unofficial mirror of bug-gnu-emacs@gnu.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

* bug#10123: 24.0.91; [PATCH] make Imenu ignore invisible definitions
  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
  0 siblings, 1 reply; 4+ messages in thread
From: Drew Adams @ 2011-11-24  0:57 UTC (permalink / raw)
  To: 10123

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

Sorry; I sent the wrong patch.  It needs to call `re-search-backward' with a
non-nil, non-t 3rd arg: (re-search-backward regexp nil 'MOVE), not
(re-search-backward regexp nil t).  The attached patch should be OK.

[-- Attachment #2: imenu-2011-11-23b.patch --]
[-- Type: application/octet-stream, Size: 1495 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 'MOVE))))
!                                           (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

* bug#10123: 24.0.91; [PATCH] make Imenu ignore invisible definitions
  2011-11-24  0:57 ` Drew Adams
@ 2011-11-24 16:46   ` Drew Adams
  2012-04-12 20:01     ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: Drew Adams @ 2011-11-24 16:46 UTC (permalink / raw)
  To: 10123

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

Might as well use `invisible-p', so it works for invisibility from overlays as
well as from text properties.  Patch attached.

[-- Attachment #2: imenu-2011-11-24a.patch --]
[-- Type: application/octet-stream, Size: 1478 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  (invisible-p (point))))
!                                     (or (not invis)
!                                         (progn
!                                           (while (and invis  (not (bobp)))
!                                             (setq invis  (not (re-search-backward regexp nil 'MOVE))))
!                                           (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

* bug#10123: 24.0.91; [PATCH] make Imenu ignore invisible definitions
  2011-11-24 16:46   ` Drew Adams
@ 2012-04-12 20:01     ` Lars Magne Ingebrigtsen
  0 siblings, 0 replies; 4+ messages in thread
From: Lars Magne Ingebrigtsen @ 2012-04-12 20:01 UTC (permalink / raw)
  To: Drew Adams; +Cc: 10123

"Drew Adams" <drew.adams@oracle.com> writes:

> Might as well use `invisible-p', so it works for invisibility from overlays as
> well as from text properties.  Patch attached.

Thanks; I've now applied this to the Emacs trunk (with some white-space
fixes).

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/





^ 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 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).