Disable which-func-mode in erc-imenu buffers
* lisp/erc/erc-imenu.el (erc-imenu-setup): Move after module definition so the variable `erc-imenu-mode' is defined. Run teardown code when module is deactivated. Set `which-func-mode' to nil locally. (erc-imenu-mode, erc-imenu-enable, erc-imenu-disable): Manage membership of `erc-imenu--disable-which-func' in `which-function-mode-hook'. (erc-imenu--disable-which-func): New function. (Bug#74934)
This commit is contained in:
parent
2d173aa3d3
commit
d1c670f0cb
1 changed files with 24 additions and 11 deletions
|
@ -132,23 +132,36 @@ Don't rely on this function, read it first!"
|
|||
(defvar-local erc-imenu--create-index-function nil
|
||||
"Previous local value of `imenu-create-index-function', if any.")
|
||||
|
||||
(defun erc-imenu-setup ()
|
||||
"Wire up support for Imenu in an ERC buffer."
|
||||
(when (and (local-variable-p 'imenu-create-index-function)
|
||||
imenu-create-index-function)
|
||||
(setq erc-imenu--create-index-function imenu-create-index-function))
|
||||
(setq imenu-create-index-function #'erc-create-imenu-index))
|
||||
|
||||
;;;###autoload(autoload 'erc-imenu-mode "erc-imenu" nil t)
|
||||
(define-erc-module imenu nil
|
||||
"Simple Imenu integration for ERC."
|
||||
((add-hook 'erc-mode-hook #'erc-imenu-setup)
|
||||
(add-hook 'which-function-mode-hook #'erc-imenu--disable-which-func)
|
||||
(unless erc--updating-modules-p (erc-buffer-do #'erc-imenu-setup)))
|
||||
((remove-hook 'erc-mode-hook #'erc-imenu-setup)
|
||||
(erc-with-all-buffers-of-server nil nil
|
||||
(when erc-imenu--create-index-function
|
||||
(setq imenu-create-index-function erc-imenu--create-index-function)
|
||||
(kill-local-variable 'erc-imenu--create-index-function)))))
|
||||
(remove-hook 'which-function-mode-hook #'erc-imenu--disable-which-func)
|
||||
(erc-buffer-do #'erc-imenu-setup)))
|
||||
|
||||
(defun erc-imenu-setup ()
|
||||
"Set up or tear down Imenu integration."
|
||||
(if erc-imenu-mode
|
||||
(progn
|
||||
(when (and (local-variable-p 'imenu-create-index-function)
|
||||
imenu-create-index-function)
|
||||
(setq erc-imenu--create-index-function imenu-create-index-function))
|
||||
(setq imenu-create-index-function #'erc-create-imenu-index)
|
||||
(when (boundp 'which-func-mode)
|
||||
(setq which-func-mode nil)))
|
||||
(when erc-imenu--create-index-function
|
||||
(setq imenu-create-index-function erc-imenu--create-index-function))
|
||||
(kill-local-variable 'erc-imenu--create-index-function)
|
||||
(kill-local-variable 'which-func-mode)))
|
||||
|
||||
(defun erc-imenu--disable-which-func ()
|
||||
"Silence `which-function-mode' in ERC buffers."
|
||||
(defvar which-func-mode)
|
||||
(erc-with-all-buffers-of-server nil nil
|
||||
(setq which-func-mode nil)))
|
||||
|
||||
(provide 'erc-imenu)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue