unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
To: 10123@debbugs.gnu.org
Subject: bug#10123: 24.0.91; [PATCH] make Imenu ignore invisible definitions
Date: Wed, 23 Nov 2011 16:36:42 -0800	[thread overview]
Message-ID: <CDCFC1B2A82F4E6BA8BE80E556BA8182@us.oracle.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1080 bytes --]

The attached patch makes Imenu ignore definitions that are in invisible
text.
 
This is especially useful when combined with code that hides comments,
in which case definitions that are commented out are not included in the
Imenu.  (Obviously, that behavior should be optional, as it is sometimes
helpful to use Imenu to get to commented-out definitions too.)

Someone else might have a more elegant or more performant way to do this,
but this way seems to work OK.

In GNU Emacs 24.0.91.1 (i386-mingw-nt5.1.2600) of 2011-11-21 on MARVIN
 Windowing system distributor `Microsoft Corp.', version 5.1.2600
 configured using `configure --with-gcc (4.6) --no-opt --cflags
 -ID:/devel/emacs/libs/libXpm-3.5.8/include
 -ID:/devel/emacs/libs/libXpm-3.5.8/src
 -ID:/devel/emacs/libs/libpng-dev_1.4.3-1/include
 -ID:/devel/emacs/libs/zlib-dev_1.2.5-2/include
 -ID:/devel/emacs/libs/giflib-4.1.4-1/include
 -ID:/devel/emacs/libs/jpeg-6b-4/include
 -ID:/devel/emacs/libs/tiff-3.8.2-1/include
 -ID:/devel/emacs/libs/gnutls-2.10.1/include --ldflags
 -LD:/devel/emacs/libs/gnutls-2.10.1/lib'
 

[-- Attachment #2: imenu-2011-11-23.patch --]
[-- Type: application/octet-stream, Size: 1491 bytes --]

diff -c -w "imenu.el" "imenupatched.el"
*** imenu.el	Wed Nov 23 13:43:14 2011
--- imenu-patched.el	Wed Nov 23 13:47:16 2011
***************
*** 800,806 ****
  	      (goto-char (point-max))
  	      (while (and (if (functionp regexp)
  			      (funcall regexp)
! 			    (re-search-backward regexp nil t))
  			  ;; Exit the loop if we get an empty match,
  			  ;; because it means a bad regexp was specified.
  			  (not (= (match-beginning 0) (match-end 0))))
--- 800,813 ----
                 (goto-char (point-max))
                 (while (and (if (functionp regexp)
                                 (funcall regexp)
!                              (and (re-search-backward regexp nil t)
!                                   ;; Do not count invisible definitions.
!                                   (let ((invis  (get-text-property (point) 'invisible)))
!                                     (or (not invis)
!                                         (progn
!                                           (while (and invis  (not (bobp)))
!                                             (setq invis  (not (re-search-backward regexp nil t))))
!                                           (not invis))))))
                             ;; Exit the loop if we get an empty match,
                             ;; because it means a bad regexp was specified.
                             (not (= (match-beginning 0) (match-end 0))))

Diff finished at Wed Nov 23 13:48:05

             reply	other threads:[~2011-11-24  0:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-24  0:36 Drew Adams [this message]
2011-11-24  0:57 ` bug#10123: 24.0.91; [PATCH] make Imenu ignore invisible definitions Drew Adams
2011-11-24 16:46   ` Drew Adams
2012-04-12 20:01     ` Lars Magne Ingebrigtsen

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CDCFC1B2A82F4E6BA8BE80E556BA8182@us.oracle.com \
    --to=drew.adams@oracle.com \
    --cc=10123@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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).