mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 10:30:25 -08:00
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): New function. (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: New test.
This commit is contained in:
parent
27ccf2230b
commit
3dca52dd42
2 changed files with 82 additions and 15 deletions
58
test/lisp/progmodes/which-func-tests.el
Normal file
58
test/lisp/progmodes/which-func-tests.el
Normal file
|
|
@ -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 <sbaugh@catern.com>
|
||||
|
||||
;; 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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
;;; 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue