From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id aKX8MZ4xWWLOOAAAgWs5BA (envelope-from ) for ; Fri, 15 Apr 2022 10:49:34 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id uKOdLp4xWWKfsgAAauVa8A (envelope-from ) for ; Fri, 15 Apr 2022 10:49:34 +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 27E0C21DDA for ; Fri, 15 Apr 2022 10:49:34 +0200 (CEST) Received: from localhost ([::1]:47884 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nfHe0-0006x6-UE for larch@yhetil.org; Fri, 15 Apr 2022 04:49:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50850) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nfHZY-00052W-7Z for emacs-orgmode@gnu.org; Fri, 15 Apr 2022 04:44:57 -0400 Received: from mail-ot1-x335.google.com ([2607:f8b0:4864:20::335]:36827) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nfHZW-0003rt-0Q for emacs-orgmode@gnu.org; Fri, 15 Apr 2022 04:44:55 -0400 Received: by mail-ot1-x335.google.com with SMTP id c11-20020a9d684b000000b00603307cef05so1421719oto.3 for ; Fri, 15 Apr 2022 01:44:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=TtmeYLaIUPVzL9kMCPLxWYjUPCjLQ2J3omsfki4C8PY=; b=k+zSeMXhF1vu3PTuOpl8+OR0CWd/ggCO6U/XYC7Q28RtN3unssCKL4PnIC4u8ZxO3B wqnVDaq7KXgMHV6KYjTHlhg5qI64MYPXVngDu/COIsCRBWhcF2jgh0odoQ9kRAcQ7gMX l3jIDShXUG/ZYOZxPFJYbA1YHT7hoC+D6nonx/BzO5ZNztgh3H6Y3ciB7VuSY2JupXPV xpcl09GL2jU9KxiohnWgShTqQbM9ZZH/Z0ZeFCihyEm8gfWfkbDf1GlA5c+dDQCmXN1S OPUO/3A4UPLgLkoRa6QxjXg4HHB295ZxiRb6rf1S1AmIBjUO52xnRnHL7BXjZ169VvoQ kI6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=TtmeYLaIUPVzL9kMCPLxWYjUPCjLQ2J3omsfki4C8PY=; b=EDbdmhaEw3BVTius9Um3C3W8v9TsQl1C+QMe3bqQvcCBk6yHXFIxrXCdI0uF96GJ6p Clzj0R+sOZ8SWCfy0rM/Ufn1svHw5Q1IJ2KPVcJkKl0I7G5q5wqQiBg0PJ1wxpKsxv/9 WGTpmSQyBmjeE7QJ7DHEWetZGuY9xsp1AG49yxYq5E0JMpn6Ukk/h+8PDdyIggI/pOC+ PnHuDsjB9XdJgYuijpxbIaey3X5csNRIV/f26TTxWNO21ABcGCejM7X5UDX0Cfy7NaXy Rc9ZUZjB5NJHuUylFF/qy5eIG4kN6EvMKXqX4rGnt4wag/4EEP6KxEGTetqjq7PJh0TH IhLA== X-Gm-Message-State: AOAM532oy0yE8nihEM5pMg/ZUHE3WhOddOkZZMqvkytJPogX76a17pq9 5Pi0cXnTxK03FU0MaZ+2oRo= X-Google-Smtp-Source: ABdhPJxxTSwuCArZHgDvqOylcCeukNs+SwqsNMwrM6njCCO0Hh6b9uDMWsXlPPlP/KKmACQcZ00uXA== X-Received: by 2002:a9d:6406:0:b0:5cd:c867:c2e2 with SMTP id h6-20020a9d6406000000b005cdc867c2e2mr2264158otl.306.1650012292287; Fri, 15 Apr 2022 01:44:52 -0700 (PDT) Received: from localhost ([208.110.84.210]) by smtp.gmail.com with ESMTPSA id n62-20020acaef41000000b002ef646e6690sm960858oih.53.2022.04.15.01.44.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 01:44:51 -0700 (PDT) From: Ihor Radchenko To: Anders Johansson Subject: Re: Bug: Changed behaviour of org-at-timestamp-p after recent change In-Reply-To: References: Date: Fri, 15 Apr 2022 16:45:44 +0800 Message-ID: <87tuau20qv.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::335; envelope-from=yantar92@gmail.com; helo=mail-ot1-x335.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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, 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: , Cc: org-mode-email 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=1650012574; 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=TtmeYLaIUPVzL9kMCPLxWYjUPCjLQ2J3omsfki4C8PY=; b=Vxic/06c9CQ+NWyfkFoFU3rqSKfOMlKnE1iPbsPiabzhAFZ6Ilk7IRsgW8zYxOhDW2vrXp woyHxSt8uC+Iow/KBK+Do7AEzvdUmb5Lire/zh81OKpE/zxLI7ho8tIgN+krpIHnHR9H0N oEy/4duEI672N0IwAaPiXaUEVf1blt8Twq4uvPCMuSKRszHOHqCRuPtqGjvXz+pKqKwhsf O4znn6DWZoU1DvTlcg8MJHV43K7kAs71Bt8XhL77PVJAaVYuOShNcN0AITgdn2AyEZRc6L dPRRdPrUmrdZhMd/t3anYmRF38ZULzODJpzTEFsi7D1/st+igtAhyxXnzq+N6g== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1650012574; a=rsa-sha256; cv=none; b=JlfPJj/UN1MJj3smn/d2byhOM8R0DgiWg74aNgxX0D6fQwLMW5fVG6YefxbQjIl8cQU0PE EM0EbL4xLTqPHGybBNEx3tfj7Zn4on7I8DZnmgiwihL0WhaTKiY9ebg+4fdUZC6heuIKsB tpzpudxvtGeNbhveAfRDRBsYrIrhICA/EFTlu/jNKHLbsKP20ErUougNp96X0DTYwn3EvD FJ8x4/GQ7eSo5Cbzl8BV1rG1Mh2J9FAcvnDnjuLMTCrumUmUzM9GeE0shRvskvT7EJBfJ1 Hp1Y39yBD3YnNWTuJfgQXI9i+guv9KwdHeJ4SY1sXM2SC7Q3bztx01djTlgWYQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=k+zSeMXh; 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: -5.05 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=k+zSeMXh; 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: 27E0C21DDA X-Spam-Score: -5.05 X-Migadu-Scanner: scn0.migadu.com X-TUID: 2CSVVPuKgpAE --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Anders Johansson writes: > Hi, > I noticed that this commit: > b1a570b3b org-agenda: Fix regression when diary sexp timestamps are igno= red > > made a call like (org-at-timestamp-p 'agenda) match against the regexp > `org-element--timestamp-regexp`. However, this regexp doesn=E2=80=99t hav= e the > match groups setup as the others (`org-ts-regexp3` and `org-ts-regexp2`) = so > the last part of the docstring for org-at-timestamp-p doesn=E2=80=99t hol= d anymore > (that the timestamp parts should now be put in match groups). Confirmed. Can you try the attached patch? Also, unless I miss something, docstring was not fully obeyed even in the past. Consider the following timestamp: <2022-04-15 Fri 11:40> I ran the following code with point at the timestamp: (progn (org-at-timestamp-p ) (mapcar #'substring-no-properties (list (match= -string 0) (match-string 1) (match-string 2) (match-string 3) (match-string= 4) (match-string 5) (match-string 6) (match-string 7)))) The output is: ("<2022-04-15 Fri 11:40>" "2022-04-15 Fri 11:40" "2022" "04" "15" "Fri" " 1= 1:40" "11" "40") There are two extra groups (group 1 and group 6), presumably due to earlier changes in org-ts-regexp1. > I was using this in some code of mine, but I also realize that this doesn= =E2=80=99t > feel all that clean anyway. I am not sure if this is used elsewhere in org > though. I am currently working on an alternative concept of analyzing arbitrary org element components. Instead of named groups, I plan to provide named match groups: (progn (org-element-match 'timestamp) (org-element-match-data)) ((:minute-start 314 316) (:hour-start 311 313) (:day-start 304 306) (:month-start 301 303) (:year-start 296 300) (:date-start 296 316) (:timestamp-start 295 317) (:end-marker 316 317) (:begin-marker 295 296) (:full 295 317) (:full-no-blank 295 317) (:full-no-affiliated 295 317)) The current WIP implementation is in https://github.com/yantar92/org/blob/feature/org-font-lock-element/lisp/org= -element-match.el The match groups set by org-at-timestamp-p are currently being used by the following functions: org-mouse-delete-timestamp, org-follow-timestamp-link, org-time-stamp, org-toggle-timestamp-type However, all but one of them are only using group 0 and org-follow-timestamp-link is using group 1 as currently set by org-at-timestamp-p against the docstring. Best, Ihor --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-org-at-timestamp-p-Fix-invalid-regexp-groups-for-age.patch >From d9a5cb8b7d7b12aca389331f4817130420d2d744 Mon Sep 17 00:00:00 2001 Message-Id: From: Ihor Radchenko Date: Fri, 15 Apr 2022 15:05:39 +0800 Subject: [PATCH] org-at-timestamp-p: Fix invalid regexp groups for 'agenda scope * lisp/org.el (org-at-timestamp-p): Make sure that match groups follow the docstring in `agenda' scope. Update docstring explaining return values for sexp timestamps. Reported in https://orgmode.org/list/CAKJdtO8bqdbW5N6pRFNQRATjm2daEBDCpJj0njwcd4fmhSJSKQ@mail.gmail.com --- lisp/org.el | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 3cc8a5036..b736a3824 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -15248,20 +15248,24 @@ (defun org-at-timestamp-p (&optional extended) When at a timestamp, return the position of the point as a symbol among `bracket', `after', `year', `month', `hour', `minute', `day' or a number of character from the last know part of the -time stamp. +time stamp. If diary sexp timestamps, any point inside the timestamp +is considered `day' (i.e. only `bracket', `day', and `after' return +values are possible). When matching, the match groups are the following: - group 1: year - group 2: month - group 3: day number - group 4: day name + group 1: year, if any + group 2: month, if any + group 3: day number, if any + group 4: day name, if any group 5: hours, if any group 6: minutes, if any" - (let* ((regexp (if extended - (if (eq extended 'agenda) - org-element--timestamp-regexp - org-ts-regexp3) - org-ts-regexp2)) + (let* ((regexp + (if extended + (if (eq extended 'agenda) + (rx (or (regexp org-ts-regexp3) + (regexp org-element--timestamp-regexp))) + org-ts-regexp3) + org-ts-regexp2)) (pos (point)) (match? (let ((boundaries (org-in-regexp regexp))) -- 2.35.1 --=-=-=--