From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id SAeODrj1cmPX9QAAbAwnHQ (envelope-from ) for ; Tue, 15 Nov 2022 03:13:12 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id EFN1Drj1cmO/IgAA9RJhRA (envelope-from ) for ; Tue, 15 Nov 2022 03:13:12 +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 B887D3CB7C for ; Tue, 15 Nov 2022 03:13:11 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ouijo-0004LT-5Q; Mon, 14 Nov 2022 18:19:36 -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 1ouiem-0004k1-4u for emacs-orgmode@gnu.org; Mon, 14 Nov 2022 18:14:24 -0500 Received: from mail-lj1-x230.google.com ([2a00:1450:4864:20::230]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oucoQ-0004jM-0J for emacs-orgmode@gnu.org; Mon, 14 Nov 2022 12:00:00 -0500 Received: by mail-lj1-x230.google.com with SMTP id u2so14023010ljl.3 for ; Mon, 14 Nov 2022 08:59:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=PY3HsIq3gY17aQuBw1kj1TpBdkKkGyVD1z1nUU1WQ/Y=; b=QKwWxMgnYiTZ7TSLLi+p8JVvRJ67JiRt2V72aqZePRMeI+sYNwkFSCzR0KZqomB7YZ 2LTLq7wK2g7uA7Ioq7z2M+FhWBddqaWXZj/feJ0qPkOPA096AKCwj7oU7gM/ccXqb88u RQG4Iet2Dl6NkA9NUJtG8EwNOfte9AyzTvypIePFTz7xvpg+QK1u8PVI4GFxXF2kcODC Jt4hk3CRNzrcVMI08tG/IWfYIYj/YFtT0C1VzkH0U9NY0qLHTMhI/WsdcAwk2+KGhUrn xmMx1AMUD5cGUW1bzfyLhvqX6q//fey8C8kcC9u+QO74/ZgtUiaVGO1BuV4KzF7CxM0d O3zQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=PY3HsIq3gY17aQuBw1kj1TpBdkKkGyVD1z1nUU1WQ/Y=; b=ntx3OmNCqSf0blCkfhn32QmJGpm6+9Fn8tngcku/VaOyXnK1moo2hde3Z8QPGgbiGa fylL2j3v+69QzPucOcIVUtTbapXozMe6F0GgUCYkRLWOWvmQZDruvGnNkAxSW4HMSU6n zDpwUuc5xlMe+fGutW//bnvkz3v6NUW14ckQYzF+Z6RqZwey06TD3vch4gvkEkbV1RaS kpFdzPVKnNx73dl+A0RzAzGRkui6zUmbbwQLR9c/6aCmjJ5h3EPEAazlkHHxCp1uYC3j /WKb167DGLZqrXEhMUaiYcpgz7q+wPjW9huQT8Pf6R9yZYfXD87wwXylaCBSyyPWxKId JvJg== X-Gm-Message-State: ANoB5pnPBHsz2WYVaFxm67+Wj/niyJGcaU2leV5LYvER/UHTFrlLXqNv aryrfTDgOKnaGIz8eviB1jg= X-Google-Smtp-Source: AA0mqf6jvwuVNCpAqmJT243pAetEudBrS/tofiy8UJiFmCBYBT/55yzl8dtZHxHE3v1oyeUK5Fbj9A== X-Received: by 2002:a2e:b6d0:0:b0:277:14cf:6da2 with SMTP id m16-20020a2eb6d0000000b0027714cf6da2mr4259624ljo.94.1668445195140; Mon, 14 Nov 2022 08:59:55 -0800 (PST) Received: from [192.168.0.101] (nat-0-0.nsk.sibset.net. [5.44.169.188]) by smtp.googlemail.com with ESMTPSA id i6-20020a2ea366000000b00278e5d12be3sm2002104ljn.127.2022.11.14.08.59.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 14 Nov 2022 08:59:54 -0800 (PST) Message-ID: <3326940f-f7a8-37f6-2dc2-f1f035f4c491@gmail.com> Date: Mon, 14 Nov 2022 23:59:52 +0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [PATCH v2] org-attach.el: ID to path functions may return nil Content-Language: en-US To: Ihor Radchenko Cc: emacs-orgmode@gnu.org References: <87k084v1wa.fsf@localhost> <871qtxhsm6.fsf@localhost> <87a68ce32u.fsf@localhost> <871qtodygs.fsf@localhost> <87v8qz9zui.fsf@localhost> <35cbf452-c3ed-d97f-db96-dcae57463eff@gmail.com> <87wnbc7ltm.fsf@localhost> <87bksn1nl1.fsf@localhost> <87sfk6zixs.fsf@localhost> <874jwiakpn.fsf@localhost> <87y1sm11aj.fsf@localhost> <87a64zjmz1.fsf@localhost> <87sfimfc2p.fsf@localhost> From: Max Nikulin In-Reply-To: <87sfimfc2p.fsf@localhost> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=2a00:1450:4864:20::230; envelope-from=manikulin@gmail.com; helo=mail-lj1-x230.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_FROM=0.001, NICE_REPLY_A=-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-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1668478391; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=PY3HsIq3gY17aQuBw1kj1TpBdkKkGyVD1z1nUU1WQ/Y=; b=KVUifny1wkoALJwLO5PO6mQpB1e5xba5gzulotF7BLipGFw/V9yi2M8mpOpBT+Ljv8Mrvp G2eFh8ajxVbDXrL9sUv1BceSZdbN02p3ePVcopW/pJAhAY0NutOYrZn2j2ylxbvg83XH0D H6PROmZk2azjnhQD4hs6jYGYC0/KeTzdKyH8uG5AN0Ziwi386lM0cnGm56qBQHF6IDhhZa jfCtrMfGdkaFaFFaJ3eONTSgXYu+zAMDw6QtpzG83Ew7XkyaRXNEyrwqVA/+TKH2kG0qtH HXlxm3t/CVyeNO/G24KjG31lVxdQs4emhgQTyly2t00KNUzJ1+FsaT7fEtTleg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1668478391; a=rsa-sha256; cv=none; b=MT8zN6BRqyHGReudq4m9eI30GrLN6HHYCs1whMg2VhaXOhlCSlgAHE5AgZsZG8FMedHlI4 mpXWZosdNiQXa6p/bJ2go+jPsu+3rx6ItGBSaLmVpXMXsNCvBziu4aMthVaA4vG4oOWthk 7/yAoFx40ySyeVWZ5aQ3tgs4uRoKaDVuUFGdcMbfRl6TL3zwyei1wQIQc8IPQN5C2DB2lJ 1NhNQLaM5c+lM9wgCXDEgP55u8v1AYc1iX6GGFr3jAK9i75AoDsqMEAGC2yXnQ+kJ3M6WE EicL9zCtM3h9F6GZK15jUvJBIjEh3F1JWkgOv+oKaeHDvk89TVcqsyKkMjbYIg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=QKwWxMgn; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=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: 6.16 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=QKwWxMgn; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=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: B887D3CB7C X-Spam-Score: 6.16 X-Migadu-Scanner: scn1.migadu.com X-TUID: /cLT6OGUb1Ok On 14/11/2022 10:29, Ihor Radchenko wrote: > > I went through the patch and tried to clarify the wording. > Especially in the defcustom docstring. I do not mind in general. Please, remove a stray space in the defcustom. > I also added the dumb fallback to the default value. > I feel that otherwise the description of too confusing. I am unsure concerning adding it to the default value. From my point of view, it is better to ask user to clarify their intention. I believe that the obscure error message is the real bug, not that Org can not handle too short ID by default. I think, for new users default value should include just strict variants of `org-attach-id-uuid-folder-format' and `org-attach-id-ts-folder-format' that checks ID format as in the example in ORG-NEWS. Changing of `org-id-method' will not cause non-optimal subdir layout for the same value of 'org-attach-id-to-path-function-list'. It will cause a problem for users who changed `org-id-method' in the past, so they have either XX/timestamp or YYYYMM/uuid subdirectories. It may be solved by adding original variants of `org-attach-id-uuid-folder-format' and `org-attach-id-ts-folder-format', but perhaps it is better to add predicates for "wrong" style (UUID or Org for timestamp and vice versa) just for backward compatibility. It should be responsibility of the user to setup subdirs layout for non-standard ID format. The dumb fallback is intended as an example and a variant for those who do not have a lot of attachments and do not care where they are stored. > +#+begin_src emacs-lisp > +(setq org-attach-id-to-path-function-list > + '(;; When ID looks like an UUIDs or Org internal ID, use > + ;; `org-attach-id-uuid-folder-format'. > + (lambda (id) > + (and (or (org-uuidgen-p id) > + (string-match-p "[0-9a-z]\\{12\\}" id)) > + (org-attach-id-uuid-folder-format id))) > + ;; When ID looks like a timestap-based ID. Group by year-month > + ;; folders. > + (lambda (id) > + (and (string-match-p "[0-9]\\{8\\}T[0-9]\\{6\\}\.[0-9]\\{6\\}" id) > + (org-attach-id-ts-folder-format id))) > + ;; Any other ID goes into "important" folder. > + (lambda (id) (format "important/%s/%s" (substring id 0 1) id)))) `org-attach-id-uuid-folder-format' and `org-attach-id-ts-folder-format' here were added for users changed `org-id-method' in the past and so having mixed subdirs layout with UUIDs in 6 character prefix directories or timestamps in two characters folders. > +#+end_src > +(defun org-attach-id-fallback-folder-format (id) > + "Return \"__/X/ID\" folder path as a dumb fallback. > +X is the first character in the ID string. > + > +This function may be appended to `org-attach-id-path-function-list' to > +provide a fallback for non-standard ID values that other functions in > +`org-attach-id-path-function-list' are unable to handle. For example, > +when the ID is too short for `org-attach-id-ts-folder-format'. > + > +However, we recommend to define a more specific function spreading > +entries over multiple folders. This function may create a large > +number of entries in a single folder, which may cause issues on some > +systems." > + (format "__/%s/%s" (substring id 0 1) id)) Additional single character subdir level should be a minor improvement, unless `org-id-prefix' is non-nil. > +(defcustom org-attach-id-to-path-function-list '( org-attach-id-uuid-folder-format space ----------------------------------------------^ > + org-attach-id-ts-folder-format If strict variants of functions were used above then non-standard IDs would be isolated in the directory returned by the next entry > + org-attach-id-fallback-folder-format) So I do not have strong objections since default value of `org-attach-id-to-path-function-list' may be adjusted later. Maybe strict variants of ID to subdir functions should be added as named functions. Fortunately it does not conflict with the patch variant your suggested. Feel free to commit your version.