From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Glenn Morris Newsgroups: gmane.emacs.devel Subject: which-function-mode and imenu submenus Date: Sun, 13 Apr 2003 18:49:48 +0100 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1050257038 19600 80.91.224.249 (13 Apr 2003 18:03:58 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sun, 13 Apr 2003 18:03:58 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Sun Apr 13 20:03:56 2003 Return-path: Original-Received: from mail-relay.eunet.no ([193.71.71.242]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 194lpb-00055o-00 for ; Sun, 13 Apr 2003 20:03:55 +0200 Original-Received: from quimby.gnus.org (quimby.gnus.org [80.91.224.244]) by mail-relay.eunet.no (8.12.2/8.12.2/GN) with ESMTP id h3DI4UxP001301 for ; Sun, 13 Apr 2003 20:04:34 +0200 (CEST) (envelope-from emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org) Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 194ldo-0001Vj-00 for ; Sun, 13 Apr 2003 19:51:44 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 194lcN-0005NE-00 for emacs-devel@quimby.gnus.org; Sun, 13 Apr 2003 13:50:15 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 194lc0-0005KA-00 for emacs-devel@gnu.org; Sun, 13 Apr 2003 13:49:52 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 194lbz-0005Jz-00 for emacs-devel@gnu.org; Sun, 13 Apr 2003 13:49:51 -0400 Original-Received: from brown.csi.cam.ac.uk ([131.111.8.14]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 194lby-0005HY-00 for emacs-devel@gnu.org; Sun, 13 Apr 2003 13:49:50 -0400 Original-Received: from cass41.ast.cam.ac.uk ([131.111.69.186]) by brown.csi.cam.ac.uk with esmtp (Exim 4.12) id 194lbx-0007qW-00 for emacs-devel@gnu.org; Sun, 13 Apr 2003 18:49:49 +0100 Original-Received: from xserv1.ast.cam.ac.uk[131.111.69.235]) h3DHnngD006692; Sun, 13 Apr 2003 18:49:49 +0100 (BST) Original-Received: from xserv1.ast.cam.ac.uk[131.111.69.55]) by xserv1.ast.cam.ac.uk (8.11.6/8.11.6) with ESMTP id h3DHnml18803; Sun, 13 Apr 2003 18:49:49 +0100 Original-To: emacs-devel@gnu.org X-Attribution: GM Mail-Followup-To: emacs-devel@gnu.org User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/directory/emacs.html) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Emacs development discussions. List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:13207 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:13207 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)