all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Craig Falls <cfalls@gmail.com>
To: bug-gnu-emacs@gnu.org
Subject: bug#2289: wishlist with fix: losing X-windows clipboard
Date: Wed, 11 Feb 2009 11:46:43 -0500	[thread overview]
Message-ID: <180a05860902110846v246f3b2aq665aec656c420a0d@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 3930 bytes --]

Symptom: User loses the contents of the X-windows clipboard when
executing a kill command.  This is inconsistent with text killed in
emacs, which is still saved in the kill-ring after subsequent kills.
(see http://osdir.com/ml/emacs.macintosh.osx/2005-11/msg00078.html for
someone else annoyed by this)

Actions to trigger: Copy text in Firefox.  Run a kill command
(e.g. kill-region) in emacs.  Run yank.  Run yank-pop.  Note that the
text copied in Firefox is nowhere to be found.

Fix: The following one-line patch seems to work, but I'm no emacs
hacker, so among other things, there's no configuration.  It just
saves the clipboard to the kill-ring before killing if yank would
result in yanking the clipboard instead of the top of the kill ring.

--- /home/cfalls/src/emacs/lisp/simple.el       2008-04-22
15:50:11.000000000 -0400
+++ /tmp/simple.el      2009-02-11 11:23:46.373880990 -0500
@@ -2705,46 +2705,47 @@
 (defun kill-new (string &optional replace yank-handler)
   "Make STRING the latest kill in the kill ring.
 Set `kill-ring-yank-pointer' to point to it.
 If `interprogram-cut-function' is non-nil, apply it to STRING.
 Optional second argument REPLACE non-nil means that STRING will replace
 the front of the kill ring, rather than being added to the list.

 Optional third arguments YANK-HANDLER controls how the STRING is later
 inserted into a buffer; see `insert-for-yank' for details.
 When a yank handler is specified, STRING must be non-empty (the yank
 handler, if non-nil, is stored as a `yank-handler' text property on
STRING).

 When the yank handler has a non-nil PARAM element, the original STRING
 argument is not used by `insert-for-yank'.  However, since Lisp code
 may access and use elements from the kill ring directly, the STRING
 argument should still be a \"useful\" string for such uses."
   (if (> (length string) 0)
       (if yank-handler
          (put-text-property 0 (length string)
                             'yank-handler yank-handler string))
     (if yank-handler
        (signal 'args-out-of-range
                (list string "yank-handler specified for empty string"))))
+  (current-kill 0)
   (if (fboundp 'menu-bar-update-yank-menu)
       (menu-bar-update-yank-menu string (and replace (car kill-ring))))
   (if (and replace kill-ring)
       (setcar kill-ring string)
     (push string kill-ring)
     (if (> (length kill-ring) kill-ring-max)
        (setcdr (nthcdr (1- kill-ring-max) kill-ring) nil)))
   (setq kill-ring-yank-pointer kill-ring)
   (if interprogram-cut-function
       (funcall interprogram-cut-function string (not replace))))

 (defun kill-append (string before-p &optional yank-handler)
   "Append STRING to the end of the latest kill in the kill ring.
 If BEFORE-P is non-nil, prepend STRING to the kill.
 Optional third argument YANK-HANDLER, if non-nil, specifies the
 yank-handler text property to be set on the combined kill ring
 string.  If the specified yank-handler arg differs from the
 yank-handler property of the latest kill string, this function
 adds the combined string to the kill ring as a new element,
 instead of replacing the last kill with it.
 If `interprogram-cut-function' is set, pass the resulting kill to it."
   (let* ((cur (car kill-ring)))
     (kill-new (if before-p (concat string cur) (concat cur string))



In GNU Emacs 23.0.60.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.8.20)
 of 2008-04-24 on nyc-qws-024
Windowing system distributor `The X.Org Foundation', version 11.0.70101000
configured using `configure  '--enable-font-backend' '--with-xft'
'--with-freetype''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default-enable-multibyte-characters: t

[-- Attachment #2: Type: text/html, Size: 5340 bytes --]

             reply	other threads:[~2009-02-11 16:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-11 16:46 Craig Falls [this message]
2009-02-12  2:33 ` bug#2289: wishlist with fix: losing X-windows clipboard Stefan Monnier
2009-02-12  2:40   ` Processed: " Emacs bug Tracking System
2009-02-13  0:04   ` Craig Falls
2011-10-05  5:53     ` Glenn Morris
2011-10-05 22:18       ` Chong Yidong

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

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

  git send-email \
    --in-reply-to=180a05860902110846v246f3b2aq665aec656c420a0d@mail.gmail.com \
    --to=cfalls@gmail.com \
    --cc=2289@emacsbugs.donarmstrong.com \
    --cc=bug-gnu-emacs@gnu.org \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.