Skip to content

Commit 493acf4

Browse files
committed
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))))) ```
1 parent 4e4714f commit 493acf4

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

drupal-mode.el

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,23 @@ Include path to the executable if it is not in your $PATH."
188188
(make-variable-buffer-local 'drupal-project)
189189
(put 'drupal-project 'safe-local-variable 'string-or-null-p)
190190

191+
(defvar drupal-mode-map-alist
192+
'((?d . drupal-search-documentation)
193+
(?c . drupal-drush-cache-clear)
194+
(?h . drupal-insert-hook)
195+
(?f . drupal-insert-function)
196+
(?m . drupal-module-name)
197+
(?t . drupal-wrap-string-in-t-function))
198+
"Map of mnemonic keys and functions for keyboard shortcuts.
199+
See `drupal-mode-map'.")
200+
191201
(defvar drupal-mode-map
192202
(let ((map (make-sparse-keymap)))
193-
(define-key map [(control c) (control v) (control d)] #'drupal-search-documentation)
194-
(define-key map [(control c) (control v) (control c)] #'drupal-drush-cache-clear)
195-
(define-key map [(control c) (control v) (control h)] #'drupal-insert-hook)
196-
(define-key map [(control c) (control v) (control f)] #'drupal-insert-function)
197-
(define-key map [(control c) (control v) (control m)] #'drupal-module-name)
198-
(define-key map [(control c) (control v) (control t)] #'drupal-wrap-string-in-t-function)
203+
;; Iterate `drupal-mode-map-alist' and assign the functions to the
204+
;; mode map on C-c C-v C-`mnemonic-key'.
205+
(dolist (elem drupal-mode-map-alist)
206+
(define-key map `[(control c) (control v) (control ,(car elem))] (cdr elem)))
207+
199208
(define-key map [(control a)] #'drupal-mode-beginning-of-line)
200209
map)
201210
"Keymap for `drupal-mode'")

0 commit comments

Comments
 (0)