emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

which-function-mode and imenu submenus


From: Glenn Morris
Subject: which-function-mode and imenu submenus
Date: Sun, 13 Apr 2003 18:49:48 +0100
User-agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/directory/emacs.html)

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 via email to

[Prev in Thread] Current Thread [Next in Thread]