unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#23444: 25.0.92; activate-mark-hook does not run after a command has changed the region
@ 2016-05-04 12:04 Nicolas Richard
  2016-05-04 16:46 ` Eli Zaretskii
  2021-02-07 13:30 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 6+ messages in thread
From: Nicolas Richard @ 2016-05-04 12:04 UTC (permalink / raw)
  To: 23444

activate-mark-hook contains the following in its docstring:

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

FWIW this was mentionned in bug#902 (and then promptly forgotten, due to
the main topic being something else in that report).

(side note : in the git repo these docstrings were introduced in commit
0251bafb90e63cc7f428e1b91db436c32ad2677c authored by Richard Stallman.
In the lisp/ChangeLog.12 the author of those lines is said to be Chong
Yidong. I guess I will pretend I did not see this.)

In GNU Emacs 25.0.92.1 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2016-03-04 built on localhost
Repository revision: 620951fe22a6ecc2edc1f78d961f52566a7fe2b6
Windowing system distributor 'The X.Org Foundation', version 11.0.11604000
System Description:	Gentoo Base System release 2.2

Configured using:
 'configure --with-x-toolkit=lucid 'CFLAGS= ''

-- 
Nicolas Richard





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#23444: 25.0.92; activate-mark-hook does not run after a command has changed the region
  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
  1 sibling, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2016-05-04 16:46 UTC (permalink / raw)
  To: Nicolas Richard; +Cc: 23444

> From: Nicolas Richard <youngfrog@members.fsf.org>
> Date: Wed, 04 May 2016 14:04:01 +0200
> 
> (side note : in the git repo these docstrings were introduced in commit
> 0251bafb90e63cc7f428e1b91db436c32ad2677c authored by Richard Stallman.
> In the lisp/ChangeLog.12 the author of those lines is said to be Chong
> Yidong. I guess I will pretend I did not see this.)

You don't need to pretend.  I'm quite sure Chong wrote the code and
Richard just committed the change, for some reason.  CVS doesn't have
the equivalent of the --author switch to the 'commit' command, so you
will see a lot of similar cases in old commits.  E.g., all of my
commits were done by Richard or others at first, until I got write
access several years later.

There's nothing funky here.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#23444: 25.0.92; activate-mark-hook does not run after a command has changed the region
  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
  2021-02-07 15:21   ` Eli Zaretskii
  1 sibling, 1 reply; 6+ messages in thread
From: Lars Ingebrigtsen @ 2021-02-07 13:30 UTC (permalink / raw)
  To: Nicolas Richard; +Cc: 23444

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





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#23444: 25.0.92; activate-mark-hook does not run after a command has changed the region
  2021-02-07 13:30 ` Lars Ingebrigtsen
@ 2021-02-07 15:21   ` Eli Zaretskii
  2021-02-07 21:01     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2021-02-07 15:21 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 23444, youngfrog

> From: Lars Ingebrigtsen <larsi@gnus.org>
> Date: Sun, 07 Feb 2021 14:30:51 +0100
> Cc: 23444@debbugs.gnu.org
> 
> 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.

Yes, I think the manual actually intended to describe what the
implementation does, but failed to be accurate enough.  So it needs to
be fixed.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#23444: 25.0.92; activate-mark-hook does not run after a command has changed the region
  2021-02-07 15:21   ` Eli Zaretskii
@ 2021-02-07 21:01     ` Lars Ingebrigtsen
  2021-02-08  6:44       ` Nicolas Richard
  0 siblings, 1 reply; 6+ messages in thread
From: Lars Ingebrigtsen @ 2021-02-07 21:01 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 23444, youngfrog

Eli Zaretskii <eliz@gnu.org> writes:

> Yes, I think the manual actually intended to describe what the
> implementation does, but failed to be accurate enough.  So it needs to
> be fixed.

I've now made an attempt in emacs-27.

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





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#23444: 25.0.92; activate-mark-hook does not run after a command has changed the region
  2021-02-07 21:01     ` Lars Ingebrigtsen
@ 2021-02-08  6:44       ` Nicolas Richard
  0 siblings, 0 replies; 6+ messages in thread
From: Nicolas Richard @ 2021-02-08  6:44 UTC (permalink / raw)
  To: Lars Ingebrigtsen, Eli Zaretskii; +Cc: 23444

[-- Attachment #1: Type: text/html, Size: 518 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-02-08  6:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2021-02-07 15:21   ` Eli Zaretskii
2021-02-07 21:01     ` Lars Ingebrigtsen
2021-02-08  6:44       ` Nicolas Richard

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