From: William Xu <william.xwl@gmail.com>
To: 15560@debbugs.gnu.org
Subject: bug#15560: 24.3.50; [patch] * imenu.el (imenu--generic-function): Don't generate index for comments area.
Date: Tue, 8 Oct 2013 16:17:04 +0800 [thread overview]
Message-ID: <CACzMC-BqYFN1Cseg+d_Njg=J=C3wMj3HOdtwKmi+cQ48XpTQdg@mail.gmail.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 363 bytes --]
It is annoying when imenu generates index also for functions found in
comments area. e.g., in c-mode:
/*
a : Modified filesys_init()
: hello
*/
uint8 filesys_init( void )
{
}
imenu will generate two filesys_init, which makes imenu useless.
This patch skips comment area completely. In this case, it will
generate only one filesys_init.
-William
[-- Attachment #1.2: Type: text/html, Size: 467 bytes --]
[-- Attachment #2: 0001-imenu.el-imenu-generic-function-Don-t-generate-index.patch --]
[-- Type: application/octet-stream, Size: 3396 bytes --]
From ed923157d43273a6d21498b64a0ca2869838651b Mon Sep 17 00:00:00 2001
From: William Xu <william.xwl@gmail.com>
Date: Tue, 8 Oct 2013 16:15:47 +0800
Subject: [PATCH] * imenu.el (imenu--generic-function): Don't generate index
for comments area.
---
| 52 ++++++++++++++++++++++++++--------------------------
1 file changed, 26 insertions(+), 26 deletions(-)
--git a/lisp/imenu.el b/lisp/imenu.el
index d79b0ab..9f95ff0 100644
--- a/lisp/imenu.el
+++ b/lisp/imenu.el
@@ -745,7 +745,6 @@ depending on PATTERNS."
(unwind-protect ; For syntax table.
(save-match-data
(set-syntax-table table)
-
;; Map over the elements of imenu-generic-expression
;; (typically functions, variables ...).
(dolist (pat patterns)
@@ -774,31 +773,32 @@ depending on PATTERNS."
;; because it means a bad regexp was specified.
(not (= (match-beginning 0) (match-end 0))))
(setq start (point))
- ;; Record the start of the line in which the match starts.
- ;; That's the official position of this definition.
- (goto-char (match-beginning index))
- (beginning-of-line)
- (setq beg (point))
- ;; Add this sort of submenu only when we've found an
- ;; item for it, avoiding empty, duff menus.
- (unless (assoc menu-title index-alist)
- (push (list menu-title) index-alist))
- (if imenu-use-markers
- (setq beg (copy-marker beg)))
- (let ((item
- (if function
- (nconc (list (match-string-no-properties index)
- beg function)
- rest)
- (cons (match-string-no-properties index)
- beg)))
- ;; This is the desired submenu,
- ;; starting with its title (or nil).
- (menu (assoc menu-title index-alist)))
- ;; Insert the item unless it is already present.
- (unless (member item (cdr menu))
- (setcdr menu
- (cons item (cdr menu)))))
+ ;; Record the start of the line in which the match starts.
+ ;; That's the official position of this definition.
+ (goto-char (match-beginning index))
+ (beginning-of-line)
+ (setq beg (point))
+ ;; Add this sort of submenu only when we've found an
+ ;; item for it, avoiding empty, duff menus.
+ (unless (assoc menu-title index-alist)
+ (push (list menu-title) index-alist))
+ (if imenu-use-markers
+ (setq beg (copy-marker beg)))
+ (let ((item
+ (if function
+ (nconc (list (match-string-no-properties index)
+ beg function)
+ rest)
+ (cons (match-string-no-properties index)
+ beg)))
+ ;; This is the desired submenu,
+ ;; starting with its title (or nil).
+ (menu (assoc menu-title index-alist)))
+ (unless (nth 8 (syntax-ppss)) ; inside comment block?
+ ;; Insert the item unless it is already present.
+ (unless (member item (cdr menu))
+ (setcdr menu
+ (cons item (cdr menu))))))
;; Go to the start of the match, to make sure we
;; keep making progress backwards.
(goto-char start))))
--
1.8.1.2
next reply other threads:[~2013-10-08 8:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-08 8:17 William Xu [this message]
2013-10-08 21:58 ` bug#15560: 24.3.50; [patch] * imenu.el (imenu--generic-function): Don't generate index for comments area Drew Adams
2013-10-09 9:21 ` William Xu
2013-10-09 12:23 ` Stefan Monnier
2013-10-09 14:31 ` Drew Adams
2013-10-09 14:31 ` Drew Adams
2013-11-24 21:28 ` Dmitry Gutov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CACzMC-BqYFN1Cseg+d_Njg=J=C3wMj3HOdtwKmi+cQ48XpTQdg@mail.gmail.com' \
--to=william.xwl@gmail.com \
--cc=15560@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.