From unknown Fri Jun 20 18:17:39 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#66283 <66283@debbugs.gnu.org> To: bug#66283 <66283@debbugs.gnu.org> Subject: Status: 30.0.50; which-function-mode: When configured to display in header, and toggling off, then does not remove header Reply-To: bug#66283 <66283@debbugs.gnu.org> Date: Sat, 21 Jun 2025 01:17:39 +0000 retitle 66283 30.0.50; which-function-mode: When configured to display in h= eader, and toggling off, then does not remove header reassign 66283 emacs submitter 66283 Mekeor Melire severity 66283 minor tag 66283 confirmed patch thanks From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 30 17:08:28 2023 Received: (at submit) by debbugs.gnu.org; 30 Sep 2023 21:08:28 +0000 Received: from localhost ([127.0.0.1]:59849 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qmhCO-0002TK-1P for submit@debbugs.gnu.org; Sat, 30 Sep 2023 17:08:28 -0400 Received: from lists.gnu.org ([2001:470:142::17]:42746) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qmhCK-0002T2-5T for submit@debbugs.gnu.org; Sat, 30 Sep 2023 17:08:26 -0400 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 1qmhBz-0004Mz-5A for bug-gnu-emacs@gnu.org; Sat, 30 Sep 2023 17:08:03 -0400 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qmhBx-0002YU-3J for bug-gnu-emacs@gnu.org; Sat, 30 Sep 2023 17:08:02 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 18DD7240101 for ; Sat, 30 Sep 2023 23:07:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1696108077; bh=Th16IOZNgYE+MidyXX7MjQY8aMUFydKWaTGy68hjurc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From; b=hgsLydd3MgYYX4H2yXO2iUh3KL/cSnsyOQ9Do8ZsWSbfxN+GNLGKl8eu5HVur4RRq h7YooI5uTxK1UcXtjxnX8BF3DqNCm6TJ/J4cmJSkup0d5BUq2qaxGXEgr6y9+sS96Q A6EICnUCeY28kN+ROsi1EsY7VMvAXvR1q3cq8z4RYWq4ctodmm6L4drtLcZh9syrxV TeQ4BY5E1v8GHfGceCjnSIcFUSBjlvc6y+1CMtwiOLURpb+c9Btb4xeFjqlR5MJ1wx rGGxz20ypWRhOEL9YqlZxo0Ryhbbd1F4hX2EmtWpNKFb3xxxEN/UHRksxhHBq1IdGS 3VDhJVtw9CYjg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Ryfv01Zykz9rxB; Sat, 30 Sep 2023 23:07:56 +0200 (CEST) From: Mekeor Melire To: bug-gnu-emacs@gnu.org Subject: 30.0.50; which-function-mode: When configured to display in header, and toggling off, then does not remove header Date: Sat, 30 Sep 2023 20:41:05 +0000 Message-ID: <87edif9xqh.fsf@posteo.de> MIME-Version: 1.0 Content-Type: text/plain; format=flowed Received-SPF: pass client-ip=185.67.36.66; envelope-from=mekeor@posteo.de; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: submit Cc: Author , Committer X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Execute: emacs -Q Configure Which Function Mode to display in header by evaluating the following; note that this is a new feature in Emacs 30: (customize-set-variable 'which-func-display 'header) Toggle Which Function Mode on by typing: M-x which-function-mode RET Toggle Which Function Mode off by typing again: M-x which-function-mode RET You can see a dysfunctional header. (It won't be update because Which Function Mode is off.) To be precise, the value of variable `header-line-format' is '(("" which-func-format " ")). Apparently, this variable has not been cleaned up appropriately. This is the job of the function `which-func--disable'. [1] In order to test the `which-func--disable' function, type: M-: (which-func--disable) RET The header disappeared. The value of variable `header-line-format' is `nil'. This means, that the function does its job well. Apparently, it's not being called when toggling off. [2] [1]: https://git.sv.gnu.org/cgit/emacs.git/tree/lisp/progmodes/which-func.el?h=35fbf6f15830f576fd1909f4a8d30e7ba1d777bd#n225 [2]: Where is the "Turn it off." comment here? https://git.sv.gnu.org/cgit/emacs.git/tree/lisp/progmodes/which-func.el?h=35fbf6f15830f576fd1909f4a8d30e7ba1d777bd#n289 -- In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.37, cairo version 1.16.0) Windowing system distributor 'The X.Org Foundation', version 11.0.12101004 System Description: Guix System From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 01 09:29:19 2023 Received: (at control) by debbugs.gnu.org; 1 Oct 2023 13:29:19 +0000 Received: from localhost ([127.0.0.1]:60892 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qmwVb-00008c-6M for submit@debbugs.gnu.org; Sun, 01 Oct 2023 09:29:19 -0400 Received: from mail-lj1-x22e.google.com ([2a00:1450:4864:20::22e]:57450) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qmwVX-00008L-Lb for control@debbugs.gnu.org; Sun, 01 Oct 2023 09:29:16 -0400 Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2c008042211so251270331fa.2 for ; Sun, 01 Oct 2023 06:28:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696166933; x=1696771733; darn=debbugs.gnu.org; h=to:subject:message-id:date:mime-version:from:from:to:cc:subject :date:message-id:reply-to; bh=esb+s+YZ3sbbp+ECoYk7xQKbwQPsv0IZ4l4InnM77Ug=; b=aXwoSoVumvvhdqREIxjlkSo/t6rXoOtD+x7J9UUJ1qT5mPUeebEol6y0kQAPSlecDa CiGWZXAMm0hzyg3nOO6m3aGBTVmbq5gqDmmnCsakjUKrtM+4D4sTJC2Q3wapP290AM1K xkM602siJ6gyiyAKv6SH1XrjiONji6FHT07heeoTq8wVqCCWli8d1ANcJ72h1bVq5kba 0Qt7mRz+UC+o93xyEMKeksUcGlVLlMZfkc3FssKi8qNXI6+o8RNFft1AxlGvSlwrdPOf lTShx/uvasRPQn8VAckJcNMr9xs07GyIHSb/Sw08Eq0GP2Wcc0Irn/uOIHQN5dIQ6T0q N7CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696166933; x=1696771733; h=to:subject:message-id:date:mime-version:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=esb+s+YZ3sbbp+ECoYk7xQKbwQPsv0IZ4l4InnM77Ug=; b=ZUUldEO31KpKNWaV7ZQXfi+8KVrZXPDkPYXJ46lAMmgCxYOgwswN38U47hTnHVLfzr 7TpsJX/qTcYoIRtV6kGgc4TSBBkRGh5ewJmQZzhJokRSGiqqUrfrL1owEBcG9UujZhat r+aiWSTPEC1pDm8R7FGB9pHNRaBbs04aJDEq1XekBRlI1drDOgvgNrnQOZro0PsG5idY EViXM0tzONPbHP9vQchpsCqiSrsBtvreWNaWXV9dB1QwJNIm8TRtwYXnCdsFW9dXZreP 51WiyLsaUuIY+5EXlwUfg0Vy51iAq7Y+xjDFKkwmx4bMTgZafZRjPp+Jb+sU2o5qmiXJ Trlg== X-Gm-Message-State: AOJu0YzbJGG9aXv2QGhvxfchcyUHSFhYsf0CSaXFcVNlzojNdcrmzKZb gyZxpIHolkRRlClGDjNLTpsGMut9orDlbtr9O38xoHO6XQk= X-Google-Smtp-Source: AGHT+IHb5kUfBiUWQu+JPnrj9xYUph476Q1mjmjn6PovDPa26rI97huzT5JiZrk+328WgfSD05KwhPIz4fMiPFlIgQk= X-Received: by 2002:a2e:870f:0:b0:2be:5b09:5544 with SMTP id m15-20020a2e870f000000b002be5b095544mr7379155lji.27.1696166933491; Sun, 01 Oct 2023 06:28:53 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Sun, 1 Oct 2023 06:28:53 -0700 From: Stefan Kangas MIME-Version: 1.0 Date: Sun, 1 Oct 2023 06:28:53 -0700 Message-ID: Subject: control message for bug #66283 To: control@debbugs.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) tags 66283 + confirmed quit From debbugs-submit-bounces@debbugs.gnu.org Wed Oct 04 09:57:41 2023 Received: (at 66283) by debbugs.gnu.org; 4 Oct 2023 13:57:41 +0000 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 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 From: Spencer Baugh To: Mekeor Melire Subject: Re: bug#66283: 30.0.50; which-function-mode: When configured to display in header, and toggling off, then does not remove header In-Reply-To: <87edif9xqh.fsf@posteo.de> (Mekeor Melire's message of "Sat, 30 Sep 2023 20:41:05 +0000") References: <87edif9xqh.fsf@posteo.de> Date: Wed, 04 Oct 2023 09:57:15 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 66283 Cc: Author , 66283@debbugs.gnu.org, Committer X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= 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 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed Oct 04 10:57:10 2023 Received: (at 66283) by debbugs.gnu.org; 4 Oct 2023 14:57:10 +0000 Received: from localhost ([127.0.0.1]:45143 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qo3JG-0003a7-5a for submit@debbugs.gnu.org; Wed, 04 Oct 2023 10:57:10 -0400 Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]:49199) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qo3JE-0003Zl-6J for 66283@debbugs.gnu.org; Wed, 04 Oct 2023 10:57:09 -0400 Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-5031ccf004cso2647847e87.2 for <66283@debbugs.gnu.org>; Wed, 04 Oct 2023 07:56:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696431404; x=1697036204; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:from:to:cc:subject:date:message-id:reply-to; bh=VkzlFJa1gguJ94JyY3MKOhHk2SNcHQzjdxtCYcAx+HE=; b=VrR2vNt0RIiPMeABji8/fMbh6VfEkAz0s2xNI+Ezite5rhg/aarC9wCm3RcQQ/LYqR 0Gv9dqDL4lXh21oWPy+cJ8r1sSHJ/6BQtpodHm4EuAaCIx2UsCFOtL+x3SabTGM1K2+l ljvHVTfayhVagYK6NbJtYG/TD8yEc4ZDBIOeO5uVRxismpjiiYhE/v9Wr4FPy+CfrhZk RUm5Lsq4yrauncUW1jSk/oAuVG3JqZLe41g6TUMazvL/KNzuVWNIzclCH3uXcsoDNwBC xYEsQF8aUl1QKBAXyCkdW1ta3riwzEwoWxmck/OcOhroasTPhM2rB2wRNR8coSYRPU1F Np3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696431404; x=1697036204; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=VkzlFJa1gguJ94JyY3MKOhHk2SNcHQzjdxtCYcAx+HE=; b=syXNC8glNu16FWg1rnYXxandD9FWDeD5/tpWvWtYk9FXxt1VTxl5JDVbjJGZfdO4ob XnYSDggebs1Z8Q6sQg+WDcE7UDkx2Hki3kUWze2jmTh0X1RRBT6kmw6e3Nzk5BkqvI7L oviIT8hzQhpwmbozlj36xMu/NwG5MRG439t9r1ns0VG4c3qG+fxg57y11N2Gs+N5GSeC TiF4O3+shijuqQdc/5BCigxuPybMlVgyJfcJ042ijHwUR/E8sjAj+NwLsrx9+nClOBDe A9U07y6ntijTcNHTYj595xgrwF8T7p8SM80+jTc75zmwC4W2AUajNL7w+AFMtqsmW5RA +Gwg== X-Gm-Message-State: AOJu0YwlGO/vCjoJP6qr8FBfXcbLz3zka5uprjXBqHAKiTUJIz+GxM12 GO36oyjj/xZucGxlPkQdRydejBtKeR6ybamBUr0= X-Google-Smtp-Source: AGHT+IHuhaXcMEGemXwRDSjLnlPTgltjUsvFoGB5XgAi/LrNCye1TMVQFwr4As+/BA4oXxl5TM3YR0VaGViwdBrNu3I= X-Received: by 2002:a05:6512:1583:b0:4ff:7602:5879 with SMTP id bp3-20020a056512158300b004ff76025879mr2795687lfb.55.1696431404102; Wed, 04 Oct 2023 07:56:44 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Wed, 4 Oct 2023 14:56:43 +0000 From: Stefan Kangas In-Reply-To: References: <87edif9xqh.fsf@posteo.de> MIME-Version: 1.0 Date: Wed, 4 Oct 2023 14:56:43 +0000 Message-ID: Subject: Re: bug#66283: 30.0.50; which-function-mode: When configured to display in header, and toggling off, then does not remove header To: Spencer Baugh , Mekeor Melire Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 66283 Cc: Author , 66283@debbugs.gnu.org, Committer X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) tags 66283 + patch thanks Spencer Baugh writes: > Thanks for the report. The attached patch should fix this. LGTM. I didn't test it, though. From debbugs-submit-bounces@debbugs.gnu.org Wed Oct 04 11:13:32 2023 Received: (at 66283) by debbugs.gnu.org; 4 Oct 2023 15:13:32 +0000 Received: from localhost ([127.0.0.1]:45172 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qo3Z6-0006g2-Bt for submit@debbugs.gnu.org; Wed, 04 Oct 2023 11:13:32 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]:58895) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qo3Z4-0006fo-7f for 66283@debbugs.gnu.org; Wed, 04 Oct 2023 11:13:30 -0400 From: Spencer Baugh To: Stefan Kangas Subject: Re: bug#66283: 30.0.50; which-function-mode: When configured to display in header, and toggling off, then does not remove header In-Reply-To: (Stefan Kangas's message of "Wed, 4 Oct 2023 14:56:43 +0000") References: <87edif9xqh.fsf@posteo.de> Date: Wed, 04 Oct 2023 11:13:06 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 66283 Cc: Mekeor Melire , Author , 66283@debbugs.gnu.org, Committer X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Two fixes to the previous patch: - There was always a bug with which-function-mode where if you enabled it when there were already existing buffers, it would behave differently than if you enabled it and then created those buffers. Namely it would enable which-func-mode for every buffer, even if the buffer didn't support imenu. This is especially noticeable when toggling which-function-mode and using the header line, so I fixed it. - Also, I accidentally dropped a paren before submitting. Now that's fixed :) --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Remove-the-header-line-after-disabling-which-functio.patch >From 9918722015e52510b12b0eeee093f11e231d14fe 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, previously, when we ran (which-function-mode), we would enable which-function-mode for all buffers even if they didn't support imenu. We didn't run the normal logic in which-func-ff-hook to disable which-func-mode if imenu wasn't present. Now we do run that logic, by just calling which-func-ff-hook. This is especially important when the header line is enabled, because otherwise there's a very noticeable header line added to every buffer, including e.g. *Help* and *Buffer List*. 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-ff-hook and which-func--header-line-remove. (bug#66283) --- lisp/progmodes/which-func.el | 39 ++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/lisp/progmodes/which-func.el b/lisp/progmodes/which-func.el index 09d0250515f..0e04bab6ea4 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) + (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--disable () - (when (and which-func-mode which-func--use-header-line) +(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))) + (delete '("" which-func-format " ") header-line-format)))) + +(defun which-func--disable () + (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-ff-hook)))) (defvar which-function-imenu-failed nil "Locally t in a buffer if `imenu--make-index-alist' found nothing there.") -- 2.39.3 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed Oct 04 15:25:30 2023 Received: (at 66283) by debbugs.gnu.org; 4 Oct 2023 19:25:30 +0000 Received: from localhost ([127.0.0.1]:45411 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qo7Uv-00017h-Sn for submit@debbugs.gnu.org; Wed, 04 Oct 2023 15:25:30 -0400 Received: from mout01.posteo.de ([185.67.36.65]:33635) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qo7Us-00017R-Tj for 66283@debbugs.gnu.org; Wed, 04 Oct 2023 15:25:28 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 3436D240028 for <66283@debbugs.gnu.org>; Wed, 4 Oct 2023 21:25:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1696447503; bh=1rP+FEQHPQ50/dFNWNESuZStm4Cj3kde7S5Fr4jcPh4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From; b=jmaqos8DXxwvZChq0wxJ4RSTItKs9lrFcGJNFVpsMUqQZsdQPlFLHcb5Eft55wdHH emZjednU6CBRVTbYS9R0oadkgcDGVv8sBi67PEzvnZ84sFxTIcbPvkCnK7Y4YCJ6SP XK17eYnpWRMReAlAPo9Xi3MTSuwO8VSvFfKykFjnq17kh7GHESFm04FCuhY1VYm0YB uKBpazqKsVNFbS602ernOuaMEx7K0rgXDmC6e0MOSDGkBuPCpol+s1hn9GcPM/j1L+ fDoxVqOk8DUXeKYHV5GQX0x/vTLoEZ0kHNVc0+yByQrcUYXiXe9D7eAGrhPcZ9MRL/ pRvWAu4vfW7mw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4S14QP3ywNz9rxT; Wed, 4 Oct 2023 21:25:01 +0200 (CEST) References: <87edif9xqh.fsf@posteo.de> From: Mekeor Melire To: 66283@debbugs.gnu.org Subject: Re: 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 19:19:41 +0000 In-reply-to: Message-ID: <87lecitcmc.fsf@posteo.de> MIME-Version: 1.0 Content-Type: text/plain; format=flowed X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 66283 Cc: Author , Committer , Stefan Kangas , Spencer Baugh X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) 2023-10-04 11:13 sbaugh@janestreet.com: > From 9918722015e52510b12b0eeee093f11e231d14fe 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 Thank you! I tested this patch quickly and simply, and it works for me. By the way, I'd also suggest to make which-function-mode not buffer-local instead of global. But I guess I should submit another bug-report for this. From debbugs-submit-bounces@debbugs.gnu.org Wed Oct 04 16:34:07 2023 Received: (at 66283) by debbugs.gnu.org; 4 Oct 2023 20:34:07 +0000 Received: from localhost ([127.0.0.1]:45449 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qo8ZK-00034L-QO for submit@debbugs.gnu.org; Wed, 04 Oct 2023 16:34:07 -0400 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]:50559) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qo8ZI-00033h-S2 for 66283@debbugs.gnu.org; Wed, 04 Oct 2023 16:34:05 -0400 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-5046bf37daeso330235e87.1 for <66283@debbugs.gnu.org>; Wed, 04 Oct 2023 13:33:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696451621; x=1697056421; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:from:to:cc:subject:date:message-id:reply-to; bh=loTnReQ02Dr7pBd9HHLPSWVkS2pBe7UvU8oeQflLAZI=; b=GeoDgvctkOa9h+8QgseuorNzdnOU9sdbvFlvaL7g2ROBaSv7BUrdHKETooTmYEIQem BS+c3Nqz1F0WltTd6uSJy35orfDe6DbbLy8oNUdl1n5bAdHfxDzSIlbImnI2tgh5ZaCm /aK7+0qgovQK1d1y0BlhHx6QnN7z/1avzsSGeN/IH4Ssh6Md0qAfGooajC6lGKP5HiM4 3A11c0ifoKKM9GzgmwBocYixnXWfrhKsReg4NiU2gcmlodBIZ5NXIQR5U9lBWuYp6CxD Na7oRQ25q8mC75y8bPL5tWVE3X+XGj8jq5aOzzmpLiTOmLAD44SM6UWhmRiVpVItkNmi 57Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696451621; x=1697056421; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=loTnReQ02Dr7pBd9HHLPSWVkS2pBe7UvU8oeQflLAZI=; b=aEb0TMwBKMq+EBWLx6f9hDIji3ZpHuShbK2Xy0npVynbMfwgLMmJEEPQYcb3EjrT+4 pkH1wFO8MlDvEhKe6ctaD2mnMgmvAyb0LyB3Bpwq0pHvVDMKigCgy7UbrucPflJKZsjY nhXXFzPxoVRk9H4PmVYHhq2ssprOjKBzIF7vQpjtSol85sydpTzEuF5M3dM77ZN2n6Vv xVowbS/2u0MA9UxZRpzwsDxsWKtyqTHZrL3ba3kqyiMVBAwKJYQxJFcXH5xVCY1HJ5O0 Iq+kA2/LBalCxNfyDIkJ4ETBdNfmO/9YK4N/RBNpKuxxL5Bh0EF+qSQJTirmwxLaUxI6 Xtmw== X-Gm-Message-State: AOJu0Yz4One4QPufMkzliwHsfUuXv6OLWZ9XctOickqj8KOpeZGTCjQF tMEiy9kywdAKIQiM5h5gRvrVzcEUpRseIs1k+Ss= X-Google-Smtp-Source: AGHT+IFcWDDpc/Kg7mgei4REvp/x8yCKbsVoYN3gwA02E/bHEouXxpHVwckaEhznkbJwJcAulI5qL30i0HKZZSehnpg= X-Received: by 2002:a05:6512:ac5:b0:500:8f66:5941 with SMTP id n5-20020a0565120ac500b005008f665941mr3517631lfu.50.1696451621009; Wed, 04 Oct 2023 13:33:41 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Wed, 4 Oct 2023 20:33:40 +0000 From: Stefan Kangas In-Reply-To: <87lecitcmc.fsf@posteo.de> References: <87edif9xqh.fsf@posteo.de> <87lecitcmc.fsf@posteo.de> MIME-Version: 1.0 Date: Wed, 4 Oct 2023 20:33:40 +0000 Message-ID: Subject: Re: bug#66283: 30.0.50; which-function-mode: When configured to display in header, and toggling off, then does not remove header To: Mekeor Melire , 66283@debbugs.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 66283 Cc: Author , Committer , Spencer Baugh X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Mekeor Melire writes: > By the way, I'd also suggest to make which-function-mode not > buffer-local instead of global. But I guess I should submit another > bug-report for this. Yes, that's a separate feature request. From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 05 17:55:40 2023 Received: (at control) by debbugs.gnu.org; 5 Oct 2023 21:55:40 +0000 Received: from localhost ([127.0.0.1]:48859 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qoWJo-0003I0-6J for submit@debbugs.gnu.org; Thu, 05 Oct 2023 17:55:40 -0400 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]:50686) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qoWJm-0003Hl-HM for control@debbugs.gnu.org; Thu, 05 Oct 2023 17:55:38 -0400 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-5046bf37daeso1935205e87.1 for ; Thu, 05 Oct 2023 14:55:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696542914; x=1697147714; darn=debbugs.gnu.org; h=to:subject:message-id:date:mime-version:from:from:to:cc:subject :date:message-id:reply-to; bh=r0Io42Mvq2aAB49BpDjkLtozeVmGndCmVn4Yk0vlFCs=; b=b8YIxeSQYoEV2VRYgfEDa6tE3jO80bhxInUJXxTjF3VC1Xv9CKu8CktbxLw4HE5uWB 98xdvYaf5bR+v2mcYmUY1QjuT8+fuPIePpKvxN7191sq3H40U4dPtkk8Ufu1twbijNS/ e40Zbd6NFyMC+hWi8Kih4bot+DCWAEdR3N3SNGCxQERp0+l6WTy+Zmi2yGZ7qOExcxp7 f8P2mfiRAtDfUwU2nlcp3pYFH7vNrOYQq0O1piexFEXu4WbrWUeLimgoRScKgX7jaudX PWNuRR4ajco79rA4Hf3IesKKbmQGjgl03rnVZglMJ5pHC3gSGmqZTZCznZvyDHRAkxEj tchw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696542914; x=1697147714; h=to:subject:message-id:date:mime-version:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=r0Io42Mvq2aAB49BpDjkLtozeVmGndCmVn4Yk0vlFCs=; b=l8Qj3iBzJpFtwEej2tCQbWmRjWODeI7JsZVQqsf5BNzIEuFYyBlpYQqngagRB2eZoM SkftAaiCQd6WWdGK6u4xn6dCJM93to4OoVSb9AMnvkcv0TD8criuv/f3YigItJmscLZv LV8rKsISXpC+CJKsBlpii5HieZzRqxc+1TPTeoLtL+noMnMhjE0rLjxLGrdp8aWCimNd JEh0BEpZp9ERSEg7xKvPGgucKL0+U1tM128br3rCpNMqjiCAicdOzb4x5LHAHwwGBwB1 RdR9UhjqqeNKpF0mseXoJnO5sMjC5MZdvHRto/9HxAG7DPWZuMpz7f9fTxV3qo/CdvOK rPxg== X-Gm-Message-State: AOJu0Yz8eSNAx1dMXuEAA1QYDX21d/q41R1WNImL+zLE85S1/Wj0MR4g QIKwJjZvScRncT9msbtjx4hMnl3k2pR8wjCSXjMphbcY X-Google-Smtp-Source: AGHT+IFlqAz9Rs14A59NopVKCn5QrK6m1LFH+SJ7Hej4+b7CIFh2NpvxRVjXGeKfmsXEdfTKVBcLA9wm5c1WzJKBta4= X-Received: by 2002:ac2:4f09:0:b0:500:b553:c09e with SMTP id k9-20020ac24f09000000b00500b553c09emr6732680lfr.32.1696542914241; Thu, 05 Oct 2023 14:55:14 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Thu, 5 Oct 2023 21:55:13 +0000 From: Stefan Kangas MIME-Version: 1.0 Date: Thu, 5 Oct 2023 21:55:13 +0000 Message-ID: Subject: control message for bug #66283 To: control@debbugs.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) severity 66283 minor quit From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 14 03:30:31 2023 Received: (at 66283) by debbugs.gnu.org; 14 Oct 2023 07:30:31 +0000 Received: from localhost ([127.0.0.1]:47765 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qrZ6U-00054O-UA for submit@debbugs.gnu.org; Sat, 14 Oct 2023 03:30:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41322) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qrZ6S-000549-Vj for 66283@debbugs.gnu.org; Sat, 14 Oct 2023 03:30:29 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qrZ60-0003lI-6L; Sat, 14 Oct 2023 03:30:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=YEqb50xKT/smhuHw7MlO0pZ9wIFz95tGU3vqjxDELRM=; b=boe1HqNStbzH phXsm9A6jOpTpeafn4ULF7BZIQ6g6bkym4owkmwew95zN7KMxEasoaZ4Myu27r+kxmF8cFM93WBSv JCKDSMXDSLKVAzODBoLu888+j9lBM/ZoGqlHyIapXdkTzm5kfoLLOOl43fByPAF5r0NNHVrBZ1H09 PBJ7t/D85+E4B83TSlqDWGh4OBjLE8NoTZlKWgsuzXYh3oH1J4kkA3UeK4LZxQHzDyCG7wmpXWz8h l2FVEcCWn7RjkR6VC/MRHxeYL+tFmZVgEAncoZbg3otoxrv9iKiVYIOxQ0j3F2TO9u2aylKm71Ds1 +96E6fFq2Wac/pC8YaNhbw==; Date: Sat, 14 Oct 2023 10:29:59 +0300 Message-Id: <83lec5slu0.fsf@gnu.org> From: Eli Zaretskii To: Spencer Baugh In-Reply-To: (message from Spencer Baugh on Wed, 04 Oct 2023 11:13:06 -0400) Subject: Re: bug#66283: 30.0.50; which-function-mode: When configured to display in header, and toggling off, then does not remove header References: <87edif9xqh.fsf@posteo.de> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 66283 Cc: mekeor@posteo.de, sbaugh@catern.com, 66283@debbugs.gnu.org, stefankangas@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Spencer Baugh > Cc: Mekeor Melire , Author , > 66283@debbugs.gnu.org, Committer > Date: Wed, 04 Oct 2023 11:13:06 -0400 > > Two fixes to the previous patch: > > - There was always a bug with which-function-mode where if you enabled > it when there were already existing buffers, it would behave > differently than if you enabled it and then created those buffers. > Namely it would enable which-func-mode for every buffer, even if the > buffer didn't support imenu. This is especially noticeable when > toggling which-function-mode and using the header line, so I fixed it. > > - Also, I accidentally dropped a paren before submitting. Now that's > fixed :) Thanks, but how about some tests for these fixes? It's high time which-mode had some test suite, I think. From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 21 10:44:06 2023 Received: (at 66283) by debbugs.gnu.org; 21 Oct 2023 14:44:06 +0000 Received: from localhost ([127.0.0.1]:44840 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1quDCv-00060K-P9 for submit@debbugs.gnu.org; Sat, 21 Oct 2023 10:44:06 -0400 Received: from s.wrqvtzvf.outbound-mail.sendgrid.net ([149.72.126.143]:57636) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1quDCt-0005zX-L4 for 66283@debbugs.gnu.org; Sat, 21 Oct 2023 10:44:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=catern.com; h=from:subject:in-reply-to:references:mime-version:to:cc:content-type: cc:content-type:from:subject:to; s=s1; bh=WtUmrJJfO4Silw0zT2w4YG/YCZFWMANL5O3hY7FXahE=; b=afcH9TDshXTwTlzAGuyb4Jl80fXoeIqbD1SY+mzTEJ2on2jtTWNRGsipq34aSEH2EYxe m7IdzqArHqiCdkdLRbLJqSE4jBRdSLmQieiLh5e8nT4MtMXqlvKcooYDdiRqEfSda7bjsA JAEvDX2SQj68n61STJ4Co2nXvmsBOIZ61+54DnhF2VK46ofYP8d32d3Ok7UGBEQPZEZRVw 4ML7rxf8Xbbs/lmilHaRl5LmRDDPtnrwv4YaF1OsDPx61KQ5IecWv5g1SSb0HSb8ixNjBR XgqRw2lDPyvOv2Dgwkw75W5Jk4EESL9hqVMF0S9mw3GnH/wXrm4OnmvQJe8Pa6Hg== Received: by filterdrecv-655bd866f5-9t24g with SMTP id filterdrecv-655bd866f5-9t24g-1-6533E392-5 2023-10-21 14:43:30.305690898 +0000 UTC m=+331357.448447410 Received: from earth.catern.com (unknown) by geopod-ismtpd-18 (SG) with ESMTP id Bv2RbpceTgG_i3d96Eb0ug Sat, 21 Oct 2023 14:43:30.235 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=::1; helo=localhost; envelope-from=sbaugh@catern.com; receiver=gnu.org Received: from localhost (localhost [IPv6:::1]) by earth.catern.com (Postfix) with ESMTPSA id BDBAE62F80; Sat, 21 Oct 2023 10:43:29 -0400 (EDT) From: sbaugh@catern.com Subject: Re: bug#66283: 30.0.50; which-function-mode: When configured to display in header, and toggling off, then does not remove header In-Reply-To: <83lec5slu0.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 14 Oct 2023 10:29:59 +0300") References: <87edif9xqh.fsf@posteo.de> <83lec5slu0.fsf@gnu.org> Date: Sat, 21 Oct 2023 14:43:30 +0000 (UTC) Message-ID: <871qdot4ry.fsf@catern.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?ZgbRq7gjGrt0q=2FPjvxk7wM0yQFRdOkTJAtEbkjCkHbKCqYzWVdt9kt3g5kFY5t?= =?us-ascii?Q?uSC5und23zjVeQuXWq0UqtVUOURXDwO9JDP5niM?= =?us-ascii?Q?UpM1S2dFUKyHX9uQKFykuotauT9U7ksaXOUL6rQ?= =?us-ascii?Q?b2hVI9bWee9Io3rgyi0sjA=2FrcG7HLIlBiMNwlub?= =?us-ascii?Q?07qo0O=2FuAeb33dtILS8kNrU0Em0EOGVSkHg=3D=3D?= To: Eli Zaretskii X-Entity-ID: d/0VcHixlS0t7iB1YKCv4Q== Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 1.2 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Eli Zaretskii writes: >> From: Spencer Baugh >> Cc: Mekeor Melire , Author , >> 66283@debbugs.gnu.org, Committer ] 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-Debbugs-Envelope-To: 66283 Cc: mekeor@posteo.de, Spencer Baugh , 66283@debbugs.gnu.org, stefankangas@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.2 (/) --=-=-= Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Eli Zaretskii writes: >> From: Spencer Baugh >> Cc: Mekeor Melire , Author , >> 66283@debbugs.gnu.org, Committer >> Date: Wed, 04 Oct 2023 11:13:06 -0400 >> >> Two fixes to the previous patch: >> >> - There was always a bug with which-function-mode where if you enabled >> it when there were already existing buffers, it would behave >> differently than if you enabled it and then created those buffers. >> Namely it would enable which-func-mode for every buffer, even if the >> buffer didn't support imenu. This is especially noticeable when >> toggling which-function-mode and using the header line, so I fixed it. >> >> - Also, I accidentally dropped a paren before submitting. Now that's >> fixed :) > > Thanks, but how about some tests for these fixes? It's high time > which-mode had some test suite, I think. Sure, here's a patch including a test. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Remove-the-header-line-after-disabling-which-functio.patch >From b0ae708df7cf81419fbbf6f81fcda31142626a27 Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Sat, 21 Oct 2023 10:41:42 -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, previously, when we ran (which-function-mode), we would enable which-function-mode for all buffers even if they didn't support imenu. We didn't run the normal logic in which-func-ff-hook to disable which-func-mode if imenu wasn't present. Now we do run that logic, by just calling which-func-ff-hook. This is especially important when the header line is enabled, because otherwise there's a very noticeable header line added to every buffer, including e.g. *Help* and *Buffer List*. 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-ff-hook and which-func--header-line-remove. (bug#66283) * test/lisp/progmodes/which-func-tests.el: Add. --- lisp/progmodes/which-func.el | 39 ++++++++++------- test/lisp/progmodes/which-func-tests.el | 58 +++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 15 deletions(-) create mode 100644 test/lisp/progmodes/which-func-tests.el diff --git a/lisp/progmodes/which-func.el b/lisp/progmodes/which-func.el index 09d0250515f..0e04bab6ea4 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) + (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--disable () - (when (and which-func-mode which-func--use-header-line) +(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))) + (delete '("" which-func-format " ") header-line-format)))) + +(defun which-func--disable () + (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-ff-hook)))) (defvar which-function-imenu-failed nil "Locally t in a buffer if `imenu--make-index-alist' found nothing there.") diff --git a/test/lisp/progmodes/which-func-tests.el b/test/lisp/progmodes/which-func-tests.el new file mode 100644 index 00000000000..73709f1c5e5 --- /dev/null +++ b/test/lisp/progmodes/which-func-tests.el @@ -0,0 +1,58 @@ +;;; which-func-tests.el --- tests for which-func -*- lexical-binding: t; -*- + +;; Copyright (C) 2023 Free Software Foundation, Inc. + +;; Author: Spencer Baugh + +;; This file is part of GNU Emacs. + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Commentary: + +;;; Code: +(require 'ert) +(require 'which-func) + +(ert-deftest which-func-tests-toggle () + (let ((which-func-display 'mode-and-header) buf-code buf-not) + (setq buf-code (find-file-noselect "which-func-tests.el")) + (setq buf-not (get-buffer-create "fundamental")) + (with-current-buffer buf-code + (should-not which-func-mode) (should-not header-line-format)) + (with-current-buffer buf-not + (should-not which-func-mode) (should-not header-line-format)) + (which-function-mode 1) + (with-current-buffer buf-code + (should which-func-mode) (should header-line-format)) + (with-current-buffer buf-not + (should-not which-func-mode) (should-not header-line-format)) + (which-function-mode -1) + ;; which-func-mode stays set even when which-function-mode is off. + (with-current-buffer buf-code + (should which-func-mode) (should-not header-line-format)) + (with-current-buffer buf-not + (should-not which-func-mode) (should-not header-line-format)) + (kill-buffer buf-code) + (kill-buffer buf-not) + (which-function-mode 1) + (setq buf-code (find-file-noselect "which-func-tests.el")) + (setq buf-not (get-buffer-create "fundamental")) + (with-current-buffer buf-code + (should which-func-mode) (should header-line-format)) + (with-current-buffer buf-not + (should-not which-func-mode) (should-not header-line-format)))) + +(provide 'which-func-tests) +;;; which-func-tests.el ends here -- 2.41.0 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 29 07:25:03 2023 Received: (at 66283-done) by debbugs.gnu.org; 29 Oct 2023 11:25:03 +0000 Received: from localhost ([127.0.0.1]:40546 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qx3uh-0004zZ-II for submit@debbugs.gnu.org; Sun, 29 Oct 2023 07:25:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52696) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qx3uf-0004z1-Eh for 66283-done@debbugs.gnu.org; Sun, 29 Oct 2023 07:25:02 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qx3u2-0004VC-5p; Sun, 29 Oct 2023 07:24:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=9p0ER63xVLTM7YBBsrdi2MXavDGDRdqLVoHLjIz4038=; b=lHWeNcsec6vv dieTx+XZ7AXEKfPRR6f3lQ/5n9h1XS8uCMhlgPagHZJfVC+46rOUDcbfeG+cabaHoj3ntFFculejz U4on+EQUkrL62A5YMLZaFZO3j0PypcHOQYMr8k67LT9GymsstzU2A4bkht/rdj1Yg9I+OCTGBPoiN mpcWhIg6IfVttETNAaPjWbZnoV9p0JF1PXNkftatP3UgsJpaxJmCD5WUle+pG8m9bDyM59F2nmchT oDRNMA1xYDNGwHsPomDoMMDiXqJ+L30m10DMSAx9MD/hhGml5XdOlt6rPRPUuSv5CjVEKsMDrsOYS kreamGmQcxSi6aM/sXUDiQ==; Date: Sun, 29 Oct 2023 13:24:04 +0200 Message-Id: <83r0ldbrjf.fsf@gnu.org> From: Eli Zaretskii To: sbaugh@catern.com In-Reply-To: <871qdot4ry.fsf@catern.com> (sbaugh@catern.com) Subject: Re: bug#66283: 30.0.50; which-function-mode: When configured to display in header, and toggling off, then does not remove header References: <87edif9xqh.fsf@posteo.de> <83lec5slu0.fsf@gnu.org> <871qdot4ry.fsf@catern.com> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 66283-done Cc: mekeor@posteo.de, sbaugh@janestreet.com, 66283-done@debbugs.gnu.org, stefankangas@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: sbaugh@catern.com > Date: Sat, 21 Oct 2023 14:43:30 +0000 (UTC) > Cc: Spencer Baugh , mekeor@posteo.de, > 66283@debbugs.gnu.org, stefankangas@gmail.com > > > Thanks, but how about some tests for these fixes? It's high time > > which-mode had some test suite, I think. > > Sure, here's a patch including a test. Thanks, installed on the master branch, and closing the bug. From unknown Fri Jun 20 18:17:39 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 26 Nov 2023 12:24:08 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator