From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: "Basil L. Contovounesios" Newsgroups: gmane.emacs.bugs Subject: bug#31209: 27.0.50; current-kill calls interprogram-paste-function more than once Date: Wed, 18 Apr 2018 18:52:19 +0100 Message-ID: <8736zs2yi4.fsf@tcd.ie> References: <877ep42yqv.fsf@tcd.ie> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1524073872 17304 195.159.176.226 (18 Apr 2018 17:51:12 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 18 Apr 2018 17:51:12 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: <31209@debbugs.gnu.org> Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Apr 18 19:51:08 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f8rEZ-0004Pd-Jf for geb-bug-gnu-emacs@m.gmane.org; Wed, 18 Apr 2018 19:51:07 +0200 Original-Received: from localhost ([::1]:41943 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f8rGg-0002wu-9l for geb-bug-gnu-emacs@m.gmane.org; Wed, 18 Apr 2018 13:53:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34985) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f8rGV-0002w5-Pq for bug-gnu-emacs@gnu.org; Wed, 18 Apr 2018 13:53:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f8rGQ-0005EQ-Sc for bug-gnu-emacs@gnu.org; Wed, 18 Apr 2018 13:53:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:51643) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f8rGQ-0005ED-Mt for bug-gnu-emacs@gnu.org; Wed, 18 Apr 2018 13:53:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1f8rGQ-0003hG-7a for bug-gnu-emacs@gnu.org; Wed, 18 Apr 2018 13:53:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Basil L. Contovounesios" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 18 Apr 2018 17:53:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 31209 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 31209-submit@debbugs.gnu.org id=B31209.152407395014174 (code B ref 31209); Wed, 18 Apr 2018 17:53:02 +0000 Original-Received: (at 31209) by debbugs.gnu.org; 18 Apr 2018 17:52:30 +0000 Original-Received: from localhost ([127.0.0.1]:59540 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f8rFt-0003gY-WC for submit@debbugs.gnu.org; Wed, 18 Apr 2018 13:52:30 -0400 Original-Received: from mail-wr0-f182.google.com ([209.85.128.182]:35507) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f8rFr-0003gK-LB for 31209@debbugs.gnu.org; Wed, 18 Apr 2018 13:52:28 -0400 Original-Received: by mail-wr0-f182.google.com with SMTP id w3-v6so7117196wrg.2 for <31209@debbugs.gnu.org>; Wed, 18 Apr 2018 10:52:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:subject:references:mail-followup-to:date:in-reply-to :message-id:user-agent:mime-version; bh=gAMR/fF13S7vY25Q81TkY2qRNYInyqWluoStOeXNCeo=; b=N4Fcc2+w3LQTSshR1sMJOkKxYZ6bDmsq2mXT4vCk9x1fzKA7qpTpWoUFcBItd+vEt2 zCON9Zfc1lj7z/pwKw0RzF2C93pg01e37PR9/7hlqMNrrpfL9MVOhBdMCsckNU4NvLQ+ zsohkUQEWwWslVQ6ztOuOE0pOze7b0Cp58we9x9/ZrUgoKhju1VnlC+mRwagUGzNGP6p 8BRcDIUjk0peI9X2Ir12J/z285u/1i+m4+YqS5/U1VHxs2cnytOLmzA4JshqVA0y02Y2 rD2KtE7nzq91Vo/VM1GqbMTwEUvPhS/WToV1tbFOa+a8am7tsbi1legQMnKunPGU/nzj x2uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:references:mail-followup-to:date :in-reply-to:message-id:user-agent:mime-version; bh=gAMR/fF13S7vY25Q81TkY2qRNYInyqWluoStOeXNCeo=; b=W2slevcHOpnnza3z9X8Ev5LuhBMWJizC177lwXGUsYPuP1KMe/lzMDRribhI8rZr00 kV4B+2C0y5rgNiXh49izIPhdxF85rlAauxE+VVE9MRtNwr7cEQvFhJe6nct+pjSCOfuk RSYtELBzAwueJeNwW/SjjvCsMf2291R71IoLhPASJYXOBS78hS2vWleGm3yiKLHrgBjc z4b9CDSjDkPo+46l0Aj9ow1NmTPa2JO4zoV2vL5owEe+ZYiwMuJxWooFdaqW7p1LX4vd eXoeyk6By4WO5kxsMRH1jZ1GBlsRvvnfgyc9Q+SttcU/3RUqtfS9G6mupQTuQ1NGJ0FI qlhw== X-Gm-Message-State: ALQs6tDWI70khhogcuIirxuqfAtC/uhG2BUnI9Nz8YGLvHjvXaUAAPd9 Bel96LNJuzrtI7ul6IEccTF3Dc5x X-Google-Smtp-Source: AIpwx4914hVZ0CNe4WwUCdQ6bWC6TbTJSa/Yb4wMNBad+YsnGz6E0Dk4dxyOvN0o3p/fHELtSBlkVw== X-Received: by 10.80.142.131 with SMTP id w3mr4467363edw.140.1524073941289; Wed, 18 Apr 2018 10:52:21 -0700 (PDT) Original-Received: from localhost ([213.233.149.19]) by smtp.gmail.com with ESMTPSA id v40sm1215708edm.35.2018.04.18.10.52.20 for <31209@debbugs.gnu.org> (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 18 Apr 2018 10:52:20 -0700 (PDT) Mail-Followup-To: <31209@debbugs.gnu.org> In-Reply-To: <877ep42yqv.fsf@tcd.ie> (Basil L. Contovounesios's message of "Wed, 18 Apr 2018 18:47:04 +0100") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:145579 Archived-At: --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Do-not-call-interprogram-paste-function-repeatedly.patch >From a82c662f645b82f6e9425160b586e8c607dd9a3e Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Thu, 12 Apr 2018 17:46:37 +0100 Subject: [PATCH 1/2] Do not call interprogram-paste-function repeatedly * lisp/simple.el (current-kill): Disable interprogram-paste-function so that kill-new doesn't call it repeatedly when save-interprogram-paste-before-kill is enabled. (bug#31209) --- lisp/simple.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lisp/simple.el b/lisp/simple.el index b51be3a8f8..15c4a92804 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -4463,7 +4463,10 @@ current-kill ;; Disable the interprogram cut function when we add the new ;; text to the kill ring, so Emacs doesn't try to own the ;; selection, with identical text. - (let ((interprogram-cut-function nil)) + ;; Also disable the interprogram paste function, so that + ;; `kill-new' doesn't call it repeatedly. + (let ((interprogram-cut-function nil) + (interprogram-paste-function nil)) (if (listp interprogram-paste) ;; Use `reverse' to avoid modifying external data. (mapc #'kill-new (reverse interprogram-paste)) -- 2.17.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0002-Improve-kill-related-documentation-bug-31209.patch >From 15d1a619039254df5ba1a43aa97e011bdb40175c Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Wed, 18 Apr 2018 18:35:38 +0100 Subject: [PATCH 2/2] Improve kill-related documentation (bug#31209) * doc/lispref/text.texi (Low-Level Kill Ring): Fix typo under current-kill. Mention interprogram-paste-function under kill-new and kill-append. * lisp/simple.el (save-interprogram-paste-before-kill, kill-new) (kill-append-merge-undo, kill-append): Touch-up docstrings. --- doc/lispref/text.texi | 14 +++++++++----- lisp/simple.el | 31 +++++++++++++++++-------------- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi index 8cb6cf6242..da09b4ae1c 100644 --- a/doc/lispref/text.texi +++ b/doc/lispref/text.texi @@ -1143,7 +1143,7 @@ Low-Level Kill Ring @code{current-kill} calls the value of @code{interprogram-paste-function} (documented below) before consulting the kill ring. If that value is a function and calling it -returns a string or a list of several string, @code{current-kill} +returns a string or a list of several strings, @code{current-kill} pushes the strings onto the kill ring and returns the first string. It also sets the yanking pointer to point to the kill-ring entry of the first string returned by @code{interprogram-paste-function}, @@ -1156,8 +1156,10 @@ Low-Level Kill Ring @defun kill-new string &optional replace This function pushes the text @var{string} onto the kill ring and makes the yanking pointer point to it. It discards the oldest entry -if appropriate. It also invokes the value of -@code{interprogram-cut-function} (see below). +if appropriate. It also invokes the values of +@code{interprogram-paste-function} (subject to +the user option @code{save-interprogram-paste-before-kill}) +and @code{interprogram-cut-function} (see below). If @var{replace} is non-@code{nil}, then @code{kill-new} replaces the first element of the kill ring with @var{string}, rather than pushing @@ -1169,8 +1171,10 @@ Low-Level Kill Ring kill ring and makes the yanking pointer point to the combined entry. Normally @var{string} goes at the end of the entry, but if @var{before-p} is non-@code{nil}, it goes at the beginning. This -function also invokes the value of @code{interprogram-cut-function} -(see below). +function calls @code{kill-new} as a subroutine, thus causing the +values of @code{interprogram-cut-function} and possibly +@code{interprogram-paste-function} (see below) to be invoked by +extension. @end defun @defvar interprogram-paste-function diff --git a/lisp/simple.el b/lisp/simple.el index 15c4a92804..8d04471a63 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -4341,12 +4341,11 @@ kill-ring-yank-pointer "The tail of the kill ring whose car is the last thing yanked.") (defcustom save-interprogram-paste-before-kill nil - "Save clipboard strings into kill ring before replacing them. -When one selects something in another program to paste it into Emacs, -but kills something in Emacs before actually pasting it, -this selection is gone unless this variable is non-nil, -in which case the other program's selection is saved in the `kill-ring' -before the Emacs kill and one can still paste it using \\[yank] \\[yank-pop]." + "Save existing clipboard text into kill ring before replacing it. +A non-nil value ensures that Emacs kill operations do not +irrevocably overwrite existing clipboard text by saving it to the +`kill-ring' prior to the kill. Such text can subsequently be +retrieved via \\[yank] \\[yank-pop]]." :type 'boolean :group 'killing :version "23.2") @@ -4366,7 +4365,7 @@ kill-new the front of the kill ring, rather than being added to the list. When `save-interprogram-paste-before-kill' and `interprogram-paste-function' -are non-nil, saves the interprogram paste string(s) into `kill-ring' before +are non-nil, save the interprogram paste string(s) into `kill-ring' before STRING. When the yank handler has a non-nil PARAM element, the original STRING @@ -4402,20 +4401,24 @@ kill-new (if interprogram-cut-function (funcall interprogram-cut-function string))) -;; It has been argued that this should work similar to `self-insert-command' -;; which merges insertions in undo-list in groups of 20 (hard-coded in cmds.c). +;; It has been argued that this should work like `self-insert-command' +;; which merges insertions in `buffer-undo-list' in groups of 20 +;; (hard-coded in `undo-auto-amalgamate'). (defcustom kill-append-merge-undo nil - "Whether appending to kill ring also makes \\[undo] restore both pieces of text simultaneously." + "Amalgamate appending kills with the last kill for undo. +When non-nil, appending or prepending text to the last kill makes +\\[undo] restore both pieces of text simultaneously." :type 'boolean :group 'killing :version "25.1") (defun kill-append (string before-p) "Append STRING to the end of the latest kill in the kill ring. -If BEFORE-P is non-nil, prepend STRING to the kill. -Also removes the last undo boundary in the current buffer, - depending on `kill-append-merge-undo'. -If `interprogram-cut-function' is set, pass the resulting kill to it." +If BEFORE-P is non-nil, prepend STRING to the kill instead. +If `interprogram-cut-function' is non-nil, call it with the +resulting kill. +If `kill-append-merge-undo' is non-nil, remove the last undo +boundary in the current buffer." (let* ((cur (car kill-ring))) (kill-new (if before-p (concat string cur) (concat cur string)) (or (= (length cur) 0) -- 2.17.0 --=-=-= Content-Type: text/plain "Basil L. Contovounesios" writes: > Patch addressing this to follow. I attach two patches. The first makes current-kill disable interprogram-paste-function in addition to interprogram-cut-function before calling kill-new. The second suggests potential clarifications in related documentation, both in '(elisp) Low-Level Kill Ring' and simple.el docstrings. Hopefully someone can further improve upon these. Thanks, -- Basil --=-=-=--