unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* c-post-command
@ 2024-10-27  9:25 martin rudalics
  2024-10-28 16:05 ` c-post-command Alan Mackenzie
  0 siblings, 1 reply; 3+ messages in thread
From: martin rudalics @ 2024-10-27  9:25 UTC (permalink / raw)
  To: emacs-devel; +Cc: Alan Mackenzie

After setting the major mode of a buffer to 'c-mode' and switching to a
buffer in 'text-mode', the value of 'post-command-hook' in that buffer
includes 'c-post-command'.  I suppose this comes from

   (add-hook 'post-command-hook 'c-post-command)

in 'c-basic-common-init' which is removed via

   (remove-hook 'post-command-hook 'c-post-command)

in 'change-major-mode-hook' that calls 'c-leave-cc-mode-mode'.  But such
"removals" happen only when changing the major mode of a buffer and not
when simply switching buffers.  Even if 'c-post-command' returns
immediately when not in a 'c-mode' buffer, it is disconcerting to see
that function in ‘post-command-hook’ when working in some other mode.

Is there any reason not to use

   (add-hook 'post-command-hook 'c-post-command nil t)

in 'c-basic-common-init'?

As an aside, 'c-leave-cc-mode-mode' also does

   (remove-hook 'post-gc-hook 'c-post-gc-hook)))

which I see nowhere added before.

martin

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-10-28 16:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-27  9:25 c-post-command martin rudalics
2024-10-28 16:05 ` c-post-command Alan Mackenzie
2024-10-28 16:34   ` c-post-command martin rudalics

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).