bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#23444: 25.0.92; activate-mark-hook does not run after a command has


From: Lars Ingebrigtsen
Subject: bug#23444: 25.0.92; activate-mark-hook does not run after a command has changed the region
Date: Sun, 07 Feb 2021 14:30:51 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Nicolas Richard <youngfrog@members.fsf.org> writes:

>> It is also run at the end of a command, if the mark is active and
>> it is possible that the region may have changed.
>
> However, when changing the region, nothing happens. As an example I
> tried evaluating:
>
> (defun foo ()
>   (message "ran: %s" this-command))
> (add-hook 'activate-mark-hook 'foo)
>
> then using C-M-SPC (mark-sexp) correctly showed "ran: mark-sexp", but
> moving the cursor afterwards doesn't produce any more message.

Indeed, and the manual even has this bit, added in 2012:

@defvar activate-mark-hook
@defvarx deactivate-mark-hook
These normal hooks are run, respectively, when the mark becomes active
and when it becomes inactive.  The hook @code{activate-mark-hook} is
also run at the end of the command loop if the mark is active and it
is possible that the region may have changed.
@ignore
This piece of command_loop_1, run unless deactivating the mark:
  if (current_buffer != prev_buffer || MODIFF != prev_modiff)
    {
      Lisp_Object hook = intern ("activate-mark-hook");
      Frun_hooks (1, &hook);
    }
@end ignore

And that code snippet, which is (surprisingly enough), still in Emacs
today, pretty much contradicts what the manual says in the visible text?

That is, the hook is only run if the command changes the buffer, which
then reactivates the mark.  And I can confirm that that's how it's
actually working: If you mark a region in a buffer, switch to a
different buffer, and then back again, the hook is run (after the region
has been activated again).

And that makes sense to me, I think?  Does anybody know whether this is
how it's supposed to work?  If so, the fix would be to alter the
documentation.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





reply via email to

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