From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alex Branham Newsgroups: gmane.emacs.bugs Subject: bug#33695: [PATCH] Fix which-function reporting outdated information Date: Wed, 19 Dec 2018 09:42:51 -0600 Message-ID: <87pntxed50.fsf@gmail.com> References: <87tvjlmcoe.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1545235078 8970 195.159.176.226 (19 Dec 2018 15:57:58 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 19 Dec 2018 15:57:58 +0000 (UTC) User-Agent: mu4e 1.1.0; emacs 27.0.50 To: 33695@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Dec 19 16:57:53 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gZeEL-0002C5-A8 for geb-bug-gnu-emacs@m.gmane.org; Wed, 19 Dec 2018 16:57:53 +0100 Original-Received: from localhost ([::1]:60979 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZeGS-00051i-2X for geb-bug-gnu-emacs@m.gmane.org; Wed, 19 Dec 2018 11:00:04 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38254) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZe14-000279-5D for bug-gnu-emacs@gnu.org; Wed, 19 Dec 2018 10:44:11 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZe0w-0004VL-O8 for bug-gnu-emacs@gnu.org; Wed, 19 Dec 2018 10:44:09 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:50727) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gZe0w-0004Us-HD for bug-gnu-emacs@gnu.org; Wed, 19 Dec 2018 10:44:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gZe0w-0001kw-EQ for bug-gnu-emacs@gnu.org; Wed, 19 Dec 2018 10:44:02 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <87tvjlmcoe.fsf@gmail.com> Resent-From: Alex Branham Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 19 Dec 2018 15:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33695 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 33695-submit@debbugs.gnu.org id=B33695.15452341836669 (code B ref 33695); Wed, 19 Dec 2018 15:44:02 +0000 Original-Received: (at 33695) by debbugs.gnu.org; 19 Dec 2018 15:43:03 +0000 Original-Received: from localhost ([127.0.0.1]:54985 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gZdzz-0001jV-3P for submit@debbugs.gnu.org; Wed, 19 Dec 2018 10:43:03 -0500 Original-Received: from mail-oi1-f195.google.com ([209.85.167.195]:41682) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gZdzw-0001j0-Hn for 33695@debbugs.gnu.org; Wed, 19 Dec 2018 10:43:01 -0500 Original-Received: by mail-oi1-f195.google.com with SMTP id j21so1928591oii.8 for <33695@debbugs.gnu.org>; Wed, 19 Dec 2018 07:43:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=user-agent:from:to:cc:subject:date:message-id:mime-version; bh=9JT5WdAX130z3DEtishIyldJmjcgl+ekB/a/Nm8FaCI=; b=ncbsTGwub1+vSDgWDgFVuwdWSD00U8AvCvVdKpzVVXKbHsbNl5j3bwqrrmHXwHXwTP bk+K3WCsFPwGrIGCzxQtwtqRe+AmgZP0O9jnN7ZZ+Fj02CJML2mfeuA1My7EjHv2gSza LptbK08rzLg+Cv59PdriRHA4DL1uqb4wuOml6J0ey6NeFVgSQz/UGLW29GEMqtcIUASs un5iK8E3TcoYIfgQOVRePtbSW3DUgXXOIeczYeKo3LLG1HaF9HEXo+8F73w/R5wuHAQD 6t5UDxGTc5Brjj16+kaHhAjmFRGs9TgNN5JKJlw01vjgyAEORpocxUBiSumz1Ag039Xl F0/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:user-agent:from:to:cc:subject:date:message-id :mime-version; bh=9JT5WdAX130z3DEtishIyldJmjcgl+ekB/a/Nm8FaCI=; b=rdEjcXOCiUb3GRuBzAtc+mVrRNNNKHOb6sK69rsHC4mAvbrlFlOEzuB4EwT+8hRw/3 P0edKi50l4dtEuSkM9VDiHWbQoOtDpPDJKFDRKQxV9nRA1p427UQeDv2u7AX1HZ5HoYa kx1DTqKirgzz0UqIFk1ue8hjw4rv+RJPOXr6E+S0Emw3odslYDxuEkyRi1NVqvBoi8+e nqEU0pa+dS2vV8lM2ZZHPF2sDi88qXbTBah3mZYpFPfxJw/NDYpU0H+YzKHHZW4Z1rg4 mc40/ioxfHDvfnJ+Fj1HKC73tvopFt2HzK4LGuwHcGIT4C/EQpQNM7ZnE7ESEKCmA07N Fdxw== X-Gm-Message-State: AA+aEWYwpoap5KgEGPht68ofFJP1wNoq5HORqgVNHopINvZEAjSzYh9Z pKIQWO5/0EhCZfnZGov7cSk= X-Google-Smtp-Source: AFSGD/WG3KTx+gaWjM68Ic3C/IlWkyURPHCal2+O8JVK0DsKUiIO3Ut/P8hK/Y0ZRglfASEXjXylsg== X-Received: by 2002:aca:52d4:: with SMTP id g203mr1451785oib.14.1545234174586; Wed, 19 Dec 2018 07:42:54 -0800 (PST) Original-Received: from earth (cpe-70-114-192-208.austin.res.rr.com. [70.114.192.208]) by smtp.gmail.com with ESMTPSA id r11sm9454246oib.45.2018.12.19.07.42.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 19 Dec 2018 07:42:53 -0800 (PST) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:153600 Archived-At: --=-=-= Content-Type: text/plain Hello - The following patch fixes `which-function' returning outdated imenu information by: 1. Preferring `add-log-current-defun' over `imenu--index-alist' and 2. Updating `imenu--index-alist' more aggressively if we fall back to it. Thanks, Alex >From a06b1318f23b3f67ed0e1041f50ccea67d46ea48 Mon Sep 17 00:00:00 2001 From: Alex Branham Date: Tue, 11 Dec 2018 08:29:50 -0600 Subject: [PATCH] which-function: Do not display outdated imenu information * lisp/progmodes/which-func.el (which-function): Check `add-log-current-defun' before imenu. Update `imenu--index-alist' if needed. Bug #33695 --- lisp/progmodes/which-func.el | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lisp/progmodes/which-func.el b/lisp/progmodes/which-func.el index 7604be0c25..7cc75e0edb 100644 --- a/lisp/progmodes/which-func.el +++ b/lisp/progmodes/which-func.el @@ -272,16 +272,21 @@ which-func-functions (defun which-function () "Return current function name based on point. -Uses `which-func-functions', `imenu--index-alist' -or `add-log-current-defun'. +Uses `which-func-functions', `add-log-current-defun'. +or `imenu--index-alist' If no function name is found, return nil." (let ((name ;; Try the `which-func-functions' functions first. (run-hook-with-args-until-success 'which-func-functions))) - + ;; Try using add-log support. + (when (null name) + (setq name (add-log-current-defun))) ;; If Imenu is loaded, try to make an index alist with it. (when (and (null name) - (boundp 'imenu--index-alist) (null imenu--index-alist) + (boundp 'imenu--index-alist) + (or (null imenu--index-alist) + ;; Update if outdated + (/= (buffer-chars-modified-tick) imenu-menubar-modified-tick)) (null which-function-imenu-failed)) (ignore-errors (imenu--make-index-alist t)) (unless imenu--index-alist @@ -323,10 +328,6 @@ which-function (funcall which-func-imenu-joiner-function (reverse (cons (car pair) namestack)))))))))))) - - ;; Try using add-log support. - (when (null name) - (setq name (add-log-current-defun))) ;; Filter the name if requested. (when name (if which-func-cleanup-function -- 2.19.2 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-which-function-Do-not-display-outdated-imenu-informa.patch >From a06b1318f23b3f67ed0e1041f50ccea67d46ea48 Mon Sep 17 00:00:00 2001 From: Alex Branham Date: Tue, 11 Dec 2018 08:29:50 -0600 Subject: [PATCH] which-function: Do not display outdated imenu information * lisp/progmodes/which-func.el (which-function): Check `add-log-current-defun' before imenu. Update `imenu--index-alist' if needed. Bug #33695 --- lisp/progmodes/which-func.el | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lisp/progmodes/which-func.el b/lisp/progmodes/which-func.el index 7604be0c25..7cc75e0edb 100644 --- a/lisp/progmodes/which-func.el +++ b/lisp/progmodes/which-func.el @@ -272,16 +272,21 @@ which-func-functions (defun which-function () "Return current function name based on point. -Uses `which-func-functions', `imenu--index-alist' -or `add-log-current-defun'. +Uses `which-func-functions', `add-log-current-defun'. +or `imenu--index-alist' If no function name is found, return nil." (let ((name ;; Try the `which-func-functions' functions first. (run-hook-with-args-until-success 'which-func-functions))) - + ;; Try using add-log support. + (when (null name) + (setq name (add-log-current-defun))) ;; If Imenu is loaded, try to make an index alist with it. (when (and (null name) - (boundp 'imenu--index-alist) (null imenu--index-alist) + (boundp 'imenu--index-alist) + (or (null imenu--index-alist) + ;; Update if outdated + (/= (buffer-chars-modified-tick) imenu-menubar-modified-tick)) (null which-function-imenu-failed)) (ignore-errors (imenu--make-index-alist t)) (unless imenu--index-alist @@ -323,10 +328,6 @@ which-function (funcall which-func-imenu-joiner-function (reverse (cons (car pair) namestack)))))))))))) - - ;; Try using add-log support. - (when (null name) - (setq name (add-log-current-defun))) ;; Filter the name if requested. (when name (if which-func-cleanup-function -- 2.19.2 --=-=-=--