From: Juri Linkov <juri@jurta.org>
To: Leo <sdl.web@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: kill-new may replace the wrong item
Date: Thu, 03 Jun 2010 22:17:09 +0300 [thread overview]
Message-ID: <874ohjj4x2.fsf@mail.jurta.org> (raw)
In-Reply-To: <AANLkTikKmz3YmVrzlwDAP0PJPbDnG7QA2vnhCxzk0EHk@mail.gmail.com> (Leo's message of "Wed, 2 Jun 2010 22:33:28 +0100")
> All I am trying to point out is there's something incorrect there.
The whole implementation of `kill-do-not-save-duplicates' is incorrect.
It should do nothing instead of setting `replace' to t and replacing the
same string with itself (that may override the value pushed from
`interprogram-paste' to `kill-ring').
I believe this patch will provide the consistent interaction between
`kill-do-not-save-duplicates' and `save-interprogram-paste-before-kill'.
Before pushing a string to kill-ring it compares the head of kill-ring with
the string from interprogram-paste and later with the input argument `string':
=== modified file 'lisp/simple.el'
--- lisp/simple.el 2010-05-19 19:17:29 +0000
+++ lisp/simple.el 2010-06-03 19:16:18 +0000
@@ -3009,24 +3009,25 @@ (defun kill-new (string &optional replac
(if yank-handler
(signal 'args-out-of-range
(list string "yank-handler specified for empty string"))))
- (when (and kill-do-not-save-duplicates
- (equal string (car kill-ring)))
- (setq replace t))
(if (fboundp 'menu-bar-update-yank-menu)
(menu-bar-update-yank-menu string (and replace (car kill-ring))))
(when save-interprogram-paste-before-kill
(let ((interprogram-paste (and interprogram-paste-function
(funcall interprogram-paste-function))))
(when interprogram-paste
- (if (listp interprogram-paste)
- (dolist (s (nreverse interprogram-paste))
- (push s kill-ring))
- (push interprogram-paste 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)))
+ (dolist (s (if (listp interprogram-paste)
+ (nreverse interprogram-paste)
+ (list interprogram-paste)))
+ (unless (and kill-do-not-save-duplicates
+ (equal s (car kill-ring)))
+ (push s kill-ring))))))
+ (unless (and kill-do-not-save-duplicates
+ (equal string (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))))
--
Juri Linkov
http://www.jurta.org/emacs/
next prev parent reply other threads:[~2010-06-03 19:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-31 21:32 kill-new may replace the wrong item Leo
2010-06-01 19:58 ` Juri Linkov
2010-06-02 3:10 ` Leo
2010-06-02 3:36 ` Leo
2010-06-02 19:53 ` Juri Linkov
2010-06-02 21:33 ` Leo
2010-06-03 19:17 ` Juri Linkov [this message]
2010-06-03 23:31 ` Leo
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=874ohjj4x2.fsf@mail.jurta.org \
--to=juri@jurta.org \
--cc=emacs-devel@gnu.org \
--cc=sdl.web@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 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.