emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: c-post-command


From: Alan Mackenzie
Subject: Re: c-post-command
Date: Mon, 28 Oct 2024 16:05:07 +0000

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]