all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#10123: 24.0.91; [PATCH] make Imenu ignore invisible definitions
@ 2011-11-24  0:36 Drew Adams
  2011-11-24  0:57 ` Drew Adams
  0 siblings, 1 reply; 4+ messages in thread
From: Drew Adams @ 2011-11-24  0:36 UTC (permalink / raw)
  To: 10123

[-- 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-04-12 20:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-24  0:36 bug#10123: 24.0.91; [PATCH] make Imenu ignore invisible definitions Drew Adams
2011-11-24  0:57 ` Drew Adams
2011-11-24 16:46   ` Drew Adams
2012-04-12 20:01     ` Lars Magne Ingebrigtsen

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.