[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: kill-new discards current X selection
From: |
Stefan Monnier |
Subject: |
Re: kill-new discards current X selection |
Date: |
Wed, 26 Aug 2009 23:03:33 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) |
>> 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.
Actually, IIRC I specifically (re)used kill-new to avoid code duplication.
>> + ;; 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
Yes, it's a separate "feature". I can't remember which use-case this
was designed for, but I remember I added it for one particular situation
where it makes a big difference (not that it doesn't remove all
duplicates, just consecutive duplicates).
Stefan