From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Markus Triska Newsgroups: gmane.emacs.bugs Subject: bug#35177: 27.0.50; Binding deactivate-mark to nil unexpectedly deactivates the mark Date: Sun, 07 Apr 2019 02:11:02 +0200 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="83756"; mail-complaints-to="usenet@blaine.gmane.org" To: 35177@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Apr 07 02:09:14 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hCvN3-000Lfx-Ax for geb-bug-gnu-emacs@m.gmane.org; Sun, 07 Apr 2019 02:09:13 +0200 Original-Received: from localhost ([127.0.0.1]:60434 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hCvN2-0006Wb-8B for geb-bug-gnu-emacs@m.gmane.org; Sat, 06 Apr 2019 20:09:12 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:58841) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hCvMu-0006WK-Am for bug-gnu-emacs@gnu.org; Sat, 06 Apr 2019 20:09:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hCvMt-0007aZ-33 for bug-gnu-emacs@gnu.org; Sat, 06 Apr 2019 20:09:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:34036) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hCvMs-0007aU-TC for bug-gnu-emacs@gnu.org; Sat, 06 Apr 2019 20:09:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hCvMs-0002ZR-Iw for bug-gnu-emacs@gnu.org; Sat, 06 Apr 2019 20:09:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Markus Triska Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 07 Apr 2019 00:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 35177 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.15545956929818 (code B ref -1); Sun, 07 Apr 2019 00:09:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 7 Apr 2019 00:08:12 +0000 Original-Received: from localhost ([127.0.0.1]:47580 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hCvM4-0002YI-BN for submit@debbugs.gnu.org; Sat, 06 Apr 2019 20:08:12 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:44357) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hCvM0-0002Y3-4q for submit@debbugs.gnu.org; Sat, 06 Apr 2019 20:08:10 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:56079) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hCvLu-0007O9-Vx for submit@debbugs.gnu.org; Sat, 06 Apr 2019 20:08:03 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:58734) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hCvLt-0006TI-R0 for bug-gnu-emacs@gnu.org; Sat, 06 Apr 2019 20:08:02 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hCvLs-0007NW-Sz for bug-gnu-emacs@gnu.org; Sat, 06 Apr 2019 20:08:01 -0400 Original-Received: from metalevel.at ([78.46.218.83]:59686) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hCvLs-0007MX-K8 for bug-gnu-emacs@gnu.org; Sat, 06 Apr 2019 20:08:00 -0400 Original-Received: from mts-Mac-mini.localdomain (localhost.localdomain [127.0.0.1]) by metalevel.at (Postfix) with ESMTP id 2A253A01FB for ; Sun, 7 Apr 2019 02:07:57 +0200 (CEST) Original-Received: by mts-Mac-mini.localdomain (Postfix, from userid 501) id 44D14480788; Sun, 7 Apr 2019 02:11:02 +0200 (CEST) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:157292 Archived-At: Please start Emacs with "emacs -Q" and insert the following form in the *scratch* buffer: (progn (let (deactivate-mark) (switch-to-buffer (get-buffer-create "t")) (erase-buffer) (insert "hello")) (let (deactivate-mark) (set-mark-command nil) (move-beginning-of-line nil))) then place point at the end of the form and evaluate it with C-x C-e. You will see a new buffer ("t"), where "hello" is inserted and nothing is highlighted because the mark is inactive. However, I expect the mark to be active and the region highlighted, because the form binds deactivate-mark to nil. This is the way that is recommended in the Elisp manual, see for Example 31.7 "The Mark": To write Lisp code that modifies the buffer without causing deactivation of the mark at the end of the command, bind =E2=80=98deactivate-mark=E2=80=99 to =E2=80=98nil=E2=80=99 around the = code that does the modification. For example: (let (deactivate-mark) (insert " ")) When I remove the second let-binding in the snippet, then the mark is in fact active after the form is evaluated. For example, when I evaluate: (let (deactivate-mark) (switch-to-buffer (get-buffer-create "t")) (erase-buffer) (insert "hello") (set-mark-command nil) (move-beginning-of-line nil)) then "hello" is highlighted. Hence, if I bind deactivate-mark to nil, then the mark is in some cases unexpectedly deactivated. As another test case, here is the first form bound to F4: (global-set-key [f4] (lambda () (interactive) (progn (let (deactivate-mark) (switch-to-buffer (get-buffer-create "t")) (erase-buffer) (insert "hello")) (let (deactivate-mark) (set-mark-command nil) (move-beginning-of-line nil))))) with this binding in place, when I press F4, I also expect "hello" to be highlighted, since this form binds deactivate-mark to nil. However, "hello" is unexpectedly not highlighted when I then press F4. In contrast, when I evaluate the first form with C-M-x, then the region is highlighted. Could you please make C-x C-e and F4 (with this binding in place) give the same result as using C-M-x on the form? Thank you and all the best! Markus In GNU Emacs 27.0.50 (build 1, x86_64-apple-darwin18.0.0, X toolkit, Xaw sc= roll bars) of 2018-11-15 built on mt-computer Repository revision: b4eb908f858284a7962851fd99c94598f76afa6f Windowing system distributor 'The X.Org Foundation', version 11.0.11804000 System Description: Mac OS X 10.14.2