Re: [PATCH] lisp/org-expiry.el: Account for org-time-stamp-formats

2022-12-13 Thread Ihor Radchenko
Tom Gillespie  writes:

> Here's the rebased patch. It should apply without issue. Best!

Applied.
https://git.sr.ht/~bzg/org-contrib/commit/b6712e688b3a54c54b80ab34525d4672ff2a8d7a

Marcel, note that your recent patch has been overwritten. Let me know if
you have any objections.

Also, if you see no urgent issues with org-contrib, I plan to tag the
current master as requested in
https://orgmode.org/list/m28rjerx1t@purvis.id.au

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [PATCH] lisp/org-expiry.el: Account for org-time-stamp-formats

2022-12-12 Thread Tom Gillespie
Here's the rebased patch. It should apply without issue. Best!
Tom
From 5247d2459800f82434f1bc3aeea136c18af7923c Mon Sep 17 00:00:00 2001
From: Tom Gillespie 
Date: Sun, 4 Dec 2022 01:02:35 -0800
Subject: [PATCH] lisp/org-expiry.el: Account for org-time-stamp-formats
 refactor

* lisp/org-expiry.el (org-expiry-insert-created)
(org-expiry-insert-expiry): timestamp formats dropped delimiters so a
slight modification is required following org commit
e3a7c01874c9bb80e04ffa58c578619faf09e7f0, the change is made backward
compatible by removing < and > from the old timestamp format
---
 lisp/org-expiry.el | 32 +---
 1 file changed, 21 insertions(+), 11 deletions(-)

diff --git a/lisp/org-expiry.el b/lisp/org-expiry.el
index b359610..c3dad28 100644
--- a/lisp/org-expiry.el
+++ b/lisp/org-expiry.el
@@ -301,12 +301,17 @@ update the date."
 		 (current-time)))
   (setq d-hour (format-time-string "%H:%M" d-time))
   (setq timestr
-(org-expiry-format-timestamp
- ;; two C-u prefixes will call org-read-date
-	 (if (equal arg '(16))
-		 (org-read-date nil nil nil nil d-time d-hour)
-	   (format-time-string (cdr org-time-stamp-formats)))
- org-expiry-inactive-timestamps))
+	;; two C-u prefixes will call org-read-date
+(concat "<"
+(if (equal arg '(16))
+(org-read-date nil nil nil nil d-time d-hour)
+  (format-time-string
+   (replace-regexp-in-string "\\(^<\\|>$\\)" ""
+   (cdr org-time-stamp-formats
+">"))
+  ;; maybe transform to inactive timestamp
+  (if org-expiry-inactive-timestamps
+	  (setq timestr (concat "[" (substring timestr 1 -1) "]")))
   (save-excursion
 	(org-entry-put
 	 (point) org-expiry-created-property-name timestr)
@@ -321,11 +326,16 @@ and insert today's date."
 (setq d-time (if d (org-time-string-to-time d)
 		   (current-time)))
 (setq d-hour (format-time-string "%H:%M" d-time))
-(setq timestr (org-expiry-format-timestamp
-   (if today
-		   (format-time-string (cdr org-time-stamp-formats))
-		 (org-read-date nil nil nil nil d-time d-hour))
-   org-expiry-inactive-timestamps))
+(setq timestr (concat "<"
+  (if today
+  (format-time-string
+   (replace-regexp-in-string "\\(^<\\|>$\\)" ""
+   (cdr org-time-stamp-formats)))
+(org-read-date nil nil nil nil d-time d-hour))
+  ">"))
+;; maybe transform to inactive timestamp
+(if org-expiry-inactive-timestamps
+	(setq timestr (concat "[" (substring timestr 1 -1) "]")))
 
 (save-excursion
   (org-entry-put
-- 
2.37.4



Re: [PATCH] lisp/org-expiry.el: Account for org-time-stamp-formats

2022-12-12 Thread Ihor Radchenko
Tom Gillespie  writes:

> Looks like string-replace doesn't support that notation,
> so both too aggressive and without sufficient control.
> I've switched to replace-regexp-in-string which does
> what we want.
>
> Here's the updated patch.

Thanks!
Note that your patch does not apply onto master.
There is another recent patch attempting the same fix, but in less
general way. I can apply your patch if you adjust it to the current
master as your patch is going to be compatible with older Org as well.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [PATCH] lisp/org-expiry.el: Account for org-time-stamp-formats

2022-12-11 Thread Tom Gillespie
Looks like string-replace doesn't support that notation,
so both too aggressive and without sufficient control.
I've switched to replace-regexp-in-string which does
what we want.

Here's the updated patch.
From 12ca29965e867acd64fecaecd14f2f74e90d7e99 Mon Sep 17 00:00:00 2001
From: Tom Gillespie 
Date: Sun, 4 Dec 2022 01:02:35 -0800
Subject: [PATCH] lisp/org-expiry.el: Account for org-time-stamp-formats
 refactor

* lisp/org-expiry.el (org-expiry-insert-created)
(org-expiry-insert-expiry): timestamp formats dropped delimiters so a
slight modification is required following org commit
e3a7c01874c9bb80e04ffa58c578619faf09e7f0, the change is made backward
compatible by removing < and > from the old timestamp format
---
 lisp/org-expiry.el | 22 ++
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/lisp/org-expiry.el b/lisp/org-expiry.el
index 98ad58a..0462735 100644
--- a/lisp/org-expiry.el
+++ b/lisp/org-expiry.el
@@ -299,10 +299,13 @@ update the date."
   (setq d-hour (format-time-string "%H:%M" d-time))
   (setq timestr
 	;; two C-u prefixes will call org-read-date
-	(if (equal arg '(16))
-		(concat "<" (org-read-date
-			 nil nil nil nil d-time d-hour) ">")
-	  (format-time-string (cdr org-time-stamp-formats
+(concat "<"
+(if (equal arg '(16))
+(org-read-date nil nil nil nil d-time d-hour)
+  (format-time-string
+   (replace-regexp-in-string "\\(^<\\|>$\\)" ""
+   (cdr org-time-stamp-formats
+">"))
   ;; maybe transform to inactive timestamp
   (if org-expiry-inactive-timestamps
 	  (setq timestr (concat "[" (substring timestr 1 -1) "]")))
@@ -320,10 +323,13 @@ and insert today's date."
 (setq d-time (if d (org-time-string-to-time d)
 		   (current-time)))
 (setq d-hour (format-time-string "%H:%M" d-time))
-(setq timestr (if today
-		  (format-time-string (cdr org-time-stamp-formats))
-		(concat "<" (org-read-date
- nil nil nil nil d-time d-hour) ">")))
+(setq timestr (concat "<"
+  (if today
+  (format-time-string
+   (replace-regexp-in-string "\\(^<\\|>$\\)" ""
+   (cdr org-time-stamp-formats)))
+(org-read-date nil nil nil nil d-time d-hour))
+  ">"))
 ;; maybe transform to inactive timestamp
 (if org-expiry-inactive-timestamps
 	(setq timestr (concat "[" (substring timestr 1 -1) "]")))
-- 
2.37.4



Re: [PATCH] lisp/org-expiry.el: Account for org-time-stamp-formats

2022-12-11 Thread Ihor Radchenko
Tom Gillespie  writes:

> +  (format-time-string
> +   (string-replace "<" ""
> +   (string-replace ">" "" (cdr 
> org-time-stamp-formats)

`string-replace' is very aggressive. You may want something like "\\`<"
and "\\'>", matching only beginning/end of the string.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [PATCH] lisp/org-expiry.el: Account for org-time-stamp-formats

2022-12-10 Thread Tom Gillespie
Here is an updated patch. Best!
Tom

On Thu, Dec 8, 2022 at 3:42 AM Ihor Radchenko  wrote:
>
> Tom Gillespie  writes:
>
> > Hi,
> >Here is a patch for org-contrib/lisp/org-expiry.el to account for
> > recent changes to org-time-stamp-formats. Best,
> > Tom
> >
> > PS is this list still the best place to send org-contrib patches?
>
> Yes, this list is suitable as long as org-expiry is orphaned.
>
> For the patch, note that it is not a good idea to bump the minimal
> required Org version of Org 9.6. I'd rather suggest keeping backwards
> compatibility by stripping "<" and ">" from org-time-stamp-formats, if
> any. That will not affect existing users of older Emacs versions and
> built-in Org.
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at <https://orgmode.org/>.
> Support Org development at <https://liberapay.com/org-mode>,
> or support my work at <https://liberapay.com/yantar92>
From 248104955707a7195a594712d1c7ad9d64dee1c1 Mon Sep 17 00:00:00 2001
From: Tom Gillespie 
Date: Sun, 4 Dec 2022 01:02:35 -0800
Subject: [PATCH] lisp/org-expiry.el: Account for org-time-stamp-formats
 refactor

* lisp/org-expiry.el (org-expiry-insert-created)
(org-expiry-insert-expiry): timestamp formats dropped delimiters so a
slight modification is required following org commit
e3a7c01874c9bb80e04ffa58c578619faf09e7f0, the change is made backward
compatible by removing < and > from the old timestamp format
---
 lisp/org-expiry.el | 22 ++
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/lisp/org-expiry.el b/lisp/org-expiry.el
index 98ad58a..0909aaf 100644
--- a/lisp/org-expiry.el
+++ b/lisp/org-expiry.el
@@ -299,10 +299,13 @@ update the date."
   (setq d-hour (format-time-string "%H:%M" d-time))
   (setq timestr
 	;; two C-u prefixes will call org-read-date
-	(if (equal arg '(16))
-		(concat "<" (org-read-date
-			 nil nil nil nil d-time d-hour) ">")
-	  (format-time-string (cdr org-time-stamp-formats
+(concat "<"
+(if (equal arg '(16))
+(org-read-date nil nil nil nil d-time d-hour)
+  (format-time-string
+   (string-replace "<" ""
+   (string-replace ">" "" (cdr org-time-stamp-formats)
+">"))
   ;; maybe transform to inactive timestamp
   (if org-expiry-inactive-timestamps
 	  (setq timestr (concat "[" (substring timestr 1 -1) "]")))
@@ -320,10 +323,13 @@ and insert today's date."
 (setq d-time (if d (org-time-string-to-time d)
 		   (current-time)))
 (setq d-hour (format-time-string "%H:%M" d-time))
-(setq timestr (if today
-		  (format-time-string (cdr org-time-stamp-formats))
-		(concat "<" (org-read-date
- nil nil nil nil d-time d-hour) ">")))
+(setq timestr (concat "<"
+  (if today
+  (format-time-string
+   (string-replace "<" ""
+   (string-replace ">" "" (cdr org-time-stamp-formats
+(org-read-date nil nil nil nil d-time d-hour))
+  ">"))
 ;; maybe transform to inactive timestamp
 (if org-expiry-inactive-timestamps
 	(setq timestr (concat "[" (substring timestr 1 -1) "]")))
-- 
2.37.4



Re: [PATCH] lisp/org-expiry.el: Account for org-time-stamp-formats

2022-12-08 Thread Ihor Radchenko
Tom Gillespie  writes:

> Hi,
>Here is a patch for org-contrib/lisp/org-expiry.el to account for
> recent changes to org-time-stamp-formats. Best,
> Tom
>
> PS is this list still the best place to send org-contrib patches?

Yes, this list is suitable as long as org-expiry is orphaned.

For the patch, note that it is not a good idea to bump the minimal
required Org version of Org 9.6. I'd rather suggest keeping backwards
compatibility by stripping "<" and ">" from org-time-stamp-formats, if
any. That will not affect existing users of older Emacs versions and
built-in Org.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



[PATCH] lisp/org-expiry.el: Account for org-time-stamp-formats

2022-12-04 Thread Tom Gillespie
Hi,
   Here is a patch for org-contrib/lisp/org-expiry.el to account for
recent changes to org-time-stamp-formats. Best,
Tom

PS is this list still the best place to send org-contrib patches?
From 2408e92a9c5e155b55a374462d1314aabbe50fe0 Mon Sep 17 00:00:00 2001
From: Tom Gillespie 
Date: Sun, 4 Dec 2022 01:02:35 -0800
Subject: [PATCH] lisp/org-expiry.el: Account for org-time-stamp-formats
 refactor

* lisp/org-expiry.el (org-expiry-insert-created)
(org-expiry-insert-expiry): timestamp formats dropped delimiters so a
slight modification is required following org commit
e3a7c01874c9bb80e04ffa58c578619faf09e7f0, also bump version to 0.3 and
add a dependency on org 9.6 to ensure that the new version of
org-time-stamp-formats is present and users of older versions of org
will not accidentally load the new version
---
 lisp/org-expiry.el | 21 -
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/lisp/org-expiry.el b/lisp/org-expiry.el
index 98ad58a..d8d604b 100644
--- a/lisp/org-expiry.el
+++ b/lisp/org-expiry.el
@@ -3,9 +3,10 @@
 ;; Copyright 2007-2021 Free Software Foundation, Inc.
 ;;
 ;; Author: Bastien Guerry 
-;; Version: 0.2
+;; Version: 0.3
 ;; Keywords: org, expiry
 ;; Homepage: https://git.sr.ht/~bzg/org-contrib
+;; Package-Requires: ((org "9.6"))
 
 ;; This file is not part of GNU Emacs.
 
@@ -299,10 +300,11 @@ update the date."
   (setq d-hour (format-time-string "%H:%M" d-time))
   (setq timestr
 	;; two C-u prefixes will call org-read-date
-	(if (equal arg '(16))
-		(concat "<" (org-read-date
-			 nil nil nil nil d-time d-hour) ">")
-	  (format-time-string (cdr org-time-stamp-formats
+(concat "<"
+(if (equal arg '(16))
+(org-read-date nil nil nil nil d-time d-hour)
+  (format-time-string (cdr org-time-stamp-formats)))
+">"))
   ;; maybe transform to inactive timestamp
   (if org-expiry-inactive-timestamps
 	  (setq timestr (concat "[" (substring timestr 1 -1) "]")))
@@ -320,10 +322,11 @@ and insert today's date."
 (setq d-time (if d (org-time-string-to-time d)
 		   (current-time)))
 (setq d-hour (format-time-string "%H:%M" d-time))
-(setq timestr (if today
-		  (format-time-string (cdr org-time-stamp-formats))
-		(concat "<" (org-read-date
- nil nil nil nil d-time d-hour) ">")))
+(setq timestr (concat "<"
+  (if today
+  (format-time-string (cdr org-time-stamp-formats))
+(org-read-date nil nil nil nil d-time d-hour))
+  ">"))
 ;; maybe transform to inactive timestamp
 (if org-expiry-inactive-timestamps
 	(setq timestr (concat "[" (substring timestr 1 -1) "]")))
-- 
2.37.4