unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Glenn Morris <gmorris+mail@ast.cam.ac.uk>
Subject: which-function-mode and imenu submenus
Date: Sun, 13 Apr 2003 18:49:48 +0100	[thread overview]
Message-ID: <okwuhyp9s3.fsf@xpc21.ast.cam.ac.uk> (raw)


imenu--index-alist may be defined so as to contain submenus. For
example, the value for emacs-lisp mode has submenus for "Types" and
"Variables". which-function doesn't understand imenu submenus, so
that, for example, if one activates which-function-mode in
which-function.el and places the cursor inside the definition of the
variable which-func-current, one just sees "Variables" in the
mode-line rather than the actual name of the variable.

Does this patch look OK?

===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/which-func.el,v
retrieving revision 1.29
diff -c -r1.29 which-func.el
*** which-func.el	4 Feb 2003 12:14:20 -0000	1.29
--- which-func.el	13 Apr 2003 17:47:05 -0000
***************
*** 76,82 ****
  
  (defcustom which-func-modes
    '(emacs-lisp-mode c-mode c++-mode perl-mode cperl-mode makefile-mode
! 		    sh-mode fortran-mode)
    "List of major modes for which Which Function mode should be used.
  For other modes it is disabled.  If this is equal to t,
  then Which Function mode is enabled in any major mode that supports it."
--- 76,82 ----
  
  (defcustom which-func-modes
    '(emacs-lisp-mode c-mode c++-mode perl-mode cperl-mode makefile-mode
! 		    sh-mode fortran-mode f90-mode)
    "List of major modes for which Which Function mode should be used.
  For other modes it is disabled.  If this is equal to t,
  then Which Function mode is enabled in any major mode that supports it."
***************
*** 216,229 ****
  	(setq which-function-imenu-failed t)))
      ;; If we have an index alist, use it.
      (when (and (boundp 'imenu--index-alist) imenu--index-alist)
!       (let ((pair (car-safe imenu--index-alist))
! 	    (rest (cdr-safe imenu--index-alist)))
! 	(while (and (or rest pair)
! 		    (or (not (number-or-marker-p (cdr pair)))
! 			(> (point) (cdr pair))))
! 	  (setq name (car pair))
! 	  (setq pair (car-safe rest))
! 	  (setq rest (cdr-safe rest)))))
      ;; Try using add-log support.
      (when (and (null name) (boundp 'add-log-current-defun-function)
  	       add-log-current-defun-function)
--- 216,239 ----
  	(setq which-function-imenu-failed t)))
      ;; If we have an index alist, use it.
      (when (and (boundp 'imenu--index-alist) imenu--index-alist)
!       (let ((alist imenu--index-alist)
!             (minoffset (point-max))
!             offset elem pair mark)
!         (while alist
!           (setq elem  (car-safe alist)
!                 alist (cdr-safe alist))
!           (and (number-or-marker-p (cdr elem))
!                (setq elem (list elem)))
!           (while elem
!             (setq pair (car elem)
!                   elem (cdr elem))
!             (and (consp pair)
!                  (number-or-marker-p (setq mark (cdr pair)))
!                  (if (>= (setq offset (- (point) mark)) 0)
!                      (and (< offset minoffset)
!                           (setq minoffset offset
!                                 name (car pair)))
!                    (setq elem nil)))))))
      ;; Try using add-log support.
      (when (and (null name) (boundp 'add-log-current-defun-function)
  	       add-log-current-defun-function)

                 reply	other threads:[~2003-04-13 17:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=okwuhyp9s3.fsf@xpc21.ast.cam.ac.uk \
    --to=gmorris+mail@ast.cam.ac.uk \
    /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).