From e6ed8f08460d9bc9af7109c5a8619b3d1d407bdf Mon Sep 17 00:00:00 2001 From: Feng Li Date: Thu, 10 Jan 2013 10:36:01 -0500 Subject: [PATCH] * lisp/progmodes/which-func.el (which-function): Understand Semantic's use of overlays in imenu--index-alist. --- lisp/ChangeLog | 5 +++++ lisp/imenu.el | 2 ++ lisp/progmodes/which-func.el | 4 +++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index f26c009bf2b..f74abc427af 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2013-01-10 Feng Li (tiny change) + + * progmodes/which-func.el (which-function): Understand Semantic's use + of overlays in imenu--index-alist. + 2013-01-10 Wolfgang Jenkner * man.el: Handle different "man -k" behaviors (bug#13160). Use utf-8. diff --git a/lisp/imenu.el b/lisp/imenu.el index 0bfee770094..f64d1afe951 100644 --- a/lisp/imenu.el +++ b/lisp/imenu.el @@ -447,6 +447,8 @@ Don't move point." Simple elements in the alist look like (INDEX-NAME . POSITION). POSITION is the buffer position of the item; to go to the item is simply to move point to that position. +POSITION is passed to `imenu-default-goto-function', so it can be a non-number +if that variable has been changed (e.g. Semantic uses overlays for POSITIONs). Special elements look like (INDEX-NAME POSITION FUNCTION ARGUMENTS...). To \"go to\" a special element means applying FUNCTION diff --git a/lisp/progmodes/which-func.el b/lisp/progmodes/which-func.el index 0279319cc89..adf378f6bc7 100644 --- a/lisp/progmodes/which-func.el +++ b/lisp/progmodes/which-func.el @@ -319,7 +319,9 @@ If no function name is found, return nil." namestack (cons (car pair) namestack) alist (cdr pair))) - ((number-or-marker-p (setq mark (cdr pair))) + ((or (number-or-marker-p (setq mark (cdr pair))) + (and (overlayp mark) + (setq mark (overlay-start mark)))) (when (and (>= (setq offset (- (point) mark)) 0) (< offset minoffset)) ; Find the closest item. (setq minoffset offset -- 2.39.5