From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh Newsgroups: gmane.emacs.bugs Subject: bug#66283: 30.0.50; which-function-mode: When configured to display in header, and toggling off, then does not remove header Date: Wed, 04 Oct 2023 09:57:15 -0400 Message-ID: References: <87edif9xqh.fsf@posteo.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34591"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Author , 66283@debbugs.gnu.org, Committer To: Mekeor Melire Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Oct 04 15:57:56 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qo2Nw-0008eu-2k for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 04 Oct 2023 15:57:56 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qo2Nn-0007TZ-58; Wed, 04 Oct 2023 09:57:47 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qo2Nl-0007Pl-8p for bug-gnu-emacs@gnu.org; Wed, 04 Oct 2023 09:57:45 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qo2Nl-0005DT-1A for bug-gnu-emacs@gnu.org; Wed, 04 Oct 2023 09:57:45 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qo2O2-0007oz-AF for bug-gnu-emacs@gnu.org; Wed, 04 Oct 2023 09:58:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 04 Oct 2023 13:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66283 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed Original-Received: via spool by 66283-submit@debbugs.gnu.org id=B66283.169642786130036 (code B ref 66283); Wed, 04 Oct 2023 13:58:02 +0000 Original-Received: (at 66283) by debbugs.gnu.org; 4 Oct 2023 13:57:41 +0000 Original-Received: from localhost ([127.0.0.1]:45058 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qo2Ng-0007oO-PH for submit@debbugs.gnu.org; Wed, 04 Oct 2023 09:57:41 -0400 Original-Received: from mxout5.mail.janestreet.com ([64.215.233.18]:38383) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qo2Nf-0007oA-2F for 66283@debbugs.gnu.org; Wed, 04 Oct 2023 09:57:39 -0400 In-Reply-To: <87edif9xqh.fsf@posteo.de> (Mekeor Melire's message of "Sat, 30 Sep 2023 20:41:05 +0000") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:271802 Archived-At: --=-=-= Content-Type: text/plain Thanks for the report. The attached patch should fix this. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Remove-the-header-line-after-disabling-which-functio.patch >From a6cc873b67a0cc420abfb3d5ec08426cbfe733a8 Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Wed, 4 Oct 2023 09:53:47 -0400 Subject: [PATCH] Remove the header line after disabling which-function-mode Previously, the header line would stay around even when after disabling which-function-mode, although it may be empty. Now the which-function-mode element is properly removed from header-line-format, so the header line will disappear if there's nothing else in header-line-format. Also, we now check that header-line-format is a list before trying to add to it; this makes us work properly when enabling and disabling which-function-mode for modes which set header-line-format to a string or symbol, such as eww. * lisp/progmodes/which-func.el (which-func-try-to-enable): Re-add which-func-format to the header line. (which-func--header-line-remove): Add. (which-func--disable): Call which-func--header-line-remove. (which-function-mode): Call which-func--header-line-remove. --- lisp/progmodes/which-func.el | 41 ++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/lisp/progmodes/which-func.el b/lisp/progmodes/which-func.el index 09d0250515f..77b84615fdc 100644 --- a/lisp/progmodes/which-func.el +++ b/lisp/progmodes/which-func.el @@ -208,21 +208,28 @@ which-func--use-mode-line (add-hook 'after-change-major-mode-hook #'which-func-ff-hook t) (defun which-func-try-to-enable () - (unless (or (not which-function-mode) - (local-variable-p 'which-func-mode)) - (setq which-func-mode (or (eq which-func-modes t) - (member major-mode which-func-modes))) - (setq which-func--use-mode-line - (member which-func-display '(mode mode-and-header))) - (setq which-func--use-header-line - (member which-func-display '(header mode-and-header))) - (when (and which-func-mode which-func--use-header-line) - (add-to-list 'header-line-format '("" which-func-format " "))))) + (when which-function-mode + (unless (local-variable-p 'which-func-mode) + (setq which-func-mode (or (eq which-func-modes t) + (member major-mode which-func-modes))) + (setq which-func--use-mode-line + (member which-func-display '(mode mode-and-header))) + (setq which-func--use-header-line + (member which-func-display '(header mode-and-header)))) + ;; We might need to re-add which-func-format to the header line, + ;; if which-function-mode was toggled off and on. + (when (and which-func-mode which-func--use-header-line + (listp header-line-format)) + (add-to-list 'header-line-format '("" which-func-format " ")))) + +(defun which-func--header-line-remove () + (when (and which-func-mode which-func--use-header-line + (listp header-line-format)) + (setq header-line-format + (delete '("" which-func-format " ") header-line-format)))) (defun which-func--disable () - (when (and which-func-mode which-func--use-header-line) - (setq header-line-format - (delete '("" which-func-format " ") header-line-format))) + (which-func--header-line-remove) (setq which-func-mode nil)) (defun which-func-ff-hook () @@ -288,9 +295,11 @@ which-function-mode (when which-function-mode ;;Turn it on. (setq which-func-update-timer - (run-with-idle-timer idle-update-delay t #'which-func-update)) - (dolist (buf (buffer-list)) - (with-current-buffer buf (which-func-try-to-enable))))) + (run-with-idle-timer idle-update-delay t #'which-func-update))) + (dolist (buf (buffer-list)) + (with-current-buffer buf + (which-func--header-line-remove) + (which-func-try-to-enable)))) (defvar which-function-imenu-failed nil "Locally t in a buffer if `imenu--make-index-alist' found nothing there.") -- 2.39.3 --=-=-=--