all messages for Emacs-related lists mirrored at yhetil.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

* Re: c-post-command
  2024-10-27  9:25 c-post-command martin rudalics
@ 2024-10-28 16:05 ` Alan Mackenzie
  2024-10-28 16:34   ` c-post-command martin rudalics
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Mackenzie @ 2024-10-28 16:05 UTC (permalink / raw)
  To: martin rudalics; +Cc: emacs-devel

Hello, Martin.

On Sun, Oct 27, 2024 at 10:25:07 +0100, martin rudalics wrote:
> 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)

Yes.

> 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)

No reason at all!  I don't know why I didn't do that when I introduced
c-post-command.

> 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.

How did you spot that?  :-)  c-post-gc-hook existed for a short while
back in 2021, but I obviously failed to remove it properly.

I've now fixed all these things, and committed the fix to the Emacs
master branch.

Thanks!

> martin

-- 
Alan Mackenzie (Nuremberg, Germany).



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

* Re: c-post-command
  2024-10-28 16:05 ` c-post-command Alan Mackenzie
@ 2024-10-28 16:34   ` martin rudalics
  0 siblings, 0 replies; 3+ messages in thread
From: martin rudalics @ 2024-10-28 16:34 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: emacs-devel

 > I've now fixed all these things, and committed the fix to the Emacs
 > master branch.

Thank you, 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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.