11; ;; drupal-mode.el --- Advanced minor mode for Drupal development
22
3- ; ; Copyright (C) 2012, 2013 Arne Jørgensen
3+ ; ; Copyright (C) 2012, 2013, 2014 Arne Jørgensen
44
55; ; Author: Arne Jørgensen <[email protected] >66; ; URL: https://github.com/arnested/drupal-mode
77; ; Created: January 17, 2012
8- ; ; Version: 0.3.1
8+ ; ; Version: 0.4.0
99; ; Package-Requires: ((php-mode "1.5.0"))
1010; ; Keywords: programming, php, drupal
1111
3636(require 'php-mode )
3737(require 'format-spec )
3838
39- (eval-when-compile
39+ (eval-when-compile
4040 (require 'css-mode ))
4141
4242
@@ -62,7 +62,7 @@ If `Ask' ask the user whether to convert line endings.
6262
6363Drupal coding standards states that all text files should end in
6464a single newline (\\ n)."
65- :type `(choice
65+ :type `(choice
6666 :tag " we offer to change line endings if needed?"
6767 (const :tag " Always" t )
6868 (const :tag " Never" nil )
@@ -83,7 +83,7 @@ If `Default' do what the global setting is.
8383
8484Drupal coding standards states that lines should have no trailing
8585whitespace at the end."
86- :type `(choice
86+ :type `(choice
8787 :tag " Whether to delete all the trailing whitespace."
8888 (const :tag " Always" always)
8989 (const :tag " Default" default )
@@ -98,6 +98,7 @@ whitespace at the end."
9898%s is the search term."
9999 :type '(choice (const :tag " Api.drupal.org" " http://api.drupal.org/api/search/%v/%s" )
100100 (const :tag " Api.drupalcontrib.org" " http://api.drupalcontrib.org/api/search/%v/%s" )
101+ (const :tag " Api.drupalize.me" " http://api.drupalize.me/api/search/%v/%s" )
101102 (string :tag " Other" " http://example.com/api/search/%v/%s" ))
102103 :link '(url-link :tag " api.drupalcontrib.org" " http://api.drupalcontrib.org" )
103104 :link '(url-link :tag " api.drupal.org" " http://api.drupal.org" )
@@ -188,14 +189,23 @@ Include path to the executable if it is not in your $PATH."
188189(make-variable-buffer-local 'drupal-project )
189190(put 'drupal-project 'safe-local-variable 'string-or-null-p )
190191
192+ (defvar drupal-mode-map-alist
193+ '((?d . drupal-search-documentation)
194+ (?c . drupal-drush-cache-clear)
195+ (?h . drupal-insert-hook)
196+ (?f . drupal-insert-function)
197+ (?m . drupal-module-name)
198+ (?t . drupal-wrap-string-in-t-function))
199+ " Map of mnemonic keys and functions for keyboard shortcuts.
200+ See `drupal-mode-map' ." )
201+
191202(defvar drupal-mode-map
192203 (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 )
204+ ; ; Iterate `drupal-mode-map-alist' and assign the functions to the
205+ ; ; mode map on C-c C-v C-`mnemonic-key' .
206+ (dolist (elem drupal-mode-map-alist)
207+ (define-key map `[(control c) (control v) (control ,(car elem))] (cdr elem)))
208+
199209 (define-key map [(control a)] #'drupal-mode-beginning-of-line )
200210 map)
201211 " Keymap for `drupal-mode' " )
@@ -538,12 +548,12 @@ Heavily based on `message-beginning-of-line' from Gnus."
538548 (set zrs t )))
539549 (if (derived-mode-p 'conf-mode )
540550 (let* ((here (point ))
541- (bol (progn (beginning-of-line n) (point )))
542- (eol (point-at-eol ))
543- (eoh (re-search-forward " = *" eol t )))
544- (goto-char
545- (if (and eoh (or (< eoh here) (= bol here)))
546- eoh bol)))
551+ (bol (progn (beginning-of-line n) (point )))
552+ (eol (point-at-eol ))
553+ (eoh (re-search-forward " = *" eol t )))
554+ (goto-char
555+ (if (and eoh (or (< eoh here) (= bol here)))
556+ eoh bol)))
547557 (beginning-of-line n)))
548558
549559
@@ -666,7 +676,7 @@ Used in `drupal-insert-hook' and `drupal-insert-function'."
666676 drupal-module
667677 ; ; Otherwise fall back to a very naive
668678 ; ; way of guessing the module name.
669- (file-name-nondirectory (file-name-sans-extension (buffer-file-name )))))))
679+ (file-name-nondirectory (file-name-sans-extension (or buffer-file-name ( buffer-name ) )))))))
670680 (if (called-interactively-p 'any )
671681 (insert name)
672682 name)))
0 commit comments