From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#28631: 25.3.50; Deactivate mark with Ctrl-g mess up the primary-selection Date: Wed, 11 Oct 2017 22:06:22 -0400 Message-ID: <87o9pdazmp.fsf@users.sourceforge.net> References: <87ing3w8rk.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1507774032 29282 195.159.176.226 (12 Oct 2017 02:07:12 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 12 Oct 2017 02:07:12 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.60 (gnu/linux) Cc: 28631@debbugs.gnu.org To: Tino Calancha Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Oct 12 04:07:08 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e2Sts-0006Zh-Fh for geb-bug-gnu-emacs@m.gmane.org; Thu, 12 Oct 2017 04:07:04 +0200 Original-Received: from localhost ([::1]:43335 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2Stz-00018s-E4 for geb-bug-gnu-emacs@m.gmane.org; Wed, 11 Oct 2017 22:07:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50991) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2Stt-00018l-Rk for bug-gnu-emacs@gnu.org; Wed, 11 Oct 2017 22:07:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2Stq-0005PR-Lr for bug-gnu-emacs@gnu.org; Wed, 11 Oct 2017 22:07:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:54222) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e2Stq-0005PB-Gc for bug-gnu-emacs@gnu.org; Wed, 11 Oct 2017 22:07:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1e2Stq-0002Zf-5H for bug-gnu-emacs@gnu.org; Wed, 11 Oct 2017 22:07:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 12 Oct 2017 02:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 28631 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 28631-submit@debbugs.gnu.org id=B28631.15077739929847 (code B ref 28631); Thu, 12 Oct 2017 02:07:02 +0000 Original-Received: (at 28631) by debbugs.gnu.org; 12 Oct 2017 02:06:32 +0000 Original-Received: from localhost ([127.0.0.1]:34670 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e2StL-0002Yl-VS for submit@debbugs.gnu.org; Wed, 11 Oct 2017 22:06:32 -0400 Original-Received: from mail-io0-f178.google.com ([209.85.223.178]:53525) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e2StK-0002YX-EJ for 28631@debbugs.gnu.org; Wed, 11 Oct 2017 22:06:30 -0400 Original-Received: by mail-io0-f178.google.com with SMTP id 189so3860116iow.10 for <28631@debbugs.gnu.org>; Wed, 11 Oct 2017 19:06:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=O38uuUlZrDiACq938Bfn+1TMElkeC9ZVdcRw/mU9UgI=; b=qbfpjhZqWrdPuktuOOlsPOOjyXJ6OurtW5mpMjbV1NgKXqAmsHpXGW1+UBtN4EVI72 sKSZ32AlFttB9cuG9RGK1WdPJ3FeVU0W5QdDGZprx4mooJ7+TaU+h973c9v0avTa86j7 qfra81D/gEy47H1OuCFrUDfYokCrfWxnAhM3TRI/RSx+GPUebu/hHtWzH+mFZgVsEroJ EVTDgdIz84FOgzgJ6jvL2Ecx/xIRNLFr4WQn0PPn/OKKpSBMXXBzp6CAtz+iZALk6li0 vSBMYNUBXooCP5bYb1AN6NHIrfFKwots5YMC7F0uVW6p5VUgYsTWrCt39h8JjWquKHsM fsEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=O38uuUlZrDiACq938Bfn+1TMElkeC9ZVdcRw/mU9UgI=; b=kK2HfTQf7uWVMQWjBiSn56EtrUSBa5AvmnydA1nvWft26MXPmUHhnss4Op2EQggRes K1CgbYsMwF3AYoEQuy+6M8y20tybBlyDw4cG+mrCZRu27gr1ecZpJCHpAl0G+rPMKKGQ MbMY+Cg9+YQ2vvFWEsaOsTELCZoggXhB7O4PJx1JfG00oZ1LPFo4xS+7SvOfKz3RZ5Fw aaKBeVFIVclJd6BNOW/zW6sfSM+fUgpU7aOiWIKkoEFa594yhqjW3YSq8PPWJpuu6Zc0 k3lTU6ZTeQ/NTl6CdSggFE8S6WEtx4D5CD7QPRlbhBjKVkfREt/vWCZUaTEb3LqwKVtk siUg== X-Gm-Message-State: AMCzsaVeAGRXpyf2F+BPfJoccsmEyUcuRzgnzOvErzbL7l5fZwhG5Luw P+gfnfUIxUprQ0c2D3U521WvXQ== X-Google-Smtp-Source: ABhQp+QYDPgNTFAT0UjOe01VxzgVkl1Txkccc/G2EWOoDgzO7ji5PDbCdOK/+a6k6Ynl/SDuBPcn/A== X-Received: by 10.107.141.206 with SMTP id p197mr1346899iod.92.1507773984508; Wed, 11 Oct 2017 19:06:24 -0700 (PDT) Original-Received: from zebian ([45.2.119.34]) by smtp.googlemail.com with ESMTPSA id b66sm7274287itb.28.2017.10.11.19.06.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Oct 2017 19:06:23 -0700 (PDT) In-Reply-To: <87ing3w8rk.fsf@gmail.com> (Tino Calancha's message of "Thu, 28 Sep 2017 17:02:39 +0900") 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: 208.118.235.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:138240 Archived-At: Tino Calancha writes: > I am biten by this problem from time to time. When winer-mode > is enabled and i deactivate the mark with C-g, then i observe > funny behaviour with `yank'. > > Usually i visit another buffer BUF-B to copy a string STR; then > i do `winner-undo' to comeback to the initial buffer, BUF-A, and `yank' > STR. Sometimes i found that `yank' insert a string different than STR. > That's happen if i previously deactivated the mark in BUF-A with C-g. > > To reproduce the problem: > emacs -Q -eval '(winner-mode 1)' \ > -eval "(customize-set-variable 'select-enable-clipboard nil)" \ > -eval "(customize-set-variable 'select-enable-primary t)" > > < C-TAB M-f M-f ; `yank' would insert ";; This buffer" That should be 'M-< C-SPC M-f M-f' I guess. > C-x C-b C-x 0 C-x o, not C-x 0. > C-x h ; mark whole buffer > ;; `yank' would insert the content of *Buffer List* > C-g > RET ; `yank' would insert ";; This buffer" > C-c ; winner-undo > ;; `yank' would insert the content of *Buffer List* > > Note that the primary selection doesn't change if you visit > *Buffer List* with C-x b RET. That is, if you change above > C-c > by: > C-x b RET > > then, the `yank' will insert ";;This buffer". > > I don't see a good reason why visiting a buffer with `C-x b' or > `winner-undo' makes a difference in the primary selection. It's because winner-undo tries to restore marks. (defun winner-active-region () (declare (gv-setter (lambda (store) ... `(if ,store (activate-mark) (deactivate-mark)))))) (region-active-p)) ... ;; Make sure point does not end up in the minibuffer and delete ;; windows displaying dead or boring buffers ;; (c.f. `winner-boring-buffers'). Return nil if all the windows ;; should be deleted. Preserve correct points and marks. (defun winner-set (conf) ... ;; Restore marks (save-current-buffer (cl-loop for buf in buffers for entry = (cadr (assq buf winner-point-alist)) do (progn (set-buffer buf) (set-mark (car entry)) (setf (winner-active-region) (cdr entry))))) ... Lisp Backtrace: "x-own-selection-internal" (0xffffb560) 0x1364810 PVEC_COMPILED "apply" (0xffffbbe0) "gui-backend-set-selection" (0xffffc110) "gui-set-selection" (0xffffc628) "deactivate-mark" (0xffffcb60) "winner-set" (0xffffd100) "winner-undo-this" (0xffffd600) "winner-undo" (0xffffddb0) "funcall-interactively" (0xffffdda8) "call-interactively" (0xffffe010) "command-execute" (0xffffe588) (gdb) p selection_value $10 = XIL(0x31a5f54) (gdb) xpr Lisp_String $11 = (struct Lisp_String *) 0x31a5f50 ". * *scratch*", ' ' , "266 Lisp Interaction \n %* *Messages*", ' ' , "133 Messages \n" > How about the following patch? > > Set mark at point after keyboard-quit > > * lisp/simple.el (deactivate-mark): In transient-mark-mode > always set the mark at point after keyboard-quit (Bug#28631). That seems quite disruptive. Perhaps instead deactivate-mark could be changed so that it would not update the selection on winner-undo?