unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Noam Postavsky <npostavs@users.sourceforge.net>
To: Tino Calancha <tino.calancha@gmail.com>
Cc: 28631@debbugs.gnu.org
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	[thread overview]
Message-ID: <87o9pdazmp.fsf@users.sourceforge.net> (raw)
In-Reply-To: <87ing3w8rk.fsf@gmail.com> (Tino Calancha's message of "Thu, 28 Sep 2017 17:02:39 +0900")

Tino Calancha <tino.calancha@gmail.com> 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 <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.

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*", ' ' <repeats 15 times>, "266 Lisp Interaction \n %* *Messages*", ' ' <repeats 14 times>, "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?





  parent reply	other threads:[~2017-10-12  2:06 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87o9pdazmp.fsf@users.sourceforge.net \
    --to=npostavs@users.sourceforge.net \
    --cc=28631@debbugs.gnu.org \
    --cc=tino.calancha@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).