unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Sam Steingold <sds@gnu.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: kill-new discards current X selection
Date: Wed, 26 Aug 2009 16:39:25 -0400	[thread overview]
Message-ID: <1f77704b0908261339y2baac531j11c6b230c28f1fd6@mail.gmail.com> (raw)
In-Reply-To: <jwv8wh67548.fsf-monnier+emacs@gnu.org>

On Wed, Aug 26, 2009 at 3:28 PM, Stefan Monnier<monnier@iro.umontreal.ca> wrote:
>> When I select a word in an xterm and then kill in emacs, then X selection is
>> gone forever, replaced with the emacs kill.
>> The appended patch prepends the current X selection to kill-ring before
>> replacing the X selection with the current Emacs kill.
>> Is it OK to install it unconditionally, or is it better to guard it
>> with a user option, e.g., save-interprogram-paste-before-kill?
>
> It needs to be guarded, because it can cause a delay in C-k (when the
> previous selection owner is non-responsive) and some people find it
> unacceptable.  At least that's my recollection of the consensus last
> time I suggested it.

OK, I will.

> BTW, here's the version I use in my own local collection of hacks.
>
> === modified file 'lisp/simple.el'
> --- lisp/simple.el      2009-08-19 08:31:59 +0000
> +++ lisp/simple.el      2009-08-21 14:24:38 +0000
> @@ -2799,6 +2851,21 @@
>  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."
> +  ;; To better pretend that X-selection = head-of-kill-ring, we copy other
> +  ;; application's X-selection to the kill-ring.  This comes in handy when
> +  ;; you do something like:
> +  ;; - copy a piece of text in your web-browser.
> +  ;; - have to do some editing (including killing) before you can yank
> +  ;;   that text.
> +  ;; Note: this piece of code inspired from current-kill.
> +  (let ((paste (and interprogram-paste-function
> +                    (funcall interprogram-paste-function))))
> +    (when paste
> +      (let ((interprogram-cut-function nil)
> +            (interprogram-paste-function nil))
> +        (kill-new paste))))

I think my version is just a little bit more transparent.

> +  ;; The actual kill-new functionality.
> +  (when (equal string (car kill-ring)) (setq replace t))

this seems to be a separate nice feature, similar to bash
HISTCONTROL=ignoredups.
I think it would be a good separate addition, controlled by
kill-ignore-duplicates




-- 
Sam Steingold <http://sds.podval.org>




  reply	other threads:[~2009-08-26 20:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-26 16:18 kill-new discards current X selection Sam Steingold
2009-08-26 18:41 ` Jan D.
2009-08-26 19:28 ` Stefan Monnier
2009-08-26 20:39   ` Sam Steingold [this message]
2009-08-27  3:03     ` Stefan Monnier
2009-08-26 19:36 ` David De La Harpe Golden

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=1f77704b0908261339y2baac531j11c6b230c28f1fd6@mail.gmail.com \
    --to=sds@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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).