unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#28631: 25.3.50; Deactivate mark with Ctrl-g mess up the primary-selection
@ 2017-09-28  8:02 Tino Calancha
  2017-10-12  0:52 ` Tino Calancha
  2017-10-12  2:06 ` Noam Postavsky
  0 siblings, 2 replies; 13+ messages in thread
From: Tino Calancha @ 2017-09-28  8:02 UTC (permalink / raw)
  To: 28631

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 <left> ; 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 <left>
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 <tino.calancha@gmail.com>
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))





^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2017-10-17  7:25 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-28  8:02 bug#28631: 25.3.50; Deactivate mark with Ctrl-g mess up the primary-selection Tino Calancha
2017-10-12  0:52 ` Tino Calancha
2017-10-12  2:06 ` Noam Postavsky
2017-10-12  2:53   ` Tino Calancha
2017-10-13  0:46     ` Noam Postavsky
2017-10-13  1:54       ` Tino Calancha
2017-10-13  6:48       ` Eli Zaretskii
2017-10-13  8:06         ` Tino Calancha
2017-10-13 13:32           ` Noam Postavsky
2017-10-14  1:42             ` Tino Calancha
2017-10-14  2:09               ` Noam Postavsky
2017-10-14  6:56                 ` Eli Zaretskii
2017-10-17  7:25                   ` Tino Calancha

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).