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 ms9.migadu.com with LMTPS id EGImHhWpd2S/rgAASxT56A (envelope-from ) for ; Wed, 31 May 2023 22:07:49 +0200 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 GEsqHRWpd2Q9rAAA9RJhRA (envelope-from ) for ; Wed, 31 May 2023 22:07:49 +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 A608F11D6B for ; Wed, 31 May 2023 22:07:48 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4S43-0003Q0-0D; Wed, 31 May 2023 16:04:59 -0400 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 1q4S40-0003O5-CX for emacs-orgmode@gnu.org; Wed, 31 May 2023 16:04:56 -0400 Received: from relay7-d.mail.gandi.net ([217.70.183.200]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4S3n-0005sd-D2 for emacs-orgmode@gnu.org; Wed, 31 May 2023 16:04:56 -0400 X-GND-Sasl: fernseed@fernseed.me DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fernseed.me; s=gm1; t=1685563471; 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; bh=iceh2DMTVZjYhC+9ctcxM3vK0Ozyck0sSNWrKovkOSg=; b=SwOaoNJZPJxdeVfbrR060IGc8wb+Kqq4qwiaidPsZNs57pcamWDWTeSwkyvqMZzHq3HLIO YpiRfQ65Hl/zEexHGh/IL+9SLw/nZSpUqfKMaeKlw0QYiQGVpwKXXFXeAddoQKQK+YCxb7 imcUln9qcTy7YqdmrAC0GX4I/nb8rFGkngaU2YmzeBCTKlCanbeoVybrDo/IxFwtGARcMG NKzdjH18v2ZicHDcYstrtw/Tt9YiRDv/YXuuZGFu5HoUY03FOyAIJoNyrSBSnyb6ALxycN KhMuHnAEOhHIggREHlhq8bggpeuEAf+vx2gh1NwajMyfW5Y3dkKzPe+1Lg5RPg== X-GND-Sasl: fernseed@fernseed.me Received: by mail.gandi.net (Postfix) with ESMTPSA id 9258A20004; Wed, 31 May 2023 20:04:30 +0000 (UTC) From: Kierin Bell To: Ihor Radchenko Cc: emacs-orgmode@gnu.org Subject: Re: [PATCH] lisp/org-id.el: Add new relative timestamp feature for `ts' `org-id-method' In-Reply-To: <87a5xkoq6p.fsf@localhost> (Ihor Radchenko's message of "Wed, 31 May 2023 08:33:50 +0000") References: <20230416164841.18665-1-fernseed@fernseed.me> <87o7nmlpbp.fsf@localhost> <87v8gac9uy.fsf@localhost> <87r0qxo8z5.fsf@fernseed.me> <87a5xkoq6p.fsf@localhost> Date: Wed, 31 May 2023 16:04:28 -0400 Message-ID: <87r0qw8dyr.fsf@fernseed.me> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=217.70.183.200; envelope-from=fernseed@fernseed.me; helo=relay7-d.mail.gandi.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1685563669; a=rsa-sha256; cv=none; b=CH0z2w08tY/+XPVMy1UTMACSIIkKZI5DTlB6EHhwCPhsU9+TqazuxfslvMJ6BIwYplCggW mpIeVZ3Od9b9WCWeBZv+J6YLw+4cI1nUxBOfrIIdXTVSC/vmMtQ33Oj3vUQ3TV66M2Fvpi GpM1IdUBxAenEBmKPxYhXJ/l4ggi+frPTgKj9SkDdl6GxLHyF8+2bLOyl0Yl4O2yTd4rVP qwKKQNc6ieplkh03RRItZ2o7xyhU8Z7KTUO8fby88BIXktxU+O2XuUCHStf/29yXk0oJ+f L9KqulerJiYIGBTYZ7OWNh/yWMXd/dDCeQPyrk2rU/TeCyYeBxm2lqJrRc3RDQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=fernseed.me header.s=gm1 header.b=SwOaoNJZ; dmarc=pass (policy=none) header.from=fernseed.me; 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" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1685563669; 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=iceh2DMTVZjYhC+9ctcxM3vK0Ozyck0sSNWrKovkOSg=; b=GkL3nAYDzGXq6SljATpXnJpW/dBwgHEBLznfeDIgJEbcFZiUCwJ6YrTzciikWxsXt53knc RfpKYpKcyohbd5mxiHt9WfOO1txAdkwjIR0WbFqGRSb4uLLl025DiO9CO/WtB1nuuLiD6e kd6lJpXrt9HOB2KIjqarxFdT5m9a8S2Xup24UqFxpifQIDMoyL/P2T5qMDnCyuWGMESWZf /jMc+z3Ztj1mxctvZqPHHTsNOVkQEYLzqY1ibXLSVPTyGqnkfc1PR8FByjka3/GuaN5V2k 2H8nXnK//W8dn4p0zBlKvCF9AC1CzFAkt3s19lWUEwhtYusTDDb1421VDw990Q== Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=fernseed.me header.s=gm1 header.b=SwOaoNJZ; dmarc=pass (policy=none) header.from=fernseed.me; 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-Scanner: scn0.migadu.com X-Migadu-Spam-Score: -5.55 X-Spam-Score: -5.55 X-Migadu-Queue-Id: A608F11D6B X-TUID: Y6oyVSuOOOnl Ihor Radchenko writes: > Kierin Bell writes: > >> 3. I have implemented a check to verify that `org-id-ts-relative-function' is >> only called in Org mode buffers. But since I am uncertain about all of >> the possible contexts in which `org-id-new' can be called, I am not >> completely sure if it is adequate: >> >> --8<---------------cut here---------------start------------->8--- >> (defun org-id-ts-relative-get-effective () >> "Get an effective time using `org-id-ts-relative-function'. >> >> Ensure that `org-id-ts-relative-function' is only called in the >> proper environment (an Org buffer), and return nil otherwise." >> (when (and (derived-mode-p 'org-mode) >> (functionp org-id-ts-relative-function)) >> (funcall org-id-ts-relative-function))) >> --8<---------------cut here---------------end--------------->8--- > > I do not like this approach too much. > I think that more reliable approach would be adding a new optional > argument CONTEXT to `org-id-new'. Then, `org-id-get' can pass the > context (buffer marker) letting `org-id-new' know the aimed location of > the newly created ID. I think that your suggestion is a better idea. It might also be a good idea to refactor `org-id-new' so that the different ID methods are more composable. One nice way to do this would be to create a new option that supersedes (but does not override) `org-id-method' and takes a list of functions that are tried in order, so that: (setopt org-id-method 'ts org-id-ts-relative t org-id-ts-relative-function #'org-id-ts-relative-from-keyword-or-property) ... would be equivalent to: (setopt org-id-function-list '(org-id-relative-ts-keyword org-id-relative-ts-property org-id-ts)) It would then be easy, for example, to instead set the variable so that a timestamp value is searched for in properties first *and then* in keywords if that fails. Or, perhaps someone will want to implement an `org-id-semantic-ts' ID method that takes a file with the keywords: #+title: Title of File #+date: [2023-06-01 Thu 00:00] ...And creates an ID that looks like: 20230601T000000--title-of-file+0.000000 Users could abuse my new `org-id-ts-effective-format' option to achieve this, or we could add an `org-id-ts-infix' option, and so on. But it would be better to have ID methods that are each narrowly focused in purpose, with an easy extension mechanism so that we won't have any qualms about the focus being too narrow. I do understand that ID methods may be intentionally difficult to extend, because IDs should be stable and consistent. But I don't think that extensibility, human-friendliness and consistency are necessarily mutually exclusive. So, what do you think about the `org-id-function-list' option? Either way, I'll work on refactoring the patch to make things as modular as possible. -- Kierin Bell GPG Key: FCF2 5F08 EA4F 2E3D C7C3 0D41 D14A 8CD3 2D97 0B36