branch: elpa/magit commit 0d8bf92e638ccdc4dedc07fde0637bbf72e295ec Author: Jonas Bernoulli <jo...@bernoul.li> Commit: Jonas Bernoulli <jo...@bernoul.li>
Set tabulated-list-revert-hook using setq-local It is weird that this is a hook. Usually this is a single function, which refreshes the entries in the buffer. But because it is a hook, user could theoretically add additional functions to it, which they wish run at the same time. Since the previous commit, `magit-submodule-list-mode' derives from `magit-repolist-mode', and due to the use of `add-hook' in both mode functions, we ended up installing two refresh buffers, one of which is not appropriate. We could using `remove-hook' and then `add-hook', but it seems cleaner to use `setq-local'. We make t part of the hook's local value, so any functions the user added globally are still run. If a user wants to add additional functions locally, the should probably do that using `magit-submodule-list-mode-hook'. --- lisp/magit-repos.el | 3 ++- lisp/magit-submodule.el | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lisp/magit-repos.el b/lisp/magit-repos.el index 335713aa6b9..682c0ae989a 100644 --- a/lisp/magit-repos.el +++ b/lisp/magit-repos.el @@ -271,7 +271,8 @@ If it contains \"%s\" then the directory is substituted for that." :group 'magit-repolist (setq-local x-stretch-cursor nil) (setq tabulated-list-padding 0) - (add-hook 'tabulated-list-revert-hook #'magit-repolist-refresh nil t) + (setq-local tabulated-list-revert-hook + (list #'magit-repolist-refresh t)) (setq imenu-prev-index-position-function #'magit-repolist--imenu-prev-index-position) (setq imenu-extract-index-name-function #'tabulated-list-get-id)) diff --git a/lisp/magit-submodule.el b/lisp/magit-submodule.el index 0dd0f8140df..5d0ff7a8341 100644 --- a/lisp/magit-submodule.el +++ b/lisp/magit-submodule.el @@ -639,7 +639,8 @@ These sections can be expanded to show the respective commits." "Major mode for browsing a list of Git submodules." :interactive nil :group 'magit-repolist - (add-hook 'tabulated-list-revert-hook #'magit-submodule-list-refresh nil t) + (setq-local tabulated-list-revert-hook + (list #'magit-submodule-list-refresh t)) (setq imenu-prev-index-position-function #'magit-repolist--imenu-prev-index-position) (setq imenu-extract-index-name-function #'tabulated-list-get-id))