From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id yHoLEVLCpGFFAgAAgWs5BA (envelope-from ) for ; Mon, 29 Nov 2021 13:06:42 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id KKraDFLCpGHwAQAA1q6Kng (envelope-from ) for ; Mon, 29 Nov 2021 12:06:42 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 62CCCB422 for ; Mon, 29 Nov 2021 13:06:41 +0100 (CET) Received: from localhost ([::1]:50402 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mrfQd-000694-F9 for larch@yhetil.org; Mon, 29 Nov 2021 07:06:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43690) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mrfN1-0004aw-PR for emacs-orgmode@gnu.org; Mon, 29 Nov 2021 07:02:58 -0500 Received: from ciao.gmane.io ([116.202.254.214]:48384) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mrfMv-0000Hm-2U for emacs-orgmode@gnu.org; Mon, 29 Nov 2021 07:02:55 -0500 Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1mrfMs-0008ui-QA for emacs-orgmode@gnu.org; Mon, 29 Nov 2021 13:02:46 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: emacs-orgmode@gnu.org From: Max Nikulin Subject: [PATCH] [BUG] org.el: Fix first call of `org-paste-subtree' Date: Mon, 29 Nov 2021 19:02:35 +0700 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------4B288139C22F78DD17507E1D" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 X-Mozilla-News-Host: news://news.gmane.io:119 Content-Language: en-US Received-SPF: pass client-ip=116.202.254.214; envelope-from=geo-emacs-orgmode@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: 28 X-Spam_score: 2.8 X-Spam_bar: ++ X-Spam_report: (2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, FORGED_MUA_MOZILLA=2.309, FREEMAIL_FORGED_FROMDOMAIN=0.248, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.248, NML_ADSP_CUSTOM_MED=0.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1638187601; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=FkSbefA3pgRSqhxZkmEfHTA+yEqL7hcBG/frF6Qp2Jk=; b=N1mx83W3uPqNJjl5yvITkWcwFtwD/jNigv0MzCs6HXD6Yk9OvM7sll/0+5w/sKYSt15znJ hRbln8TWlxGZYd5puGMpHw3kdvTjDFIt/rLQnDGIK9lC5EuaPk8Q4Kw+fxit/7IoYKb9g/ 7zhbriI6I6GCYvEelqkMhwsYLWgvK5T8tKakpDCUfalXfu9y1A+DPM8ZG0R8c9oqYRwySL nZUJqq1K9dGrocqU/I6fJZbm98psWyE7bfefLs1YOhclLjPSLT2AWrjo/OvWA9e3z+yZS2 DPxrg0f3jFVdRgkaMl78zcHGS4EjXhYoVME2DDwcHCyKqmJ/xxzfwq+dbYZGqw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1638187601; a=rsa-sha256; cv=none; b=pn85y7j5BxW+FGC8WSE+Q8/xhsFiz9SRYgxTjmA/89Gpfpno9em6nbZgJMDj1FyJy8JbzJ BhSt9oIa7CcyVlR8FK/CQWsaHRN74dhnxAiMthsHr5KI5PS34t9WWewNB4hpKxvgv57e1s IURf6oVHEbh+zHJDqguiHv0JuCEI265FwOOXg7fMtJXKzMYK0htdUc8rxtF1rKIxi1kbTV YfvwzMHxhvRsOUDd0CJ0r/DqOugI+rOL7HFs/4QyoBeNGIyN7yOwjUzQ7FQt9ko9DRecl0 Bry4e0IWEz7MkusPwpO5bqeoYIrEuQupXVSmcnaRvAwEW//lJL1uAreYCXnzow== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -2.31 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: 62CCCB422 X-Spam-Score: -2.31 X-Migadu-Scanner: scn1.migadu.com X-TUID: KbtzJSqCXr47 This is a multi-part message in MIME format. --------------4B288139C22F78DD17507E1D Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit An old bug is living in Org. =C-c C-x C-y= ~org-paste-subtree~ fails just after Emacs start. Maybe there are more similar issues. - Start *new* instance of emacs. - Copy some text that is Org subtree from some *external* application (not Emacs). I usually come across this issue when I copy capture from my Firefox extension. Alternative: #+begin_src elisp :results silent (require 'ob-shell) #+end_src #+begin_src bash :results silent printf '%b' '* Heading\n\nbody\n' | xclip -in -selection clipborad >/dev/null # xsel --input --clipboard #+end_src - Try =C-c C-x C-y= or [[elisp:(org-paste-subtree)]] + Actual result is the following message: : user-error: The kill is not a (set of) tree(s). Use ‘C-y’ to yank anyway + Expected result is a heading pasted at the end of the buffer. + The result may be achieved by calling [[elisp:(org-paste-subtree)]] once more. - The problem is ~(and kill-ring (current-kill 0))~ expression in the definition of ~org-paste-subtree~. Restart emacs and repeat steps above skipping ~org-paste-subtree~. Notice that ~(current-kill 0)~ call changes value of ~kill-ring~. #+begin_src elisp :results pp (list (and kill-ring t) (current-kill 0) (and kill-ring t)) #+end_src #+RESULTS: : (nil "* Heading\n\nbody\n" t) I suppose, it is better to let the error from ~current-kill~ to propagate (in the case of empty `kill-ring' and clipboard). I do not have Windows machine available to test the change. There is another occurence of ~(and (current-kill 0))~ in ~org-kill-is-subtree-p~. I would rather transform it to ~org~subtree-p~ to avoid call of ~current-kill~ inside, but this patch does not include such change. --------------4B288139C22F78DD17507E1D Content-Type: text/x-patch; charset=UTF-8; name="0001-org.el-Fix-first-call-of-org-paste-subtree.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-org.el-Fix-first-call-of-org-paste-subtree.patch" >From 04bbf6359f370bddb6ca5fff1d8c7737e7ac5ee7 Mon Sep 17 00:00:00 2001 From: Max Nikulin Date: Mon, 29 Nov 2021 18:54:43 +0700 Subject: [PATCH] org.el: Fix first call of `org-paste-subtree' * lisp/org.el (org-paste-subtree): Do not check `kill-ring' before calling `current-kill' since the latter can pull content of clipboard. First call of `org-paste-subtree' failed if nothing had been yanked before since Emacs start but system clipboard had text with valid subtree originating from other application. The bug was where since the commit adding `org-paste-subtree'. If both `kill-ring' and system clipboard are empty then `current-kill' generates meaningful error. --- lisp/org.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/org.el b/lisp/org.el index 025513e7a..55953e97b 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -7774,7 +7774,7 @@ the inserted text when done. When REMOVE is non-nil, remove the subtree from the clipboard." (interactive "P") - (setq tree (or tree (and kill-ring (current-kill 0)))) + (setq tree (or tree (current-kill 0))) (unless (org-kill-is-subtree-p tree) (user-error (substitute-command-keys -- 2.25.1 --------------4B288139C22F78DD17507E1D--