branch: elpa/drupal-mode
commit d09cdf87816638bde3c2476977cfe810db9325f4
Author: Arne Jørgensen <[email protected]>
Commit: Arne Jørgensen <[email protected]>
User error if the hook is already inserted in the file.
Fixes #22.
---
drupal-mode.el | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drupal-mode.el b/drupal-mode.el
index 132e3d7364..5185385965 100644
--- a/drupal-mode.el
+++ b/drupal-mode.el
@@ -1,6 +1,6 @@
;;; drupal-mode.el --- Advanced minor mode for Drupal development
-;; Copyright (C) 2012, 2013, 2014 Arne Jørgensen
+;; Copyright (C) 2012, 2013, 2014, 2015 Arne Jørgensen
;; Author: Arne Jørgensen <[email protected]>
;; URL: https://github.com/arnested/drupal-mode
@@ -559,6 +559,10 @@ buffer."
(concat "Implements " hook "(): ")
(drupal-next-update-id)))
(replace-regexp-in-string (regexp-quote
update-id-placeholder) (number-to-string update-id) hook t))
hook))))
+ ;; User error if the hook is already inserted in the file.
+ (when (and (boundp 'imenu--index-alist)
+ (assoc (replace-regexp-in-string "^hook" (drupal-module-name) v2)
(assoc "Named Functions" imenu--index-alist)))
+ (user-error "%s already exists in file." (replace-regexp-in-string "^hook"
(drupal-module-name) v2)))
(drupal-ensure-newline)
"/**\n"
" * Implements " str "().\n"