From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs 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 Message-ID: <871rds6m44.fsf@gnus.org> References: <87y47qowr2.fsf@ulb.ac.be> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40011"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 23444@debbugs.gnu.org To: Nicolas Richard Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Feb 07 14:33:02 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l8kBS-000AHK-JG for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 07 Feb 2021 14:33:02 +0100 Original-Received: from localhost ([::1]:58932 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l8kBR-0005sT-KQ for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 07 Feb 2021 08:33:01 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34640) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l8kAU-0005Uy-GV for bug-gnu-emacs@gnu.org; Sun, 07 Feb 2021 08:32:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:35535) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l8kAU-0001at-9k for bug-gnu-emacs@gnu.org; Sun, 07 Feb 2021 08:32:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l8kAU-0000JX-4o for bug-gnu-emacs@gnu.org; Sun, 07 Feb 2021 08:32:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 07 Feb 2021 13:32:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23444 X-GNU-PR-Package: emacs Original-Received: via spool by 23444-submit@debbugs.gnu.org id=B23444.16127046651117 (code B ref 23444); Sun, 07 Feb 2021 13:32:02 +0000 Original-Received: (at 23444) by debbugs.gnu.org; 7 Feb 2021 13:31:05 +0000 Original-Received: from localhost ([127.0.0.1]:47078 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8k9Z-0000Hw-2X for submit@debbugs.gnu.org; Sun, 07 Feb 2021 08:31:05 -0500 Original-Received: from quimby.gnus.org ([95.216.78.240]:35318) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8k9X-0000HR-DL for 23444@debbugs.gnu.org; Sun, 07 Feb 2021 08:31:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=t110R5OIc0h+iBIRE/OETzdofyfnQmrkd/e1kXn4rEU=; b=kBL7TlM1VmymXKOaGwbGLKb/cn LB1b0Xamfhgqcl8ggS7HSVmCEqh2L87hGU8RFiS+qjIi2Ro1H4PeRMWIvtiDcNT3Gv/g6wKZcRbND E5fdSWMNpV2ZD1B41/WPnJHo61Oiytvr05M4io4AAq6rFQ7mHkS15CttxjKE2KU9wqDA=; Original-Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l8k9N-0000fw-51; Sun, 07 Feb 2021 14:30:56 +0100 X-Now-Playing: James White and the Blacks's _Off White_: "White Devil" In-Reply-To: <87y47qowr2.fsf@ulb.ac.be> (Nicolas Richard's message of "Wed, 04 May 2016 14:04:01 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:199484 Archived-At: Nicolas Richard 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