From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.bugs Subject: bug#28631: 25.3.50; Deactivate mark with Ctrl-g mess up the primary-selection Date: Thu, 28 Sep 2017 17:02:39 +0900 Message-ID: <87ing3w8rk.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1506585857 15343 195.159.176.226 (28 Sep 2017 08:04:17 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 28 Sep 2017 08:04:17 +0000 (UTC) To: 28631@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Sep 28 10:04:12 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 1dxTnn-0003Zm-Kd for geb-bug-gnu-emacs@m.gmane.org; Thu, 28 Sep 2017 10:04:11 +0200 Original-Received: from localhost ([::1]:57866 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxTnu-0002F7-Un for geb-bug-gnu-emacs@m.gmane.org; Thu, 28 Sep 2017 04:04:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41634) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxTnj-0002Ab-Db for bug-gnu-emacs@gnu.org; Thu, 28 Sep 2017 04:04:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxTne-0000Lr-FC for bug-gnu-emacs@gnu.org; Thu, 28 Sep 2017 04:04:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:55418) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dxTne-0000Ll-BJ for bug-gnu-emacs@gnu.org; Thu, 28 Sep 2017 04:04:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dxTne-0004OE-2y for bug-gnu-emacs@gnu.org; Thu, 28 Sep 2017 04:04:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 28 Sep 2017 08:04:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 28631 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.150658579516816 (code B ref -1); Thu, 28 Sep 2017 08:04:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 28 Sep 2017 08:03:15 +0000 Original-Received: from localhost ([127.0.0.1]:35866 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dxTmq-0004N9-Rw for submit@debbugs.gnu.org; Thu, 28 Sep 2017 04:03:14 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:50419) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dxTmo-0004Mv-2r for submit@debbugs.gnu.org; Thu, 28 Sep 2017 04:03:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxTmh-0008TA-J1 for submit@debbugs.gnu.org; Thu, 28 Sep 2017 04:03:05 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:53357) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxTmh-0008T4-Fr for submit@debbugs.gnu.org; Thu, 28 Sep 2017 04:03:03 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41362) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxTmc-0001YK-5R for bug-gnu-emacs@gnu.org; Thu, 28 Sep 2017 04:03:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxTmX-0008OW-79 for bug-gnu-emacs@gnu.org; Thu, 28 Sep 2017 04:02:58 -0400 Original-Received: from mail-pg0-x22a.google.com ([2607:f8b0:400e:c05::22a]:48335) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dxTmW-0008Nd-TI for bug-gnu-emacs@gnu.org; Thu, 28 Sep 2017 04:02:53 -0400 Original-Received: by mail-pg0-x22a.google.com with SMTP id v23so523556pgc.5 for ; Thu, 28 Sep 2017 01:02:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version; bh=FbuLsP+9mgDz+RoQ32Tl5bUI2Z/ABUUXE43Y/TGjoGM=; b=vc3Gm4+dhCgvD2v/z6tMFdk/z8TcIYfLyTGnq4vPN68L05Bm+90Wqbu2kU4r3bQ2qD W5f/4QDXkXNTO3BDmAmD/oI5gHZ2kDqeQMGwgLOZaKLPc3iFNpEH2CO2KtCSgxc5YGz2 J01i9bl6YLsMVOvJB878vUqb+bjRnvKKNGQFAUTPw7j81CWG4h3ZPzp0G7sZBLDUYjtk 1EVUgkoPDdQ6yFRn03kPC0E3dWq9PKHIU+8WfKWgfj+lksePVE0a6EcRWRrsC7we1Qe1 gx9OwRE/Owk/qKlKfg22lyKbLK69NqWh21qf0w9b4S21KMjNHRh6L1sAPXVNbZWtGkMs 2DdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=FbuLsP+9mgDz+RoQ32Tl5bUI2Z/ABUUXE43Y/TGjoGM=; b=lXzVVJIBXp2J9Lki2mHtIOn3XBkv8qd5aw4UvRabkXqsiFQiLBxQxhUMzc4GCf4KVB 4pA1UfnosWklH0HnrO46QoOkHaZbFoParkbAzLinwTMklGxqt6iS3ZHYgsAjgZX2k9eP M6w+gX1cAhpRn5TT3iWfnBBshwCJ7BYHAQBUkqknHnEp8AZtGT1C993uFuEr1O5NYpVE gXukkpwYoSyz36E/pu1Mtu/HoKEp/9iXIUKTe6XrfmMXlc+br+y5hv+RFS8I509FWdpZ miVBj2P5AzQ5Sj7NSRi3atngV7GEJFBOI9TsqmvZ2haKhU9jTY7fXKDH9FSYdbaPzi3x II5w== X-Gm-Message-State: AHPjjUhm3cz4uHn5aVVGmcVRrJLT+0wWcAWw6vkGNo3bbAPCAnEyIQzP jZxeFxq3DJXkN2Y+Rkq5/asKvQ== X-Google-Smtp-Source: AOwi7QDvTxFZA0lJIkjcbwoegrWhxUXSOOeG88lS6k4zGahJ2E6dWT/cTmGNlxA/T9h4ZYInBDFpMQ== X-Received: by 10.99.177.74 with SMTP id g10mr3566915pgp.326.1506585770065; Thu, 28 Sep 2017 01:02:50 -0700 (PDT) Original-Received: from calancha-pc (203.191.218.133.dy.bbexcite.jp. [133.218.191.203]) by smtp.gmail.com with ESMTPSA id 65sm1726275pgh.31.2017.09.28.01.02.47 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Sep 2017 01:02:49 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. 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: 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:137532 Archived-At: Tags: patch 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" C-x C-b 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. How about the following patch? --8<-----------------------------cut here---------------start------------->8--- commit 74e5a589b762388baadbb2ac2f146bbe66765deb Author: Tino Calancha Date: Thu Sep 28 16:34:52 2017 +0900 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). diff --git a/lisp/simple.el b/lisp/simple.el index 469557713d..1f809d8964 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -5349,6 +5349,11 @@ deactivate-mark (kill-local-variable 'transient-mark-mode))) (setq mark-active nil) (run-hooks 'deactivate-mark-hook) + ;; Set mark at point after `keyboard-quit' (Bug#28631). + (when (and transient-mark-mode + (eq this-command 'keyboard-quit) + (/= (mark 'force) (point))) + (push-mark nil 'nomsg)) (redisplay--update-region-highlight (selected-window)))) (defun activate-mark (&optional no-tmm) --8<-----------------------------cut here---------------end--------------->8--- In GNU Emacs 27.0.50 (build 11, x86_64-pc-linux-gnu, GTK+ Version 3.22.11) of 2017-09-28 Repository revision: 1f02ae39310f15bf683642b9aee1cf162bd391e6 In GNU Emacs 25.3.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.11) of 2017-09-20 built on calancha-pc Repository revision: c3ff6712ad24fcf45874dc0665a8606e9b2208a4 Windowing system distributor 'The X.Org Foundation', version 11.0.11902000 System Description: Debian GNU/Linux 9.1 (stretch) Configured features: XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 Important settings: value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix Major mode: Buffer Menu Minor modes in effect: winner-mode: t tooltip-mode: t global-eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t buffer-read-only: t line-number-mode: t transient-mark-mode: t Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. Mark set [4 times] Quit Winner undo (1 / 4) Quit Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message dired format-spec rfc822 mml mml-sec password-cache epg epg-config gnus-util mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util help-fns help-mode mail-prsvr mail-utils cus-edit easymenu cus-start cus-load wid-edit cl-loaddefs pcase cl-lib winner ring time-date mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese charscript case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer cl-preloaded nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote dbusbind inotify dynamic-setting system-font-setting font-render-setting move-toolbar gtk x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 104842 3683) (symbols 48 21319 0) (miscs 40 108 146) (strings 32 17876 5250) (string-bytes 1 487777) (vectors 16 12687) (vector-slots 8 439460 5000) (floats 8 174 21) (intervals 56 281 10) (buffers 976 20))