GNU bug report logs -
#77224
[PATCH] New minor mode 'cursor-indicators-mode'
Previous Next
Full log
Message #158 received at 77224 <at> debbugs.gnu.org (full text, mbox):
> How long is the post-command-hook list in your production sessions?
> Should we poll users to give their data? Just yesterday someone
> complained on Reddit that Emacs is too slow, and I have no doubt that
> features that use post-command-hook are at least part of the reason if
> not _the_ reason.
Here is my post-command-hook in an Org mode buffer in Emacs 29:
(yas--post-command-handler
org-latex-preview-auto--handle-post-cursor
visible-mark-move-overlays
dot-mode-loop
corfu--auto-post-command
t)
That's the buffer-local value. In addition, the global value is:
(global-font-lock-mode-check-buffers
global-eldoc-mode-check-buffers
global-prettify-symbols-mode-check-buffers
magit-auto-revert-mode-check-buffers
c-post-command
repeat-post-hook
mode-local-post-major-mode-change)
-----
And here are the minor modes I'm using that are installing these hooks.
Modes from packages I've installed explicitly:
- org-latex-preview-auto-mode: Detects and previews LaTeX fragments in
Org buffers as they are typed. (I authored this mode, it is designed
to be as nonintrusive as possible.)
- yas-minor-mode: for Yasnippets (template expansion)
- visible-mark-mode: Highlights the position of the usually invisible
mark.
- dot-mode: Vim-style repeat operator for text insertion.
- corfu-mode: Autocompletion as you type.
The following modes are from built-in Emacs packages:
- font-lock-mode
- global-eldoc-mode
- global-prettify-symbols-mode
- repeat-mode
Of the remaining, I use Magit with its default settings, under which it
installs `magit-auto-revert-mode-check-buffers'.
I don't know why `c-post-command' is in the global post-command-hook. I
haven't even edited any C files in this Emacs session.
I don't know why `mode-local-post-major-mode-change' is installed either.
------
Although my Emacs isn't so slow that I can't type comfortably, I can
definitely perceive some difference between Emacs' responsiveness with the
above settings and `emacs -q'.
I would very much like some of these to be moved into different hooks
that trigger only when required. Daniel's idea for something like this:
(call-on-change (:buffer :window :focus) #'my-thing)
would be very useful.
> So I maintain that we should try to avoid post-command-hook for
> operations that should happen very rarely (this case is one such case:
> we only want to run this code when something is turned on or off).
> Even if the reaction to the change is a bit slower, it is worth our
> while to pay that price: users will be a tad happier with Emacs
> response times. And if there are alternative methods of doing the
> same, like the respective mode hooks in this case, we should use them
> without thinking twice. Ideally, post-command-hook should only be
> used for stuff that really must be done after almost every command;
> for any other cases we should look for other Emacs features to do the
> job.
For this reason I try quite hard to avoid using post-command-hook in my
packages.
Karthik
This bug report was last modified 64 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.