[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
c-post-command
From: |
martin rudalics |
Subject: |
c-post-command |
Date: |
Sun, 27 Oct 2024 10:25:07 +0100 |
User-agent: |
Mozilla Thunderbird |
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
- c-post-command,
martin rudalics <=