@@ -403,6 +403,9 @@ should save your files with unix style end of line."
403403
404404
405405
406+ (defvar drupal-form-id-history nil
407+ " History of form_id's entered in `drupal-insert-hook' ." )
408+
406409(define-skeleton drupal-insert-hook
407410 " Insert Drupal hook function skeleton."
408411 nil
@@ -411,14 +414,24 @@ should save your files with unix style end of line."
411414 (funcall drupal-symbol-collection)
412415 drupal-symbol-collection)
413416 nil nil " hook_" ))
414- '(setq v2 (let ((case-fold-search nil ))
415- (when (string-match " \\ ([A-Z][A-Z_]*[A-Z]\\ )" v1)
416- (concat " for " (match-string 1 v1) " ()" ))))
417+ '(setq v2 (let ((case-fold-search nil )
418+ (hook v1)
419+ (form-id nil )
420+ (form-id-placeholder nil ))
421+ (if (string-match " \\ ([A-Z][A-Z_]*[A-Z]\\ )" hook)
422+ (progn
423+ (setq form-id-placeholder (match-string 1 hook))
424+ (setq form-id (read-string
425+ (concat " Implements " hook " () for (default " form-id-placeholder " ): " )
426+ nil 'drupal-form-id-history form-id-placeholder))
427+ (setq v1 (concat hook " () for " form-id))
428+ (replace-regexp-in-string (regexp-quote form-id-placeholder) form-id hook t ))
429+ hook)))
417430 (drupal-ensure-newline)
418431 " /**\n "
419- " * Implements " v1 " ()" v2 " .\n "
432+ " * Implements " v1 " ().\n "
420433 " */\n "
421- " function " (replace-regexp-in-string " ^hook" (drupal-module-name) v1 ) " (" (when drupal-get-function-args (funcall drupal-get-function-args v1 (drupal-major-version))) " ) {\n "
434+ " function " (replace-regexp-in-string " ^hook" (drupal-module-name) v2 ) " (" (when drupal-get-function-args (funcall drupal-get-function-args v1 (drupal-major-version))) " ) {\n "
422435 " " @ _ " \n "
423436 " }\n " )
424437
0 commit comments