branch: elpa/drupal-mode
commit 493acf44da901ee746559d80c83182f19dd33027
Author: Arne Jørgensen <[email protected]>
Commit: Arne Jørgensen <[email protected]>
Redone building `drupal-mode-map`.
This way it is easier to also add the mnemonic keys / functions to other
key bindings. I.e. I do the following in my .emacs to map them to the
hyper key:
```
(add-hook 'drupal-mode-hook (lambda ()
(dolist (elem drupal-mode-map-alist)
(local-set-key `[(hyper ,(car elem))] (cdr
elem)))))
```
---
drupal-mode.el | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/drupal-mode.el b/drupal-mode.el
index 7d75e17872..e87a75f733 100644
--- a/drupal-mode.el
+++ b/drupal-mode.el
@@ -188,14 +188,23 @@ Include path to the executable if it is not in your
$PATH."
(make-variable-buffer-local 'drupal-project)
(put 'drupal-project 'safe-local-variable 'string-or-null-p)
+(defvar drupal-mode-map-alist
+ '((?d . drupal-search-documentation)
+ (?c . drupal-drush-cache-clear)
+ (?h . drupal-insert-hook)
+ (?f . drupal-insert-function)
+ (?m . drupal-module-name)
+ (?t . drupal-wrap-string-in-t-function))
+ "Map of mnemonic keys and functions for keyboard shortcuts.
+See `drupal-mode-map'.")
+
(defvar drupal-mode-map
(let ((map (make-sparse-keymap)))
- (define-key map [(control c) (control v) (control d)]
#'drupal-search-documentation)
- (define-key map [(control c) (control v) (control c)]
#'drupal-drush-cache-clear)
- (define-key map [(control c) (control v) (control h)] #'drupal-insert-hook)
- (define-key map [(control c) (control v) (control f)]
#'drupal-insert-function)
- (define-key map [(control c) (control v) (control m)] #'drupal-module-name)
- (define-key map [(control c) (control v) (control t)]
#'drupal-wrap-string-in-t-function)
+ ;; Iterate `drupal-mode-map-alist' and assign the functions to the
+ ;; mode map on C-c C-v C-`mnemonic-key'.
+ (dolist (elem drupal-mode-map-alist)
+ (define-key map `[(control c) (control v) (control ,(car elem))] (cdr
elem)))
+
(define-key map [(control a)] #'drupal-mode-beginning-of-line)
map)
"Keymap for `drupal-mode'")