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 CMVPAXnBc2NAYQEAbAwnHQ (envelope-from ) for ; Tue, 15 Nov 2022 17:42:33 +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 OIJEAXnBc2MQtwAA9RJhRA (envelope-from ) for ; Tue, 15 Nov 2022 17:42:33 +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 D4A842AE71 for ; Tue, 15 Nov 2022 17:42:32 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ouz0R-0003GM-7U; Tue, 15 Nov 2022 11:41:51 -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 1ouz0N-0003Eu-Oh for emacs-orgmode@gnu.org; Tue, 15 Nov 2022 11:41:48 -0500 Received: from ciao.gmane.io ([116.202.254.214]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ouz0M-00037t-75 for emacs-orgmode@gnu.org; Tue, 15 Nov 2022 11:41:47 -0500 Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1ouz0J-000AVN-G7 for emacs-orgmode@gnu.org; Tue, 15 Nov 2022 17:41:43 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: emacs-orgmode@gnu.org From: Max Nikulin Subject: Re: [PATCH v2] org-attach.el: ID to path functions may return nil Date: Tue, 15 Nov 2022 23:41:35 +0700 Message-ID: References: <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> <3326940f-f7a8-37f6-2dc2-f1f035f4c491@gmail.com> <878rkddjng.fsf@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Content-Language: en-US In-Reply-To: <878rkddjng.fsf@localhost> 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: 26 X-Spam_score: 2.6 X-Spam_bar: ++ X-Spam_report: (2.6 / 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.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, NICE_REPLY_A=-0.001, 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-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=1668530552; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=5PKfqjaSfh+v05zn28G9rZd2zFSyApwb05xGWKhNSGQ=; b=iuNPWGX3FgM15rUmxBxI99oTwqv2U2tIA3hS4/lSbEvtGOIwGs8CKz8r0cC3k4oKTK3NiO c4Fdc2vIOj6VRJALaBz5hBrh6OvOFsq9TvsZdCtBIqdLnoMRRwqWv2E0dKMT6FreyOg5rE o5DgOu6ceEdGWA7VhRoqSKSJqVgpFq3pqyQangEIXiHzZQq1guAIRuNM+zOPNz6DW52WF0 /q6jIiK1l4maqwM5EgJIVmtRcdYdAW28lhFqf6OhiMz2M/BInfdDnNwxskyiLfTGBVsXu3 8UTgTNi9RrBd9F72xrsfJFV8NvSHccydUmw1XMmUlE8nppN9D5Yr3SwkMPJJEA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1668530552; a=rsa-sha256; cv=none; b=oLkb70BgwLy5LOF0/AgT9WdisXV+rp3ttsHglne5XzC2+D1grYQaGE/O8Y/bOgk08GkTwn hnznYraH2LhYgnfrSBCAtVVZ86K1oFdQazo7f7XPhqBxBdJVSebXqSqTM5UNXXCTVBfDA/ VHZcONIpFeWeQqBzvvR7wcrATuPPw2oIZZBb8Th+NsosaGVHpOojFgVPbLt7KdqX+rAdgW zKiqNDvlIiPE8BPwGZ4+O+3dX+i+oDgnc+MaUrJkiEHEOG1O2qVSJwufxJUnemNNjAf+WY HECDQA6Z09rsdskOlXBn7onYNCzxmC2VeELbj9dykjacvp5t0ZQdniyT0VsXzA== 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+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: 2.66 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+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: D4A842AE71 X-Spam-Score: 2.66 X-Migadu-Scanner: scn1.migadu.com X-TUID: BS28mjCfPPDN On 15/11/2022 09:41, Ihor Radchenko wrote: > Max Nikulin writes: >> >> Please, remove a stray space in the defcustom. > > Hmm. Done. > > I just have a habit to add space in the first item in a list because it > helps auto-indentation. I had an impression that something was wrong with indentation of next entries. >>> 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. > Handling too short IDs is a different issue indeed, but why not to fix > it as well? I still have a different opinion, but it should not prevent you from committing your variant. The issue is not critical. The problem is not too short ID. Actually they are some ID having unknown format, so functions designed for particular ID generation methods may cause a mess in attachment subdirs. >> If strict variants of functions were used above then non-standard IDs >> would be isolated in the directory returned by the next entry > > Good point. > What about using the value you provided in the NEWS as an actual default? It may be done by a next patch unless other issues will attract more attention. >> `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. > > Agree. Fixed. > +(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))) > + ;; Fallback to handle previous defaults. > + org-attach-id-uuid-folder-format > + org-attach-id-ts-folder-format > + ;; Any other ID goes into "important" folder. > + (lambda (id) (format "important/%s/%s" (substring id 0 1) id)))) Sorry, but "important" entry should be before `org-attach-id-uuid-folder-format'. My idea is the following: - If the ID was generated by 'uuid or 'org `org-id-method' then prefer XX/... subfolder. It is important for new attachments. Even if current `org-id-method' is 'ts then this entry is ignored and layout is determined by the next entry. - If the ID is timestamp-based then prefer "YYYYMM/DDTIME" subfolder. - Put new non-standard IDs to important/X/... subfolder whenever particular ID is a short or a long one. - Handle the case of `org-id-method' changed in the past from timestamp to UUID or vice versa. Try to find attachment trying to split 2 characters from timestamp or 6 characters from UUID. So add bare `org-attach-id-uuid-folder-format' and `org-attach-id-ts-folder-format'. These 2 entries may be skipped for new users or for users who never experienced change of `org-id-method'.