GNU bug report logs - #35177
27.0.50; Binding deactivate-mark to nil unexpectedly deactivates the mark

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Markus Triska <triska@HIDDEN>; dated Sun, 7 Apr 2019 00:09:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 35177 <at> debbugs.gnu.org:


Received: (at 35177) by debbugs.gnu.org; 9 Apr 2019 23:46:40 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Apr 09 19:46:40 2019
Received: from localhost ([127.0.0.1]:52160 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hE0Rr-0004o4-Ua
	for submit <at> debbugs.gnu.org; Tue, 09 Apr 2019 19:46:40 -0400
Received: from mail-qt1-f169.google.com ([209.85.160.169]:38115)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <npostavs@HIDDEN>) id 1hE0Rq-0004nq-GE
 for 35177 <at> debbugs.gnu.org; Tue, 09 Apr 2019 19:46:38 -0400
Received: by mail-qt1-f169.google.com with SMTP id d13so811596qth.5
 for <35177 <at> debbugs.gnu.org>; Tue, 09 Apr 2019 16:46:38 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=from:to:cc:subject:references:date:in-reply-to:message-id
 :user-agent:mime-version:content-transfer-encoding;
 bh=KR8uR/k9CCNKtaZSam4s3KqIFg6TFFhzSfFL8L/CmAc=;
 b=dV6xWvLPWagf2mNulXvy9NOmJzOCp5v5A9DWGgO+UmwWB/7fmTr0lr17f5XZGge7Y2
 9rkIyk62GVvrBV7DJ/aEF3SWc87/ZDF4WfvUtaZZ1jNCQb6EA1dEWPhc99OAqfVR24pE
 Ii+niaXLmlcmR6+TsELxQSeBvti8Y3FbjKM1R2nscMELhKUfIJ5uXC+ggIBjNOakjUuc
 tZvfucA3aWwo5HFRkHa/p/zAkEyk8dpbcymbJiOGHnfIIU4V7e1ktSGfCyphO8ipIc+2
 TgXFY8KVshKl6EW25LKOtNSdN/MIdij6ptZh2jx285vezaPZtOvd95eEEHnkeyMbDPJY
 2qNA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to
 :message-id:user-agent:mime-version:content-transfer-encoding;
 bh=KR8uR/k9CCNKtaZSam4s3KqIFg6TFFhzSfFL8L/CmAc=;
 b=r8YQkoUUNTZ7XYCPEAGGvL1F1ZiIPk8AetcDCLNzzYs87DS/akMIodiqzU9ub7lA71
 UP4VXotTCZnQDMNjVDAlKZ1CgNWVQ93kjUsyPnEeb+7A7x6XsEMCapwhmPt48j6vPe2Z
 YaZFFBDPtmZM++Aallk69UbVkjYpmA5QKjBKLYr0d1ifycOPA6cYiMOOM2GB4i7mTXY/
 cqZ8ESkpbP9lzw50m3Zx4JH0Y9CzO5hpOVFlrHYtT1klKMa3UcFIJzebF7Gg293/V/dZ
 nenMUmTfwMGR9hY7AgQeZR1ynEJdw6Wt2u62opNAFAYLBherk0X74hXOaFcQnf9Msykd
 V+Fg==
X-Gm-Message-State: APjAAAVHpbbAWVo8xV7rAwwbFENkzMG2PYbXH+3IJOCHfNXIcyNTaKV4
 bpDZ5qEygF3Y1g0sn7zy1go=
X-Google-Smtp-Source: APXvYqzrmcaQ+zErVySlkEddnmTrMjwSnCfhmInXJZ2eSTpkGn5p5HpIIUj+/WY+zB6xgKtkTKKyiA==
X-Received: by 2002:ac8:2ecf:: with SMTP id i15mr34619681qta.314.1554853592814; 
 Tue, 09 Apr 2019 16:46:32 -0700 (PDT)
Received: from minid (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34])
 by smtp.googlemail.com with ESMTPSA id
 194sm13609663qkd.72.2019.04.09.16.46.30
 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);
 Tue, 09 Apr 2019 16:46:31 -0700 (PDT)
From: Noam Postavsky <npostavs@HIDDEN>
To: Markus Triska <triska@HIDDEN>
Subject: Re: bug#35177: 27.0.50;
 Binding deactivate-mark to nil unexpectedly deactivates the mark
References: <m2tvfa3ca1.fsf@HIDDEN> <831s2dakjz.fsf@HIDDEN>
 <877ec5wid3.fsf@HIDDEN> <83d0lx8bsb.fsf@HIDDEN>
 <87mul0rezk.fsf@HIDDEN> <838swk8rfr.fsf@HIDDEN>
 <87o95gfqdp.fsf@HIDDEN> <87a7h0cadq.fsf@HIDDEN>
 <87ftqrtd18.fsf@HIDDEN>
Date: Tue, 09 Apr 2019 19:46:30 -0400
In-Reply-To: <87ftqrtd18.fsf@HIDDEN> (Markus Triska's message of "Tue,
 09 Apr 2019 17:26:59 +0200")
Message-ID: <87o95ebv3d.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1.91 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 35177
Cc: 35177 <at> debbugs.gnu.org, Eli Zaretskii <eliz@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Markus Triska <triska@HIDDEN> writes:

> 3. In that Emacs instance, please do:
>
>    M-x evaluate-buffer RET M-x mark-test-run RET
>
>    After this, "hello" is displayed and the mark is active.

> Can you reproduce this?

Sort of.  There is some interaction with the suggest-key-bindings
feature.  On the first run, the mark stays active until the message with
the suggestion goes away, and only then gets deactivated.

    You can run the command =E2=80=98mark-test-run=E2=80=99 with M-x ma-t R=
ET

If set suggest-key-bindings to nil, or type in exactly M-x ma-t RET,
then the mark is deactivated the first time too.

> This seems related to the current issue. However, if you consider this
> unrelated, please let me know, and I will file this as a separate issue.

Yeah, I think it's the same issue.  If I include (setq
suggest-key-bindings nil) and (make-local-variable 'deactivate-mark)
then the mark stays active consistently.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#35177; Package emacs. Full text available.

Message received at 35177 <at> debbugs.gnu.org:


Received: (at 35177) by debbugs.gnu.org; 9 Apr 2019 15:27:02 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Apr 09 11:27:02 2019
Received: from localhost ([127.0.0.1]:51884 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hDseM-0004hP-Ge
	for submit <at> debbugs.gnu.org; Tue, 09 Apr 2019 11:27:02 -0400
Received: from metalevel.at ([78.46.218.83]:53258)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <triska@HIDDEN>) id 1hDseK-0004gv-EX
 for 35177 <at> debbugs.gnu.org; Tue, 09 Apr 2019 11:27:01 -0400
Received: by metalevel.at (Postfix, from userid 1000)
 id 0D3D7A2AD1; Tue,  9 Apr 2019 17:26:59 +0200 (CEST)
From: Markus Triska <triska@HIDDEN>
To: Noam Postavsky <npostavs@HIDDEN>
Subject: Re: bug#35177: 27.0.50;
 Binding deactivate-mark to nil unexpectedly deactivates the mark
References: <m2tvfa3ca1.fsf@HIDDEN> <831s2dakjz.fsf@HIDDEN>
 <877ec5wid3.fsf@HIDDEN> <83d0lx8bsb.fsf@HIDDEN>
 <87mul0rezk.fsf@HIDDEN> <838swk8rfr.fsf@HIDDEN>
 <87o95gfqdp.fsf@HIDDEN> <87a7h0cadq.fsf@HIDDEN>
Date: Tue, 09 Apr 2019 17:26:59 +0200
In-Reply-To: <87a7h0cadq.fsf@HIDDEN> (Noam Postavsky's message of "Mon, 08
 Apr 2019 20:04:01 -0400")
Message-ID: <87ftqrtd18.fsf@HIDDEN>
User-Agent: Emacs/24.5
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 35177
Cc: 35177 <at> debbugs.gnu.org, Eli Zaretskii <eliz@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Noam Postavsky <npostavs@HIDDEN> writes:

> I think the key detail is whether deactivate-mark has a buffer-local
> value or not (modifying the buffer gives it one).  If it does have a
> buffer-local value, then the let-binding affects just the buffer-local
> one, otherwise, it binds the global value.  So C-x C-e on the following
> always gives an active mark:

Thank you very much for looking into this!

I have constructed an additional test case, which in a sense complements
the previous one in that the mark is now active on the first run, but
inactive in subsequent runs. To reproduce it, please do the following:

1. Download mark_test_run.el with:
   $ wget https://www.metalevel.at/ei/mark_test_run.el

2. Invoke Emacs with:
   $ emacs -Q mark_test_run.el

3. In that Emacs instance, please do:

   M-x evaluate-buffer RET M-x mark-test-run RET

   After this, "hello" is displayed and the mark is active.

4. Kill the current buffer (i.e., "b") with C-x k RET

5. Invoke mark-test-run again with M-x mark-test-run RET

   After this, "hello" is displayed and the mark is *inactive*.

On subsequent invocations of mark-test-run, the mark is likewise
inactive. However, I expect the mark to be active in all runs, due to
the structure of mark-test-run, which binds deactivate-mark to nil:

    (defun mark-test-run ()
      (interactive)
      (let (deactivate-mark)
	...))

Can you reproduce this?

This seems related to the current issue. However, if you consider this
unrelated, please let me know, and I will file this as a separate issue.

For completeness, I include the content of mark_test_run.el below.

All the best,
Markus


(defvar mark-test-forms
  '((new-buffer "b")
    (insert "hello")
    (set-mark-command)
    (move-beginning-of-line)))

(defun mark-test-run ()
  (interactive)
  (let (deactivate-mark)
    (mapc 'mark-test-interpret mark-test-forms)))


(defun mark-test-interpret (expr)
  (interactive)
  (let ((e (car expr)))
    (cond ((eq e 'insert)
           (insert (cadr expr)))
          ((eq e 'move-beginning-of-line)
           (move-beginning-of-line nil))
          ((eq e 'new-buffer)
           (let ((buf (get-buffer-create (cadr expr))))
             (with-current-buffer buf
               (erase-buffer))
             (switch-to-buffer buf)))
          ((eq e 'set-mark-command)
           (let ((inhibit-message t))
             (set-mark-command nil))))))




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#35177; Package emacs. Full text available.

Message received at 35177 <at> debbugs.gnu.org:


Received: (at 35177) by debbugs.gnu.org; 9 Apr 2019 00:04:13 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Apr 08 20:04:13 2019
Received: from localhost ([127.0.0.1]:50345 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hDeFI-0008Qt-R7
	for submit <at> debbugs.gnu.org; Mon, 08 Apr 2019 20:04:13 -0400
Received: from mail-qt1-f170.google.com ([209.85.160.170]:40382)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <npostavs@HIDDEN>) id 1hDeFG-0008QX-9X
 for 35177 <at> debbugs.gnu.org; Mon, 08 Apr 2019 20:04:11 -0400
Received: by mail-qt1-f170.google.com with SMTP id x12so17709177qts.7
 for <35177 <at> debbugs.gnu.org>; Mon, 08 Apr 2019 17:04:10 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=from:to:cc:subject:references:date:in-reply-to:message-id
 :user-agent:mime-version;
 bh=Pkb70KNd/Hm090DoM+d4885tCQoiPBY5EMDdlT0uz9Y=;
 b=beDGxgLR2VT10n/AmH7zqqPP/g1/3u2xOfMDIrWwhi83isfT8RDMWTqFT+AS7cx5ZA
 3SNQwAmqPOZxkNQy5ahrdTpFsS6Bni9bfAfFUZGdhs0WZvL1wXpOCivWSCvvj7k+Kpw6
 fpWmCJniGfIh0IfD2dmAd3QBOQFf5Q+pvSm8guz1rRBah2DaS5owH89Jec2lJeWNNfes
 9ChP8GJAcnbbELOxRom0mCb0YFqo7xtpxt7RJzU88az1H/QKQdoswk1Rm7oT+0XzdnTK
 ZUzilA7byGq1Wu8PRYjqaoagwKrGztDtMpeSyp/5haCFFQ2m322rMe03ujJXRR37ZKiM
 qrFg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to
 :message-id:user-agent:mime-version;
 bh=Pkb70KNd/Hm090DoM+d4885tCQoiPBY5EMDdlT0uz9Y=;
 b=czrebhUUDqiBoonuCFZp+ratGv7I5hneMsTu6DwqQrnYKP56AjiXn7VYxoXLZJ1lVi
 JHjC7uqas/UOYgf7zt0V7YOMskaaHaSN005LnwS/XoLibc0TA4LdCKort2+uaQQYgrwn
 fv/TbFEeC1/J8KL4yU26jVj8rBxIkZ0UffvU4NTNXfLMiXWFxgacAL0l61SFgRP8S9Jd
 S7c5ShB5x3nuiqOVbKnxJ/1UGARTW/EssiFz6h20SKjRrzhYN6LfMp6lvWgB0MjHVotk
 E5/qRZ1pQHipFF5UhLC9Kv2CqZYCqvZ4Q9v7QP7KMtndU7GLYF7PU8YC0xoOEmAJ+aRl
 Jcpw==
X-Gm-Message-State: APjAAAUhcxTgd+iOqtowV9J/fFskBFujT8hggqqkrMIXEIOBUpkpiCaA
 R8mN2PnyHp2+KBDz5i0dgnwd0FIC
X-Google-Smtp-Source: APXvYqxHyb8ICEQghsPNjtkphQsKLTskdSgT/yX/uGhdptCNCrUBUJMCv2ItdQ6yXzN5lD781+dL3Q==
X-Received: by 2002:a0c:9637:: with SMTP id 52mr26473292qvx.11.1554768243599; 
 Mon, 08 Apr 2019 17:04:03 -0700 (PDT)
Received: from minid (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34])
 by smtp.googlemail.com with ESMTPSA id
 f47sm22429973qta.80.2019.04.08.17.04.02
 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);
 Mon, 08 Apr 2019 17:04:02 -0700 (PDT)
From: Noam Postavsky <npostavs@HIDDEN>
To: Markus Triska <triska@HIDDEN>
Subject: Re: bug#35177: 27.0.50;
 Binding deactivate-mark to nil unexpectedly deactivates the mark
References: <m2tvfa3ca1.fsf@HIDDEN> <831s2dakjz.fsf@HIDDEN>
 <877ec5wid3.fsf@HIDDEN> <83d0lx8bsb.fsf@HIDDEN>
 <87mul0rezk.fsf@HIDDEN> <838swk8rfr.fsf@HIDDEN>
 <87o95gfqdp.fsf@HIDDEN>
Date: Mon, 08 Apr 2019 20:04:01 -0400
In-Reply-To: <87o95gfqdp.fsf@HIDDEN> (Markus Triska's message of "Mon,
 08 Apr 2019 17:50:10 +0200")
Message-ID: <87a7h0cadq.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1.91 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 35177
Cc: 35177 <at> debbugs.gnu.org, Eli Zaretskii <eliz@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Markus Triska <triska@HIDDEN> writes:

> (let (deactivate-mark)
>   (switch-to-buffer (get-buffer-create "t"))
>   (insert "hello")
>   (set-mark-command nil)
>   (move-beginning-of-line nil))
>
> It seems to play a role whether its buffer is modified or not, hence
> this receipe starting from a fresh file and an unmodified buffer.

I think the key detail is whether deactivate-mark has a buffer-local
value or not (modifying the buffer gives it one).  If it does have a
buffer-local value, then the let-binding affects just the buffer-local
one, otherwise, it binds the global value.  So C-x C-e on the following
always gives an active mark:

(progn
  (make-local-variable 'deactivate-mark)
  ;; (kill-local-variable 'deactivate-mark)
  (let (deactivate-mark)
    (switch-to-buffer (get-buffer-create "t"))
    (insert "hello")
    (set-mark-command nil)
    (move-beginning-of-line nil)))

And if you uncomment the kill-local-variable statement, then C-x C-e
will never give an active mark.

C-M-x and M-x eval-region still do give an active mark for all variants.
I'm not entirely sure why, but I'm guessing it's because they juggle
buffers in a slightly different way, such that the command loop ends up
consulting the value of deactivate-mark from somewhere else.





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#35177; Package emacs. Full text available.

Message received at 35177 <at> debbugs.gnu.org:


Received: (at 35177) by debbugs.gnu.org; 8 Apr 2019 16:01:03 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Apr 08 12:01:03 2019
Received: from localhost ([127.0.0.1]:50135 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hDWhi-00051F-FY
	for submit <at> debbugs.gnu.org; Mon, 08 Apr 2019 12:01:03 -0400
Received: from eggs.gnu.org ([209.51.188.92]:36945)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1hDWhg-00050f-Bu
 for 35177 <at> debbugs.gnu.org; Mon, 08 Apr 2019 12:01:01 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:49011)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <eliz@HIDDEN>)
 id 1hDWha-0004wP-Kb; Mon, 08 Apr 2019 12:00:54 -0400
Received: from [176.228.60.248] (port=3405 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1hDWhZ-0002n3-Cb; Mon, 08 Apr 2019 12:00:53 -0400
Date: Mon, 08 Apr 2019 19:00:47 +0300
Message-Id: <835zro8p1s.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Markus Triska <triska@HIDDEN>
In-reply-to: <87o95gfqdp.fsf@HIDDEN> (message from Markus Triska on Mon, 
 08 Apr 2019 17:50:10 +0200)
Subject: Re: bug#35177: 27.0.50;
 Binding deactivate-mark to nil unexpectedly deactivates the mark
References: <m2tvfa3ca1.fsf@HIDDEN> <831s2dakjz.fsf@HIDDEN>
 <877ec5wid3.fsf@HIDDEN> <83d0lx8bsb.fsf@HIDDEN>
 <87mul0rezk.fsf@HIDDEN> <838swk8rfr.fsf@HIDDEN>
 <87o95gfqdp.fsf@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 35177
Cc: 35177 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

> From: Markus Triska <triska@HIDDEN>
> Cc: 35177 <at> debbugs.gnu.org
> Date: Mon, 08 Apr 2019 17:50:10 +0200
> 
> Eli Zaretskii <eliz@HIDDEN> writes:
> 
> > I cannot reproduce your result: the above does show an active mark
> > after the execution, both in Emacs 26.2 and Emacs 27.0.50.
> 
> Here is a more complete recipe, could you please try it:
> 
>   1. download deactivate_mark.el with
>      $ wget https://www.metalevel.at/ei/deactivate_mark.el
> 
>   2. start Emacs with
>      $ emacs -Q deactivate_mark.el
> 
>   3. move point at the end of the form and evaluate it with C-x C-e.
> 
> The result is that "hello" is displayed in buffer "t", and the mark is
> not active. The content of deactivate_mark.el is:
> 
> (let (deactivate-mark)
>   (switch-to-buffer (get-buffer-create "t"))
>   (insert "hello")
>   (set-mark-command nil)
>   (move-beginning-of-line nil))
> 
> It seems to play a role whether its buffer is modified or not, hence
> this receipe starting from a fresh file and an unmodified buffer.
> 
> Can you reproduce this up to here? If so, please proceed as follows:
> 
>   4. Kill the "t" buffer with C-x C-k RET
> 
>   5. Add a space to the end of deactivate_mark.el by pressing SPACE.
> 
>   6. Evaluate the form again with C-x C-e.
> 
> After these steps, "hello" is highlighted and the mark is active. Also,
> on all further iterations of (4) to (6), the region is again active.
> 
> Can you reproduce this?

Yes.

> If possible, could you please make it so that the mark is active
> also on the first run, i.e., after steps (1) to (3)?

Not sure.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#35177; Package emacs. Full text available.

Message received at 35177 <at> debbugs.gnu.org:


Received: (at 35177) by debbugs.gnu.org; 8 Apr 2019 15:50:14 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Apr 08 11:50:14 2019
Received: from localhost ([127.0.0.1]:50131 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hDWXG-0004js-Dx
	for submit <at> debbugs.gnu.org; Mon, 08 Apr 2019 11:50:14 -0400
Received: from metalevel.at ([78.46.218.83]:59888)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <triska@HIDDEN>) id 1hDWXD-0004jj-Rb
 for 35177 <at> debbugs.gnu.org; Mon, 08 Apr 2019 11:50:13 -0400
Received: by metalevel.at (Postfix, from userid 1000)
 id 6A42CA2A8E; Mon,  8 Apr 2019 17:50:10 +0200 (CEST)
From: Markus Triska <triska@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#35177: 27.0.50;
 Binding deactivate-mark to nil unexpectedly deactivates the mark
References: <m2tvfa3ca1.fsf@HIDDEN> <831s2dakjz.fsf@HIDDEN>
 <877ec5wid3.fsf@HIDDEN> <83d0lx8bsb.fsf@HIDDEN>
 <87mul0rezk.fsf@HIDDEN> <838swk8rfr.fsf@HIDDEN>
Date: Mon, 08 Apr 2019 17:50:10 +0200
In-Reply-To: <838swk8rfr.fsf@HIDDEN> (Eli Zaretskii's message of "Mon, 08 Apr
 2019 18:09:12 +0300")
Message-ID: <87o95gfqdp.fsf@HIDDEN>
User-Agent: Emacs/24.5
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 35177
Cc: 35177 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Eli Zaretskii <eliz@HIDDEN> writes:

> I cannot reproduce your result: the above does show an active mark
> after the execution, both in Emacs 26.2 and Emacs 27.0.50.

Here is a more complete recipe, could you please try it:

  1. download deactivate_mark.el with
     $ wget https://www.metalevel.at/ei/deactivate_mark.el

  2. start Emacs with
     $ emacs -Q deactivate_mark.el

  3. move point at the end of the form and evaluate it with C-x C-e.

The result is that "hello" is displayed in buffer "t", and the mark is
not active. The content of deactivate_mark.el is:

(let (deactivate-mark)
  (switch-to-buffer (get-buffer-create "t"))
  (insert "hello")
  (set-mark-command nil)
  (move-beginning-of-line nil))

It seems to play a role whether its buffer is modified or not, hence
this receipe starting from a fresh file and an unmodified buffer.

Can you reproduce this up to here? If so, please proceed as follows:

  4. Kill the "t" buffer with C-x C-k RET

  5. Add a space to the end of deactivate_mark.el by pressing SPACE.

  6. Evaluate the form again with C-x C-e.

After these steps, "hello" is highlighted and the mark is active. Also,
on all further iterations of (4) to (6), the region is again active.

Can you reproduce this? If possible, could you please make it so that
the mark is active also on the first run, i.e., after steps (1) to (3)?

Thank you and all the best,
Markus




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#35177; Package emacs. Full text available.

Message received at 35177 <at> debbugs.gnu.org:


Received: (at 35177) by debbugs.gnu.org; 8 Apr 2019 15:09:24 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Apr 08 11:09:24 2019
Received: from localhost ([127.0.0.1]:50105 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hDVtj-0003kC-V9
	for submit <at> debbugs.gnu.org; Mon, 08 Apr 2019 11:09:24 -0400
Received: from eggs.gnu.org ([209.51.188.92]:51674)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1hDVti-0003k0-V2
 for 35177 <at> debbugs.gnu.org; Mon, 08 Apr 2019 11:09:23 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:48055)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <eliz@HIDDEN>)
 id 1hDVtd-00015w-AJ; Mon, 08 Apr 2019 11:09:17 -0400
Received: from [176.228.60.248] (port=4208 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1hDVtc-0008FV-Po; Mon, 08 Apr 2019 11:09:17 -0400
Date: Mon, 08 Apr 2019 18:09:12 +0300
Message-Id: <838swk8rfr.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Markus Triska <triska@HIDDEN>
In-reply-to: <87mul0rezk.fsf@HIDDEN> (message from Markus Triska on Mon, 
 08 Apr 2019 12:03:11 +0200)
Subject: Re: bug#35177: 27.0.50;
 Binding deactivate-mark to nil unexpectedly deactivates the mark
References: <m2tvfa3ca1.fsf@HIDDEN> <831s2dakjz.fsf@HIDDEN>
 <877ec5wid3.fsf@HIDDEN> <83d0lx8bsb.fsf@HIDDEN>
 <87mul0rezk.fsf@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 35177
Cc: 35177 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

> From: Markus Triska <triska@HIDDEN>
> Cc: 35177 <at> debbugs.gnu.org
> Date: Mon, 08 Apr 2019 12:03:11 +0200
> 
> Eli Zaretskii <eliz@HIDDEN> writes:
> 
> > None of your additional test cases do what I said I thought you should
> > do, though, do they?
> 
> In emacs -Q, please evaluate the following form with C-x C-e:
> 
>     (let (deactivate-mark)
>       (switch-to-buffer (get-buffer-create "t"))
>       (insert "hello")
>       (set-mark-command nil)
>       (move-beginning-of-line nil))
> 
> This does what you say. However, the mark is deactivated after the form
> is executed, which is the opposite of what I expect from this snippet.

I cannot reproduce your result: the above does show an active mark
after the execution, both in Emacs 26.2 and Emacs 27.0.50.

> Please also note that the documentation of deactivate-mark states
> "around the code that does the modification". If other preconditions are
> necessary to consistently retain the active mark, could you please
> document them? Thank you.

You seem to think that I know something you don't, and just withhold
it.  But that's not so: I'm exactly like you, trying to make sense of
the behavior and the documentation.  I just arrived at slightly
different conclusions, and saw that by modifying your examples I can
get the behavior described by the docs, while I cannot reproduce some
of your results, that's all.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#35177; Package emacs. Full text available.

Message received at 35177 <at> debbugs.gnu.org:


Received: (at 35177) by debbugs.gnu.org; 8 Apr 2019 10:03:19 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Apr 08 06:03:19 2019
Received: from localhost ([127.0.0.1]:49016 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hDR7X-0001vX-AT
	for submit <at> debbugs.gnu.org; Mon, 08 Apr 2019 06:03:19 -0400
Received: from metalevel.at ([78.46.218.83]:53904)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <triska@HIDDEN>) id 1hDR7T-0001vN-I2
 for 35177 <at> debbugs.gnu.org; Mon, 08 Apr 2019 06:03:18 -0400
Received: by metalevel.at (Postfix, from userid 1000)
 id DB5DEA2A8E; Mon,  8 Apr 2019 12:03:11 +0200 (CEST)
From: Markus Triska <triska@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#35177: 27.0.50;
 Binding deactivate-mark to nil unexpectedly deactivates the mark
References: <m2tvfa3ca1.fsf@HIDDEN> <831s2dakjz.fsf@HIDDEN>
 <877ec5wid3.fsf@HIDDEN> <83d0lx8bsb.fsf@HIDDEN>
Date: Mon, 08 Apr 2019 12:03:11 +0200
Message-ID: <87mul0rezk.fsf@HIDDEN>
User-Agent: Emacs/24.5
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 35177
Cc: 35177 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Eli Zaretskii <eliz@HIDDEN> writes:

> None of your additional test cases do what I said I thought you should
> do, though, do they?

In emacs -Q, please evaluate the following form with C-x C-e:

    (let (deactivate-mark)
      (switch-to-buffer (get-buffer-create "t"))
      (insert "hello")
      (set-mark-command nil)
      (move-beginning-of-line nil))

This does what you say. However, the mark is deactivated after the form
is executed, which is the opposite of what I expect from this snippet.

> I don't think it's something in your code that deactivates the mark,
> it's what Emacs does internally when a command finishes.

I noticed that the mark stays activate (as expected), when I add a
"redisplay" after switch-to-buffer:

    (let (deactivate-mark)
      (switch-to-buffer (get-buffer-create "t"))
      (redisplay)
      (insert "hello")
      (set-mark-command nil)
      (move-beginning-of-line nil))

After I evaluate this, the first form also consistently retains the
active mark when I evaluate it. It is expected that the mark stays
active, but it is unexpected that it does so after I evaluate the second
form, yet is deactivated if I only evaluate the first form.

Please also note that the documentation of deactivate-mark states
"around the code that does the modification". If other preconditions are
necessary to consistently retain the active mark, could you please
document them? Thank you.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#35177; Package emacs. Full text available.

Message received at 35177 <at> debbugs.gnu.org:


Received: (at 35177) by debbugs.gnu.org; 8 Apr 2019 02:35:15 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Apr 07 22:35:15 2019
Received: from localhost ([127.0.0.1]:48890 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hDK7u-0007rt-PY
	for submit <at> debbugs.gnu.org; Sun, 07 Apr 2019 22:35:15 -0400
Received: from eggs.gnu.org ([209.51.188.92]:53741)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1hDK7s-0007rd-My
 for 35177 <at> debbugs.gnu.org; Sun, 07 Apr 2019 22:35:14 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:38194)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <eliz@HIDDEN>)
 id 1hDK7n-0001hB-0J; Sun, 07 Apr 2019 22:35:07 -0400
Received: from [176.228.60.248] (port=1676 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1hDK7l-0002zN-NP; Sun, 07 Apr 2019 22:35:06 -0400
Date: Mon, 08 Apr 2019 05:35:00 +0300
Message-Id: <83d0lx8bsb.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Markus Triska <triska@HIDDEN>
In-reply-to: <877ec5wid3.fsf@HIDDEN> (message from Markus Triska on Mon, 
 08 Apr 2019 00:39:04 +0200)
Subject: Re: bug#35177: 27.0.50;
 Binding deactivate-mark to nil unexpectedly deactivates the mark
References: <m2tvfa3ca1.fsf@HIDDEN> <831s2dakjz.fsf@HIDDEN>
 <877ec5wid3.fsf@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 35177
Cc: 35177 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

> From: Markus Triska <triska@HIDDEN>
> Cc: 35177 <at> debbugs.gnu.org
> Date: Mon, 08 Apr 2019 00:39:04 +0200
> 
> Eli Zaretskii <eliz@HIDDEN> writes:
> 
> > I think you need to put the entire progn inside the binding of
> > deactivate-mark.  IOW, the binding should be in effect when the
> > command terminates.
> 
> Please consider the following additional test cases: Both of the
> following forms keep the mark activated, while neither of them has the
> binding in effect when the commond terminates.

None of your additional test cases do what I said I thought you should
do, though, do they?

> So, in other words, binding deactivate-mark to nil deactivates the mark,
> which is the opposite of what I expect it to do.

I don't think it's something in your code that deactivates the mark,
it's what Emacs does internally when a command finishes.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#35177; Package emacs. Full text available.

Message received at 35177 <at> debbugs.gnu.org:


Received: (at 35177) by debbugs.gnu.org; 7 Apr 2019 22:39:08 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Apr 07 18:39:08 2019
Received: from localhost ([127.0.0.1]:48829 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hDGRP-0001ul-Su
	for submit <at> debbugs.gnu.org; Sun, 07 Apr 2019 18:39:08 -0400
Received: from metalevel.at ([78.46.218.83]:43028)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <triska@HIDDEN>) id 1hDGRO-0001uc-LK
 for 35177 <at> debbugs.gnu.org; Sun, 07 Apr 2019 18:39:07 -0400
Received: by metalevel.at (Postfix, from userid 1000)
 id 2229AA03BE; Mon,  8 Apr 2019 00:39:04 +0200 (CEST)
From: Markus Triska <triska@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#35177: 27.0.50;
 Binding deactivate-mark to nil unexpectedly deactivates the mark
References: <m2tvfa3ca1.fsf@HIDDEN> <831s2dakjz.fsf@HIDDEN>
Date: Mon, 08 Apr 2019 00:39:04 +0200
In-Reply-To: <831s2dakjz.fsf@HIDDEN> (Eli Zaretskii's message of "Sun, 07 Apr
 2019 18:42:40 +0300")
Message-ID: <877ec5wid3.fsf@HIDDEN>
User-Agent: Emacs/24.5
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 35177
Cc: 35177 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Eli Zaretskii <eliz@HIDDEN> writes:

> I think you need to put the entire progn inside the binding of
> deactivate-mark.  IOW, the binding should be in effect when the
> command terminates.

Please consider the following additional test cases: Both of the
following forms keep the mark activated, while neither of them has the
binding in effect when the commond terminates.

Form 1:

    (progn
      (let (deactivate-mark)
        (switch-to-buffer (get-buffer-create "t"))
        (erase-buffer)
        (insert "hello"))
      (set-mark-command nil)
      (move-beginning-of-line nil))

Form 2:

    (progn
      (let (deactivate-mark)
        (switch-to-buffer (get-buffer-create "t"))
        (erase-buffer)
        (insert "hello"))
      (let (deactivate-mark-1)
        (set-mark-command nil)
        (move-beginning-of-line nil)))

So, it seems very unexpected to me that an additional let-binding of
deactivate-mark (to nil) causes deactivation of the mark, whereas both
of these forms keep the mark activated (when evaluated with C-x C-e).

If anything, I expect an additional let-binding of deactivate-mark to
nil to retain the active mark "all the more". In other words, if:

    (progn
      (let (deactivate-mark)
        (switch-to-buffer (get-buffer-create "t"))
        (erase-buffer)
        (insert "hello"))
      (let (deactivate-mark-1)
        (set-mark-command nil)
        (move-beginning-of-line nil)))

keeps the mark activated, then I expect the following to do too:

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

Note that I only changed deactivate-mark-1 to deactivate-mark.

So, in other words, binding deactivate-mark to nil deactivates the mark,
which is the opposite of what I expect it to do.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#35177; Package emacs. Full text available.

Message received at 35177 <at> debbugs.gnu.org:


Received: (at 35177) by debbugs.gnu.org; 7 Apr 2019 15:42:58 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Apr 07 11:42:58 2019
Received: from localhost ([127.0.0.1]:48607 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hD9wg-0006YK-5o
	for submit <at> debbugs.gnu.org; Sun, 07 Apr 2019 11:42:58 -0400
Received: from eggs.gnu.org ([209.51.188.92]:34453)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1hD9we-0006Y7-Ay
 for 35177 <at> debbugs.gnu.org; Sun, 07 Apr 2019 11:42:56 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:55779)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <eliz@HIDDEN>)
 id 1hD9wY-00016j-Ld; Sun, 07 Apr 2019 11:42:50 -0400
Received: from [176.228.60.248] (port=4977 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1hD9wX-0005FT-IE; Sun, 07 Apr 2019 11:42:50 -0400
Date: Sun, 07 Apr 2019 18:42:40 +0300
Message-Id: <831s2dakjz.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Markus Triska <triska@HIDDEN>
In-reply-to: <m2tvfa3ca1.fsf@HIDDEN> (message from Markus Triska on Sun, 
 07 Apr 2019 02:11:02 +0200)
Subject: Re: bug#35177: 27.0.50;
 Binding deactivate-mark to nil unexpectedly deactivates the mark
References: <m2tvfa3ca1.fsf@HIDDEN>
MIME-version: 1.0
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 35177
Cc: 35177 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

> From: Markus Triska <triska@HIDDEN>
> Date: Sun, 07 Apr 2019 02:11:02 +0200
> 
> 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
>      ‘deactivate-mark’ to ‘nil’ around the code that does the
>      modification.  For example:
> 
>           (let (deactivate-mark)
>             (insert " "))
> 

I think you need to put the entire progn inside the binding of
deactivate-mark.  IOW, the binding should be in effect when the
command terminates.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#35177; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 7 Apr 2019 00:08:12 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Apr 06 20:08:12 2019
Received: from localhost ([127.0.0.1]:47580 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hCvM4-0002YI-BN
	for submit <at> debbugs.gnu.org; Sat, 06 Apr 2019 20:08:12 -0400
Received: from eggs.gnu.org ([209.51.188.92]:44357)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <triska@HIDDEN>) id 1hCvM0-0002Y3-4q
 for submit <at> debbugs.gnu.org; Sat, 06 Apr 2019 20:08:10 -0400
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 <triska@HIDDEN>) id 1hCvLu-0007O9-Vx
 for submit <at> debbugs.gnu.org; Sat, 06 Apr 2019 20:08:03 -0400
Received: from eggs.gnu.org ([209.51.188.92]:58734)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <triska@HIDDEN>) id 1hCvLt-0006TI-R0
 for bug-gnu-emacs@HIDDEN; Sat, 06 Apr 2019 20:08:02 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,URIBL_BLOCKED
 autolearn=disabled version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <triska@HIDDEN>) id 1hCvLs-0007NW-Sz
 for bug-gnu-emacs@HIDDEN; Sat, 06 Apr 2019 20:08:01 -0400
Received: from metalevel.at ([78.46.218.83]:59686)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <triska@HIDDEN>) id 1hCvLs-0007MX-K8
 for bug-gnu-emacs@HIDDEN; Sat, 06 Apr 2019 20:08:00 -0400
Received: from mts-Mac-mini.localdomain (localhost.localdomain [127.0.0.1])
 by metalevel.at (Postfix) with ESMTP id 2A253A01FB
 for <bug-gnu-emacs@HIDDEN>; Sun,  7 Apr 2019 02:07:57 +0200 (CEST)
Received: by mts-Mac-mini.localdomain (Postfix, from userid 501)
 id 44D14480788; Sun,  7 Apr 2019 02:11:02 +0200 (CEST)
From: Markus Triska <triska@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 27.0.50;
 Binding deactivate-mark to nil unexpectedly deactivates the mark
Date: Sun, 07 Apr 2019 02:11:02 +0200
Message-ID: <m2tvfa3ca1.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 78.46.218.83
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


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





Acknowledgement sent to Markus Triska <triska@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#35177; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 25 Nov 2019 12:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.