GNU bug report logs -
#27442
Un-obsolete x-clipboard-yank, or provide analogous functional
Previous Next
Reported by: Constantine Kharlamov <Hi-Angel <at> yandex.ru>
Date: Wed, 21 Jun 2017 15:33:01 UTC
Severity: normal
Tags: moreinfo, patch
Fixed in version 28.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Constantine Kharlamov <Hi-Angel <at> yandex.ru> writes:
> 1. start `emacs -Q`
> 2. Press M-: to execute `(setq select-enable-clipboard nil)`
> 3. Copy a text in the system, i.e. outside of Emacs.
> 4. Press M-: to execute `(clipboard-yank)` (you'll get at the point a
> content from system clipboard)
> 5. Press M-< M-d (so now you have the word ";; This" in kill-ring)
> 6. Press M-: to execute `(clipboard-yank)`
>
> You will see ";; This" got pasted at point, not the value in
> the system clipboard.
>
> 7. Press M-: to execute `(x-clipboard-yank)`
>
> You will see content from the system clipboard got pasted at point.
Aaah! This explains the weird behaviour I've been seeing when I'm
trying to paste stuff from the clipboard -- as you say,
`M-x clipboard-yank' doesn't work reliably if you've yanked the
clipboard contents once.
And that's because of this:
(defun gui-selection-value ()
(let ((clip-text
(when select-enable-clipboard
(let ((text (gui--selection-value-internal 'CLIPBOARD)))
(if (string= text "") (setq text nil))
;; Check the CLIPBOARD selection for 'newness', is it different
;; from what we remembered them to be last time we did a
;; cut/paste operation.
(prog1
(unless (equal text gui--last-selected-text-clipboard)
text)
(setq gui--last-selected-text-clipboard text)))))
So, indeed, if you `M-x clipboard-yank', then kill some text in Emacs,
you can't `M-x clipboard-yank' until you've clipboarded some other text,
yanked it, and then clipboarded the original text again.
Fixing this should be pretty trivial -- the following patch should do
the trick, I think (although I haven't tested it). But I'm not quite
sure about the intended logic here, so I've added Stefan M to the CCs --
perhaps he has some comments.
diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el
index 739e751d8a..dac04e113e 100644
--- a/lisp/menu-bar.el
+++ b/lisp/menu-bar.el
@@ -570,7 +570,8 @@ menu-bar-edit-menu
(defun clipboard-yank ()
"Insert the clipboard contents, or the last stretch of killed text."
(interactive "*")
- (let ((select-enable-clipboard t))
+ (let ((select-enable-clipboard t)
+ (gui--last-selected-text-clipboard nil))
(yank)))
(defun clipboard-kill-ring-save (beg end &optional region)
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
This bug report was last modified 4 years and 14 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.