unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: martin rudalics <rudalics@gmx.at>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: c-post-command
Date: Mon, 28 Oct 2024 16:05:07 +0000	[thread overview]
Message-ID: <Zx-2M8bRoJafItkM@MAC.fritz.box> (raw)
In-Reply-To: <0b46e919-da81-4153-b27c-dbd46f5b12f0@gmx.at>

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	other threads:[~2024-10-28 16:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-27  9:25 c-post-command martin rudalics
2024-10-28 16:05 ` Alan Mackenzie [this message]
2024-10-28 16:34   ` c-post-command martin rudalics

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Zx-2M8bRoJafItkM@MAC.fritz.box \
    --to=acm@muc.de \
    --cc=emacs-devel@gnu.org \
    --cc=rudalics@gmx.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).