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 6GJQMhQqaGO48wAAbAwnHQ (envelope-from ) for ; Sun, 06 Nov 2022 22:41:40 +0100 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 aABcMRQqaGO0yQAAG6o9tA (envelope-from ) for ; Sun, 06 Nov 2022 22:41:40 +0100 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 69EFB2EF30 for ; Sun, 6 Nov 2022 22:41:40 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ornNT-0004bY-2v; Sun, 06 Nov 2022 16:40:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ornNP-0004Ze-RK for emacs-orgmode@gnu.org; Sun, 06 Nov 2022 16:40:23 -0500 Received: from bird.elm.relay.mailchannels.net ([23.83.212.17]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ornNN-0005ul-TE for emacs-orgmode@gnu.org; Sun, 06 Nov 2022 16:40:23 -0500 X-Sender-Id: dreamhost|x-authsender|inbox@alphapapa.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id D69DD40DC2; Sun, 6 Nov 2022 21:40:17 +0000 (UTC) Received: from pdx1-sub0-mail-a294 (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 7143440D07; Sun, 6 Nov 2022 21:40:17 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1667770817; a=rsa-sha256; cv=none; b=qXYajSeuNKQBqD2Y7eZxbefCo46+eI0nWj+Hb47E9ySqxgNBZqR5h33i0KR+kzCFPqkvmP OBrfhfdhi23NKkkY4WTou705OTOkyI5eWP1xlDrJUMFrEb1OfizLyKH2Vt9lK5a/r5SbBd A7DUncLgVNmW/eIeTsJpTuw4zxwYhTvAmu3tgpGWKppw/x2gxIsPPUx1RtPqj18wrxIivQ plvdhRRXNtgQvCqFZzSxxs3zSXrE/DRfK8caEwbENTb2Q0EgoSijKWgbyNpgr5HDICu4+P ONSuErdk7Vawmt0ky99Zl+HK+ohmKhyw6OWsI5TvltJr22XRK7+HY0FeE/hnEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1667770817; h=from:from: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:dkim-signature; bh=PJZQYNA2sy7Rdixrq8f1hTricpdNA+/Oy1TDBxpmoSU=; b=eQVXgoPHxYfs5a+A3bZSPXUB7O3UQx8V084qsWn4a9qSfVlnqVqhelq9e+VbVcpWHYrQn8 XNh9hgItaFFRDu2NQ+zfWgwhivM/7mMOqpnB1AEGHpgZ65VjeuHQsK7HLM1ISgdOS6oWe9 oNuDZXHtUGNFknZ6CUjzAJtc4rUnw9/XMtn2rNLOicZowtqpP0/Kg55d1EOIjisLULjkNQ P9aNdf7FL5QtLhBKoA9VODrDXySuydHhB14kWRyCShIM6eWLxxhTPQhyn8KxQ9RGuePhDA 0C9iABoZyZjpLPW7IdxtmwztQfArPPZuOhCNHL9pvc2PxrhHDk/pYZ+nYTmEew== ARC-Authentication-Results: i=1; rspamd-7f9bbcf788-lc8tz; auth=pass smtp.auth=dreamhost smtp.mailfrom=adam@alphapapa.net X-Sender-Id: dreamhost|x-authsender|inbox@alphapapa.net X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|inbox@alphapapa.net X-MailChannels-Auth-Id: dreamhost X-Keen-Wipe: 629115371ef60d2b_1667770817697_3988369295 X-MC-Loop-Signature: 1667770817696:3817352582 X-MC-Ingress-Time: 1667770817696 Received: from pdx1-sub0-mail-a294 (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.99.229.7 (trex/6.7.1); Sun, 06 Nov 2022 21:40:17 +0000 Received: from [10.124.0.70] (unknown [193.56.116.195]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: inbox@alphapapa.net) by pdx1-sub0-mail-a294 (Postfix) with ESMTPSA id 4N577h6Jhbz8q; Sun, 6 Nov 2022 13:40:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alphapapa.net; s=dreamhost; t=1667770817; bh=PJZQYNA2sy7Rdixrq8f1hTricpdNA+/Oy1TDBxpmoSU=; h=Content-Type:Date:Subject:To:Cc:From; b=FlDijxyrO7uN3Aq9EgTQb1TkWtyawV/Z9qG/r+gmY78jN1PI/rE3CA9ywkW5C+vaR 4V1LqmlmPnDlbzoEU+7SMC4JSlcmavXK4Mw5zS9EjV78086ccJUVppM+BF5FwYsM0M NwFUZuZwsoRHNU1T+bh/KJjU9sJSYmCAdlygX7IfX53lgG9vu3nueEdAd12zGY5Fsf Fpy1BUiJUzc7lbW3kpDUG8HiAo31EqZjPIwY1+SJEDkdKBDSOPuSgdA829Sm1i+Iiq 5LmvtP4F1kulPqIm9mFVAdJCiQ3DBCvOjvK9cXEn098HthCBH+kaH72wCvPzxAW8EQ Yi3Wz+zM3v5IQ== Content-Type: multipart/mixed; boundary="------------H6AMky9ofb4bbKDYAx3eoM6f" Message-ID: <8b2c1814-2c6f-fdca-8ba7-63c415bfca5e@alphapapa.net> Date: Sun, 6 Nov 2022 15:40:15 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH] * lisp/org.el: (org-get-indirect-buffer) Allow indirect base buffers Content-Language: en-US To: Ihor Radchenko Cc: emacs-orgmode@gnu.org References: <66cdbc7d-9720-d124-a9f1-2467ae07a4ef@alphapapa.net> <87a655lt4x.fsf@localhost> From: Adam Porter In-Reply-To: <87a655lt4x.fsf@localhost> Received-SPF: neutral client-ip=23.83.212.17; envelope-from=adam@alphapapa.net; helo=bird.elm.relay.mailchannels.net X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NEUTRAL=0.779 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1667770900; 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=PJZQYNA2sy7Rdixrq8f1hTricpdNA+/Oy1TDBxpmoSU=; b=Ssy+QFpkppoSahP+n0stIIPDqL5zHt02lsgJgGr7cC4+Kua0VYmDbdpbPjSr7tKBkvRM6M S5kwU/sLaaipFTV3gDxXzOdT7bMIgfaz+lrLsdl1i94uiuAT7/OYjDwDv9EsFftm7B2NBL KbSnXIF036AINwDq3+m18u/x5DIWSFyzE4e0KibTABlLsSkdfAzvF1/CSR0SFqq1RPr4jt Q3e0mNsSKyUtzlFiL3nhfpY8R7xfMNe994s0OAL8zOhrIRNZ3ZdqtZP5HpOLShCIJiWi02 yCkMgUNJDmUugIaAbWvv8Oa8FjFKsHIu2obDPMAajDUHiSf7lYVHT98doiAMyw== ARC-Seal: i=2; s=key1; d=yhetil.org; t=1667770900; a=rsa-sha256; cv=pass; b=lBK0kJYzwRFRaCGwh7n4fPigUHX02Mp7OiR86IYHtvh+rNahVYjL7QUEXPxJlyxs71cOYQ CiTAJ745F8v90/1lpX8VEux8n/EYjUwLJ8+FRaXF9hv32AYA/Ks9m0O6p+X2bz3SNdoyT8 v2YzJDT2d7y9XdeZdkhorpmhLDEbsbtbKijb9VsjeR8C61F+aSb4uX9RwZZGmZzL0S5xfD 6Q84lj9seoVQQwL7WNzCm3jRpaxiBxL4HmdlH01XKhG3xsRqXrZxZgB7h5BayxNMXqEp8a RlamLcu9HkFFb09V7Hsmc7PJXmBnpbEbxnzFzIqlRMV1PWI6EZ4BxqwMnfPZfQ== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=pass header.d=alphapapa.net header.s=dreamhost header.b=FlDijxyr; arc=pass ("mailchannels.net:s=arc-2022:i=1"); dmarc=none; 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: -8.70 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=alphapapa.net header.s=dreamhost header.b=FlDijxyr; arc=pass ("mailchannels.net:s=arc-2022:i=1"); dmarc=none; 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: 69EFB2EF30 X-Spam-Score: -8.70 X-Migadu-Scanner: scn0.migadu.com X-TUID: MV/ZDojuULdZ This is a multi-part message in MIME format. --------------H6AMky9ofb4bbKDYAx3eoM6f Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi Ihor, On 11/5/22 03:09, Ihor Radchenko wrote: > Adam Porter writes: > >> The attached patch improves the function org-get-indirect-buffer, fixing >> a bug, clarifying the code, and adding a docstring. > > Thanks! I have some comments. Thanks for your review. I've attached a new patch. >> +(cl-defun org-get-indirect-buffer (&optional (buffer (current-buffer)) heading) >> + "Return an indirect buffer based on BUFFER. >> +If HEADING, prepend it to the name of the new buffer." > > Maybe append to the name? Yes, thanks. In the new patch I took the liberty of improving the format to make it more distinctive (i.e. it won't resemble a normal filename). > >> + (let* ((base-buffer (or (buffer-base-buffer buffer) buffer)) >> + (suffix-prefix (if heading >> + (concat heading "-") >> + "")) > > Why not pre-define the whole prefix instead? > (prefix (format "%s-%s" (buffer-name base-buffer) > (if heading (concat heading "-") ""))) > > then, can just say (format "%s%s" prefix n) in the loop. > >> + (buffer-name (cl-loop for n from 1 to 100 > > why to 100? It may fail (even though unlikely) and also unnecessary. > Can just say for n from 1. I chose to limit the index because IME it's better to signal an error than to potentially go into an infinite loop. Although it shouldn't happen, it could in the case of unforeseen circumstances, one of which I experienced while writing the patch. But, even better, the new patch uses the built-in function generate-new-buffer-name, which handles it for us, and more efficiently. >> + ;; FIXME: Explain why this `condition-case' is necessary. Why >> + ;; could an error be signaled with the CLONE argument non-nil, >> + ;; and why would trying again without CLONE solve the problem? >> + (error (make-indirect-buffer base-buffer buffer-name))))) > > I did not find why in the git logs. It looks like some ancient code. You > can remove it in a followup patch. Very well, the new patch omits it. Thanks, Adam --------------H6AMky9ofb4bbKDYAx3eoM6f Content-Type: text/x-patch; charset=UTF-8; name="0001-lisp-org.el-org-get-indirect-buffer-Allow-indirect-b.patch" Content-Disposition: attachment; filename*0="0001-lisp-org.el-org-get-indirect-buffer-Allow-indirect-b.pa"; filename*1="tch" Content-Transfer-Encoding: base64 RnJvbSAyMmU3MDkxYjVkNmRkOGE4NDQ0NmIzMDNhMjcwNmFiM2Q0MjJiNTJmIE1vbiBTZXAg MTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBBZGFtIFBvcnRlciA8YWRhbUBhbHBoYXBhcGEubmV0 PgpEYXRlOiBGcmksIDQgTm92IDIwMjIgMTQ6NTI6NTggLTA1MDAKU3ViamVjdDogW1BBVENI XSAqIGxpc3Avb3JnLmVsOiAob3JnLWdldC1pbmRpcmVjdC1idWZmZXIpIEFsbG93IGluZGly ZWN0IGJhc2UKIGJ1ZmZlcnMKClByZXZpb3VzbHksIGNhbGxpbmcgdGhpcyBmdW5jdGlvbiBv biBhbiBpbmRpcmVjdCBidWZmZXIgd291bGQgZmFpbCwKcHJldmVudGluZyB0aGUgdXNlciBm cm9tIG1ha2luZyBhIG5ldyBpbmRpcmVjdCBidWZmZXIgYmFzZWQgb24gYW4KaW5kaXJlY3Qg YnVmZmVyIChlLmcuIGltYWdpbmUgdGhlIHVzZXIgbWFrZXMgYW4gaW5kaXJlY3QgYnVmZmVy IGZvciBhCmxhcmdlIHN1YnRyZWUsIHRoZW4gd2FudHMgdG8gbWFrZSBhbm90aGVyIG9uZSBm b3IgYSBzdWJ0cmVlIG9mIHRoYXQpLgpOb3csIHRoZSBiYXNlIGJ1ZmZlciBvZiB0aGUgYnVm ZmVyIGlzIHVzZWQsIHdoZW4gYXBwbGljYWJsZS4KCkFsc28sIHRoZSBmdW5jdGlvbiBpcyBw YXJ0aWFsbHkgcmV3cml0dGVuIHRvIGJlI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ICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChjb25jYXQgIjo6IiBoZWFkaW5nKQor ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIiIpKSkpCisgICAgICAgICAoaW5k aXJlY3QtYnVmZmVyIChtYWtlLWluZGlyZWN0LWJ1ZmZlciBiYXNlLWJ1ZmZlciBidWZmZXIt bmFtZSAnY2xvbmUpKSkKKyAgICA7OyBEZWNvdXBsZSBmb2xkaW5nIHN0YXRlLiAgV2UgbmVl ZCB0byBkbyBpdCBtYW51YWxseSBzaW5jZQorICAgIDs7IGBtYWtlLWluZGlyZWN0LWJ1ZmZl cicgZG9lcyBub3QgcnVuCisgICAgOzsgYGNsb25lLWluZGlyZWN0LWJ1ZmZlci1ob29rJy4K KyAgICAob3JnLWZvbGQtY29yZS1kZWNvdXBsZS1pbmRpcmVjdC1idWZmZXItZm9sZHMpCisg ICAgaW5kaXJlY3QtYnVmZmVyKSkKIAogKGRlZnVuIG9yZy1zZXQtZnJhbWUtdGl0bGUgKHRp dGxlKQogICAiU2V0IHRoZSB0aXRsZSBvZiB0aGUgY3VycmVudCBmcmFtZSB0byB0aGUgc3Ry aW5nIFRJVExFLiIKLS0gCjIuMzQuMAoK --------------H6AMky9ofb4bbKDYAx3eoM6f--