From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id sIBvIyTNKmPzcwEAbAwnHQ (envelope-from ) for ; Wed, 21 Sep 2022 10:36:52 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id QIaFIiTNKmPw9QAAG6o9tA (envelope-from ) for ; Wed, 21 Sep 2022 10:36:52 +0200 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 25734BB17 for ; Wed, 21 Sep 2022 10:36:52 +0200 (CEST) Received: from localhost ([::1]:60840 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oavDu-0006uN-UY for larch@yhetil.org; Wed, 21 Sep 2022 04:36:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43312) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oav4E-0002oz-Ex for emacs-orgmode@gnu.org; Wed, 21 Sep 2022 04:26:54 -0400 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]:38411) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oav4C-0006JY-OJ for emacs-orgmode@gnu.org; Wed, 21 Sep 2022 04:26:50 -0400 Received: by mail-pj1-x1029.google.com with SMTP id x1-20020a17090ab00100b001fda21bbc90so13456841pjq.3 for ; Wed, 21 Sep 2022 01:26:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date; bh=q43tBNHih2BGL/DHBZqJSqmcKANj1Txdyoew9vgLbjc=; b=OrncadCo+U2ZvHwOZ5+13f8jfc0ExBaYruCa5Tu1OFb3RLdwp9qe/vIS5GIzzrBhgx 6z2lR6qE/GFwNQpMBBCJ+Mx2XcZLx+HFO3oUu1jJcVqinKW23suy5jz4HDJ6Kojbn/mc 7whnWU07rzHPlnjXOGw0QEay1zykXcQqyYtYhtcRoUxPPBSXqN7OdhUIQ4DTwe6xmHCh 7aTgCHxdPzuXJjKI3Qht7NCsZ6BhzNq0wzlQulR6mq7fyskOf1JtLzMAAwgeZTYmHDUs tP3LJqk1KkkM5MsoEDU9rL+Vfdj7YmtB1zYcqPFAPX4SqsmWHyzbjUxNDgMuJVfm5Y2v t3kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date; bh=q43tBNHih2BGL/DHBZqJSqmcKANj1Txdyoew9vgLbjc=; b=qwN0Ec5OA9d6Bms0DlE22DI3yTC+WiWZ7/RywEm7VCxJrdbwTQUexkTaU+siliqjsz 5sPosoYv1fKuw1kjr+OsvTrtTU75YCTg9z985pi37LXYy4iCX5Usnm6xfU0zwQhESwO7 q9Kqihmf8LEFAnAKtvriIEKo8MHXe31diF5juPSyDoKywKDPRHyD4aOs2aw2avbGIBD+ vNJBjvEnMJFt0YjpUDNvcSrb60aYMB5EqgJJF1DFwELh6epdDdGFi6o2NkkGiLlfSnhz UBzkkCj90qisdIXw89uSn99UQjqaVTstv83PubrwY+/K4I34BRIT1Fz+ouHfPirBphKO QdGQ== X-Gm-Message-State: ACrzQf1HMPfVfenRRboVFnEfa3eCH5qBsJSWnL4ucsWSH5vvsKQi9uSo 2YmvAS016yUMiQT53lwQLjs= X-Google-Smtp-Source: AMsMyM5xAhOt4T0/T15sSRdCLcsOBAvZrt3aLx4bfByKEpFrh6LEpeYsFcSaJFiH7MgQj5ih3sCAeg== X-Received: by 2002:a17:90b:1b47:b0:202:f248:e1f2 with SMTP id nv7-20020a17090b1b4700b00202f248e1f2mr8348899pjb.106.1663748806397; Wed, 21 Sep 2022 01:26:46 -0700 (PDT) Received: from localhost ([1.83.154.224]) by smtp.gmail.com with ESMTPSA id x68-20020a623147000000b0053b850b17c8sm1452314pfx.152.2022.09.21.01.26.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 01:26:43 -0700 (PDT) From: Ihor Radchenko To: Max Nikulin Cc: emacs-orgmode@gnu.org Subject: Re: [PATCH] [BUG] org.el: Fix first call of `org-paste-subtree' In-Reply-To: References: <87illiyym0.fsf@localhost> Date: Wed, 21 Sep 2022 16:27:38 +0800 Message-ID: <87illhxhc5.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::1029; envelope-from=yantar92@gmail.com; helo=mail-pj1-x1029.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1663749412; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=q43tBNHih2BGL/DHBZqJSqmcKANj1Txdyoew9vgLbjc=; b=HsDjytTqkZ8ELPgWbmlGBDvovBMp6CB6wu+YgKyd+5Xd34KVclNPx5Ji+FDeDvEQZPm95j 3xyflTKiumKoruuHCUccwUM2G4vU9U+CsDLSJyF5d/Nrh65P1Hlwh/NBPvpB/C/TFvyYze 85eyHj/dmpZJb/RnpjZrZUrblND6RPmiiJmkUcsJpAA+VMQmAgCtKC2AWW6GVWlJWkOpHe 15g+itLA4+UEehhKwfJ4kjpcgQg9woSTeMOGzz1eUuK7/bBUlYyLTND6+N9z7SR4LIAM2x rVQKIGeke9C2OFEjY7uRmXRmVvLckvuq+9HGAiO9Wt3TOys/UWNjBf8SbNKF9Q== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1663749412; a=rsa-sha256; cv=none; b=Tw9f1fT7wwNhvGxQU0hiWPol+eJyh5fLXaHGQ4uqU7kAFnrmYysalNmngftuQ1AbVHr9Ct 1BiJF/ow5hg9JIrgJDE3lhBk5LYp/20fhv04Pp8g+jWjxdvX8BD4zJ0rHg4KDdS4tb/DvG jY2DcL0LvuwoS8Y5kWblCxHZV+g8XITjNp9Zl1zp9tWJeOIxHLUzEF0Zl2YG5hEIolX9mi uxqHAsO/7EwJLyXrUwrg40UKusu+RsEEyOlAKN77bGayXXLsU/dt8WUEXW/F2WoXFo8bDM 6fUSO452wNfb+sfE2QAwDCvItvpwnmaZKNpOrdEMPOG8IRWj0g0dg0tb+IRqMg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=OrncadCo; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.34 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=OrncadCo; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 25734BB17 X-Spam-Score: -3.34 X-Migadu-Scanner: scn1.migadu.com X-TUID: 3Qt+1dF1rwp6 Max Nikulin writes: >> The main problem the old code solves is working around user error when >> kill-ring is empty. We do not really want to err in such cases; just >> handle empty kill ring specially. > > From my point of view "kill ring is empty" user error clearly describes > what happens in such case, so I do not see any point to spit suggestion > to try simple yank instead. >> I agree that (and kill-ring ...) condition misses the system clipboard. >> The proper way to handle this issue is explicitly catching "Kill ring is >> empty" error thrown by `current-kill' (i.e. `condition-case'). > > Why do you believe that just allowing to propagate this error is worse? I agree with you for `org-paste-subtree', but not for `org-kill-is-subtree-p' and `org-capture-fill-template'. The two latter ones also use (and kill-ring ...). >> We have 3 occurrences of (and kill-ring (current-kill 0)) constructs in >> the code and may fix the problem either by replacing each instance with >> `condition-case' or we may create a separate macro/function in org-macs >> and use it. > > Other cases (such as the one at the end of `org-paste-subtree' to > determine if yanked text should be folded) require more care. This particular case, kill-ring test appears to be unnecessary (see snippet below). current-kill should return non-nil because otherwise "The kill is not a (set of) tree(s)" error would be thrown earlier. (when (and (not for-yank) ; in this case, org-yank will decide about folding kill-ring (equal org-subtree-clip (current-kill 0)) org-subtree-clip-folded) ;; The tree was folded before it was killed/copied (org-fold-subtree t)) The other piece (when remove (pop kill-ring)) is indeed trickier and we may need to test (equal org-subtree-clip (current-kill 0)) like the above. -- Ihor Radchenko, Org mode contributor, Learn more about Org mode at https://orgmode.org/. Support Org development at https://liberapay.com/org-mode, or support my work at https://liberapay.com/yantar92