unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: Nicolas Richard <youngfrog@members.fsf.org>
Cc: 23444@debbugs.gnu.org
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	[thread overview]
Message-ID: <871rds6m44.fsf@gnus.org> (raw)
In-Reply-To: <87y47qowr2.fsf@ulb.ac.be> (Nicolas Richard's message of "Wed, 04 May 2016 14:04:01 +0200")

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





  parent reply	other threads:[~2021-02-07 13:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-04 12:04 bug#23444: 25.0.92; activate-mark-hook does not run after a command has changed the region Nicolas Richard
2016-05-04 16:46 ` Eli Zaretskii
2021-02-07 13:30 ` Lars Ingebrigtsen [this message]
2021-02-07 15:21   ` Eli Zaretskii
2021-02-07 21:01     ` Lars Ingebrigtsen
2021-02-08  6:44       ` Nicolas Richard

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=871rds6m44.fsf@gnus.org \
    --to=larsi@gnus.org \
    --cc=23444@debbugs.gnu.org \
    --cc=youngfrog@members.fsf.org \
    /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).