emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] make 'org-at-date-range-p work like org-at-timestamp-p
@ 2019-03-15 21:13 Thomas Plass
  2019-03-18 21:43 ` Nicolas Goaziou
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Plass @ 2019-03-15 21:13 UTC (permalink / raw)
  To: emacs-orgmode

Hello maintainers,

it's counter-intuitive that 'org-at-date-range-p doesn't work like
'org-at-timestamp-p when point is on the leading bracket of a range.
Witness (^ = point)

<2019-12-30 Mo 12:00>
^ (org-at-timestamp-p)                            => t

<2019-12-30 Mo 12:00>--<2019-12-31 Di 09:00>
^ (org-at-timestamp-p)                            => t
 ^ (org-at-date-range-p)                          => t
^ (org-at-date-range-p)                           => nil

Is the attached patch OK?

Regards,

Thomas


From 11424a8a8f975148a6914ba324b7e34218fed30d Mon Sep 17 00:00:00 2001
From: Thomas Plass <thunk2@arcor.de>
Date: Fri, 15 Mar 2019 22:56:01 +0200
Subject: [PATCH] * make 'org-at-date-range-p work like org-at-timestamp-p  
 when point is on starting bracket

---
 lisp/org.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/org.el b/lisp/org.el
index 24e1549a2..2053ae6b7 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -10651,7 +10651,7 @@ on INACTIVE-OK."
   (save-excursion
     (catch 'exit
       (let ((pos (point)))
-	(skip-chars-backward "^[<\r\n")
+	(or (looking-at-p "[<[]") (skip-chars-backward "^[<\r\n"))
 	(skip-chars-backward "<[")
 	(and (looking-at (if inactive-ok org-tr-regexp-both org-tr-regexp))
 	     (>= (match-end 0) pos)
-- 
2.13.1.windows.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] make 'org-at-date-range-p work like org-at-timestamp-p
  2019-03-15 21:13 [PATCH] make 'org-at-date-range-p work like org-at-timestamp-p Thomas Plass
@ 2019-03-18 21:43 ` Nicolas Goaziou
  2019-03-19 19:46   ` Thomas Plass
  2019-03-19 19:49   ` Thomas Plass
  0 siblings, 2 replies; 5+ messages in thread
From: Nicolas Goaziou @ 2019-03-18 21:43 UTC (permalink / raw)
  To: Thomas Plass; +Cc: emacs-orgmode

Hello,

thunk2@arcor.de (Thomas Plass) writes:

> it's counter-intuitive that 'org-at-date-range-p doesn't work like
> 'org-at-timestamp-p when point is on the leading bracket of a range.
> Witness (^ = point)
>
> <2019-12-30 Mo 12:00>
> ^ (org-at-timestamp-p)                            => t
>
> <2019-12-30 Mo 12:00>--<2019-12-31 Di 09:00>
> ^ (org-at-timestamp-p)                            => t
>  ^ (org-at-date-range-p)                          => t
> ^ (org-at-date-range-p)                           => nil
>
> Is the attached patch OK?

Thank you.

I think the incompatibility is deeper than that. IMO,
`org-at-date-range-p' should obey to the same arguments as
`org-at-timestamp-p'. IOW, a rewrite is in order.

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] make 'org-at-date-range-p work like org-at-timestamp-p
  2019-03-18 21:43 ` Nicolas Goaziou
@ 2019-03-19 19:46   ` Thomas Plass
  2019-03-19 19:49   ` Thomas Plass
  1 sibling, 0 replies; 5+ messages in thread
From: Thomas Plass @ 2019-03-19 19:46 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode

Nicolas,

thanks for taking care.  But there's another thing.

I don't know what I've done to my Org buffer, but what look like
timestamps are a mixture of element types 'timestamp and 'planning.

Anyway, 'org-at-timestamp-p returns nil for the 'planning timestamps.
Which causes breakage.

Please take a look at the patch.  It could be that 'org-check-*-date
functions might also be affected by the same problem, I haven't
tested.

Regards

Thomas

From dda6f686e40663b1da3151686145cd125d1f88d1 Mon Sep 17 00:00:00 2001
From: Thomas Plass <thunk2@arcor.de>
Date: Tue, 19 Mar 2019 21:24:19 +0200
Subject: [PATCH] Check timestamp contexts for both element types
 'timestamp and 'planning.

---
 lisp/org.el | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index ee1082376..3f2e429dd 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -15178,10 +15178,10 @@ When matching, the match groups are the following:
 				  (and (bound-and-true-p
 					org-agenda-include-inactive-timestamps)
 				       (org-at-clock-log-p))))
-			 (eq 'timestamp
-			     (save-excursion
-			       (when (= pos (cdr boundaries)) (forward-char -1))
-			       (org-element-type (org-element-context)))))))))))
+			 (memq (save-excursion
+			         (when (= pos (cdr boundaries)) (forward-char -1))
+			         (org-element-type (org-element-context)))
+                               '(timestamp planning)))))))))
     (cond
      ((not match?)                        nil)
      ((= pos (match-beginning 0))         'bracket)
-- 
2.13.1.windows.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] make 'org-at-date-range-p work like org-at-timestamp-p
  2019-03-18 21:43 ` Nicolas Goaziou
  2019-03-19 19:46   ` Thomas Plass
@ 2019-03-19 19:49   ` Thomas Plass
  2019-03-19 20:28     ` Nicolas Goaziou
  1 sibling, 1 reply; 5+ messages in thread
From: Thomas Plass @ 2019-03-19 19:49 UTC (permalink / raw)
  To: emacs-orgmode

Nicolas,

thanks for taking care.  But there's another thing.

I don't know what I've done to my Org buffer, but what look like
timestamps are a mixture of element types 'timestamp and 'planning.

Anyway, 'org-at-timestamp-p returns nil for the 'planning timestamps.
Which causes breakage.

Please take a look at the patch.  It could be that 'org-check-*-date
functions might also be affected by the same problem, I haven't
tested.

Regards

Thomas

From dda6f686e40663b1da3151686145cd125d1f88d1 Mon Sep 17 00:00:00 2001
From: Thomas Plass <thunk2@arcor.de>
Date: Tue, 19 Mar 2019 21:24:19 +0200
Subject: [PATCH] Check timestamp contexts for both element types
 'timestamp and 'planning.

---
 lisp/org.el | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index ee1082376..3f2e429dd 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -15178,10 +15178,10 @@ When matching, the match groups are the following:
 				  (and (bound-and-true-p
 					org-agenda-include-inactive-timestamps)
 				       (org-at-clock-log-p))))
-			 (eq 'timestamp
-			     (save-excursion
-			       (when (= pos (cdr boundaries)) (forward-char -1))
-			       (org-element-type (org-element-context)))))))))))
+			 (memq (save-excursion
+			         (when (= pos (cdr boundaries)) (forward-char -1))
+			         (org-element-type (org-element-context)))
+                               '(timestamp planning)))))))))
     (cond
      ((not match?)                        nil)
      ((= pos (match-beginning 0))         'bracket)
-- 
2.13.1.windows.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] make 'org-at-date-range-p work like org-at-timestamp-p
  2019-03-19 19:49   ` Thomas Plass
@ 2019-03-19 20:28     ` Nicolas Goaziou
  0 siblings, 0 replies; 5+ messages in thread
From: Nicolas Goaziou @ 2019-03-19 20:28 UTC (permalink / raw)
  To: Thomas Plass; +Cc: emacs-orgmode

Hello,

thunk2@arcor.de (Thomas Plass) writes:

> I don't know what I've done to my Org buffer, but what look like
> timestamps are a mixture of element types 'timestamp and 'planning.
>
> Anyway, 'org-at-timestamp-p returns nil for the 'planning timestamps.
> Which causes breakage.

That behaviour is correct. Planning lines are not timestamps. See
`extended' parameter in `org-at-timestamp-p'.

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-03-19 20:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-15 21:13 [PATCH] make 'org-at-date-range-p work like org-at-timestamp-p Thomas Plass
2019-03-18 21:43 ` Nicolas Goaziou
2019-03-19 19:46   ` Thomas Plass
2019-03-19 19:49   ` Thomas Plass
2019-03-19 20:28     ` Nicolas Goaziou

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).