Skip to content

Commit d09cdf8

Browse files
committed
User error if the hook is already inserted in the file.
Fixes #22.
1 parent 5b5ab1f commit d09cdf8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drupal-mode.el

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
;;; drupal-mode.el --- Advanced minor mode for Drupal development
22

3-
;; Copyright (C) 2012, 2013, 2014 Arne Jørgensen
3+
;; Copyright (C) 2012, 2013, 2014, 2015 Arne Jørgensen
44

55
;; Author: Arne Jørgensen <[email protected]>
66
;; URL: https://github.com/arnested/drupal-mode
@@ -559,6 +559,10 @@ buffer."
559559
(concat "Implements " hook "(): ") (drupal-next-update-id)))
560560
(replace-regexp-in-string (regexp-quote update-id-placeholder) (number-to-string update-id) hook t))
561561
hook))))
562+
;; User error if the hook is already inserted in the file.
563+
(when (and (boundp 'imenu--index-alist)
564+
(assoc (replace-regexp-in-string "^hook" (drupal-module-name) v2) (assoc "Named Functions" imenu--index-alist)))
565+
(user-error "%s already exists in file." (replace-regexp-in-string "^hook" (drupal-module-name) v2)))
562566
(drupal-ensure-newline)
563567
"/**\n"
564568
" * Implements " str "().\n"

0 commit comments

Comments
 (0)