To configure imenu in my major mode, I need to set imenu-generic-expression
to have regexps for functions.
However, this is incorrectly detects things inside comments and strings that look like functions.
How do I prevent this? imenu
isn't confused by the following elisp, but I can't see what emacs-lisp-mode
is doing differently.
;; imenu detects this.
(defun foo () (foo))
;; imenu correctly ignores this, even though it's at
;; the beginning of the line.
"
(defun bar () (bar))
"
;; imenu correctly ignores this.
;; (defun baz () (baz))
;; imenu correctly detects this, even though it's not
;; at the beginning of the line.
(defun boz () (boz))