emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] ox-icalendar: Create export backend options for deadline/scheduled-summary-prefix defcustoms
@ 2022-11-07 14:32 Чернышов Илья
  2022-11-09  2:42 ` Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Чернышов Илья @ 2022-11-07 14:32 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 175 bytes --]

This patch will allow to customize `org-icalendar-deadline-summary-prefix',
`org-icalendar-scheduled-summary-prefix' directly in the `ext-plist' arg of
org-export-as function

[-- Attachment #1.2: Type: text/html, Size: 209 bytes --]

[-- Attachment #2: 0001-ox-icalendar-Create-export-backend-options-for-deadl.patch --]
[-- Type: text/x-patch, Size: 3640 bytes --]

From d666147f919c91b48988f7c90d66ea85e9f1faaa Mon Sep 17 00:00:00 2001
From: Ilya Chernyshov <ichernyshovvv@gmail.com>
Date: Mon, 7 Nov 2022 20:12:08 +0600
Subject: [PATCH] ox-icalendar: Create export backend options for
 deadline/scheduled-summary-prefix defcustoms

ox-icalendar.el (org-export-define-derived-backend):

Add export backend options:
:deadline-summary-prefix
:scheduled-summary-prefix

ox-icalendar.el (org-icalendar-entry):

Use :deadline-summary-prefix export backend option instead of
`org-icalendar-deadline-summary-prefix'. If the option is not
explicitly set, use the value of the custom variable.

Use :scheduled-summary-prefix export backend option instead of
`org-icalendar-scheduled-summary-prefix'. If the option is not
explicitly set, use the value of the custom variable.

Convert `deadline/scheduled-summary-prefix' string to iCal-compatible
format via `(org-icalendar-cleanup-string)'
---
 lisp/ox-icalendar.el | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/lisp/ox-icalendar.el b/lisp/ox-icalendar.el
index 6e4a9f21f..f4c904da4 100644
--- a/lisp/ox-icalendar.el
+++ b/lisp/ox-icalendar.el
@@ -332,7 +332,9 @@ re-read the iCalendar file.")
     (:icalendar-store-UID nil nil org-icalendar-store-UID)
     (:icalendar-timezone nil nil org-icalendar-timezone)
     (:icalendar-use-deadline nil nil org-icalendar-use-deadline)
-    (:icalendar-use-scheduled nil nil org-icalendar-use-scheduled))
+    (:icalendar-use-scheduled nil nil org-icalendar-use-scheduled)
+    (:icalendar-scheduled-summary-prefix nil nil org-icalendar-scheduled-summary-prefix)
+    (:icalendar-deadline-summary-prefix nil nil org-icalendar-deadline-summary-prefix))
   :filters-alist
   '((:filter-headline . org-icalendar-clear-blank-lines))
   :menu-entry
@@ -630,7 +632,9 @@ inlinetask within the section."
 	  ;; "VEVENT" component from scheduled, deadline, or any
 	  ;; timestamp in the entry.
 	  (let ((deadline (org-element-property :deadline entry))
-		(use-deadline (plist-get info :icalendar-use-deadline)))
+		(use-deadline (plist-get info :icalendar-use-deadline))
+                (deadline-summary-prefix (org-icalendar-cleanup-string
+                                          (plist-get info :icalendar-deadline-summary-prefix))))
 	    (and deadline
 		 (pcase todo-type
 		   (`todo (or (memq 'event-if-todo-not-done use-deadline)
@@ -639,10 +643,12 @@ inlinetask within the section."
 		   (_ (memq 'event-if-not-todo use-deadline)))
 		 (org-icalendar--vevent
 		  entry deadline (concat "DL-" uid)
-		  (concat org-icalendar-deadline-summary-prefix summary)
+		  (concat deadline-summary-prefix summary)
                   loc desc cat tz class)))
 	  (let ((scheduled (org-element-property :scheduled entry))
-		(use-scheduled (plist-get info :icalendar-use-scheduled)))
+		(use-scheduled (plist-get info :icalendar-use-scheduled))
+                (scheduled-summary-prefix (org-icalendar-cleanup-string
+                                           (plist-get info :icalendar-scheduled-summary-prefix))))
 	    (and scheduled
 		 (pcase todo-type
 		   (`todo (or (memq 'event-if-todo-not-done use-scheduled)
@@ -651,7 +657,7 @@ inlinetask within the section."
 		   (_ (memq 'event-if-not-todo use-scheduled)))
 		 (org-icalendar--vevent
 		  entry scheduled (concat "SC-" uid)
-		  (concat org-icalendar-scheduled-summary-prefix summary)
+		  (concat scheduled-summary-prefix summary)
                   loc desc cat tz class)))
 	  ;; When collecting plain timestamps from a headline and its
 	  ;; title, skip inlinetasks since collection will happen once
-- 
2.38.1


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

* Re: [PATCH] ox-icalendar: Create export backend options for deadline/scheduled-summary-prefix defcustoms
  2022-11-07 14:32 [PATCH] ox-icalendar: Create export backend options for deadline/scheduled-summary-prefix defcustoms Чернышов Илья
@ 2022-11-09  2:42 ` Ihor Radchenko
  2022-11-09 12:12   ` Ilya Chernyshov
  0 siblings, 1 reply; 4+ messages in thread
From: Ihor Radchenko @ 2022-11-09  2:42 UTC (permalink / raw)
  To: Чернышов Илья
  Cc: emacs-orgmode

Чернышов Илья <ichernyshovvv@gmail.com> writes:

> This patch will allow to customize `org-icalendar-deadline-summary-prefix',
> `org-icalendar-scheduled-summary-prefix' directly in the `ext-plist' arg of
> org-export-as function

Thanks!
The patch looks good.

Could you also update the relevant NEWS entry (New custom settings
=org-icalendar-scheduled-summary-prefix= and
=org-icalendar-deadline-summary-prefix=)?

-- 
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>


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

* Re: [PATCH] ox-icalendar: Create export backend options for deadline/scheduled-summary-prefix defcustoms
  2022-11-09  2:42 ` Ihor Radchenko
@ 2022-11-09 12:12   ` Ilya Chernyshov
  2022-11-10  2:43     ` Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Ilya Chernyshov @ 2022-11-09 12:12 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 821 bytes --]

Sending the updated patch.

On Wed, Nov 9, 2022 at 8:42 AM Ihor Radchenko <yantar92@posteo.net> wrote:

> Чернышов Илья <ichernyshovvv@gmail.com> writes:
>
> > This patch will allow to customize
> `org-icalendar-deadline-summary-prefix',
> > `org-icalendar-scheduled-summary-prefix' directly in the `ext-plist' arg
> of
> > org-export-as function
>
> Thanks!
> The patch looks good.
>
> Could you also update the relevant NEWS entry (New custom settings
> =org-icalendar-scheduled-summary-prefix= and
> =org-icalendar-deadline-summary-prefix=)?
>
> --
> 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>
>

[-- Attachment #1.2: Type: text/html, Size: 1471 bytes --]

[-- Attachment #2: 0001-ox-icalendar-Create-export-backend-options-for-deadl.patch --]
[-- Type: text/x-patch, Size: 4312 bytes --]

From 74cc1a6b879c1b856fdc9205b4e042582f658f6c Mon Sep 17 00:00:00 2001
From: Ilya Chernyshov <ichernyshovvv@gmail.com>
Date: Mon, 7 Nov 2022 20:12:08 +0600
Subject: [PATCH] ox-icalendar: Create export backend options for
 deadline/scheduled-summary-prefix defcustoms

ox-icalendar.el (org-export-define-derived-backend):

Add export backend options:
:deadline-summary-prefix
:scheduled-summary-prefix

ox-icalendar.el (org-icalendar-entry):

Use :deadline-summary-prefix export backend option instead of
`org-icalendar-deadline-summary-prefix'. If the option is not
explicitly set, use the value of the custom variable.

Use :scheduled-summary-prefix export backend option instead of
`org-icalendar-scheduled-summary-prefix'. If the option is not
explicitly set, use the value of the custom variable.

Convert `deadline/scheduled-summary-prefix' string to iCal-compatible
format via `(org-icalendar-cleanup-string)'
---
 etc/ORG-NEWS         |  5 +++++
 lisp/ox-icalendar.el | 16 +++++++++++-----
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index b542da34b..5943f1749 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -350,6 +350,11 @@ lines in ICS exports.  The customization can be used to disable
 the prefixes completely or make them a little bit more verbose
 (e.g. "Deadline: " instead of the default "DL: ").
 
+The same settings also can be applied via corresponding exporter
+options:
+=:icalendar-scheduled-summary-prefix=,
+=:icalendar-deadline-summary-prefix=
+
 *** A new custom setting =org-hide-drawer-startup= to control initial folding state of drawers
 
 Previously, all the drawers were always folded when opening an Org
diff --git a/lisp/ox-icalendar.el b/lisp/ox-icalendar.el
index 6e4a9f21f..f4c904da4 100644
--- a/lisp/ox-icalendar.el
+++ b/lisp/ox-icalendar.el
@@ -332,7 +332,9 @@ re-read the iCalendar file.")
     (:icalendar-store-UID nil nil org-icalendar-store-UID)
     (:icalendar-timezone nil nil org-icalendar-timezone)
     (:icalendar-use-deadline nil nil org-icalendar-use-deadline)
-    (:icalendar-use-scheduled nil nil org-icalendar-use-scheduled))
+    (:icalendar-use-scheduled nil nil org-icalendar-use-scheduled)
+    (:icalendar-scheduled-summary-prefix nil nil org-icalendar-scheduled-summary-prefix)
+    (:icalendar-deadline-summary-prefix nil nil org-icalendar-deadline-summary-prefix))
   :filters-alist
   '((:filter-headline . org-icalendar-clear-blank-lines))
   :menu-entry
@@ -630,7 +632,9 @@ inlinetask within the section."
 	  ;; "VEVENT" component from scheduled, deadline, or any
 	  ;; timestamp in the entry.
 	  (let ((deadline (org-element-property :deadline entry))
-		(use-deadline (plist-get info :icalendar-use-deadline)))
+		(use-deadline (plist-get info :icalendar-use-deadline))
+                (deadline-summary-prefix (org-icalendar-cleanup-string
+                                          (plist-get info :icalendar-deadline-summary-prefix))))
 	    (and deadline
 		 (pcase todo-type
 		   (`todo (or (memq 'event-if-todo-not-done use-deadline)
@@ -639,10 +643,12 @@ inlinetask within the section."
 		   (_ (memq 'event-if-not-todo use-deadline)))
 		 (org-icalendar--vevent
 		  entry deadline (concat "DL-" uid)
-		  (concat org-icalendar-deadline-summary-prefix summary)
+		  (concat deadline-summary-prefix summary)
                   loc desc cat tz class)))
 	  (let ((scheduled (org-element-property :scheduled entry))
-		(use-scheduled (plist-get info :icalendar-use-scheduled)))
+		(use-scheduled (plist-get info :icalendar-use-scheduled))
+                (scheduled-summary-prefix (org-icalendar-cleanup-string
+                                           (plist-get info :icalendar-scheduled-summary-prefix))))
 	    (and scheduled
 		 (pcase todo-type
 		   (`todo (or (memq 'event-if-todo-not-done use-scheduled)
@@ -651,7 +657,7 @@ inlinetask within the section."
 		   (_ (memq 'event-if-not-todo use-scheduled)))
 		 (org-icalendar--vevent
 		  entry scheduled (concat "SC-" uid)
-		  (concat org-icalendar-scheduled-summary-prefix summary)
+		  (concat scheduled-summary-prefix summary)
                   loc desc cat tz class)))
 	  ;; When collecting plain timestamps from a headline and its
 	  ;; title, skip inlinetasks since collection will happen once
-- 
2.38.1


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

* Re: [PATCH] ox-icalendar: Create export backend options for deadline/scheduled-summary-prefix defcustoms
  2022-11-09 12:12   ` Ilya Chernyshov
@ 2022-11-10  2:43     ` Ihor Radchenko
  0 siblings, 0 replies; 4+ messages in thread
From: Ihor Radchenko @ 2022-11-10  2:43 UTC (permalink / raw)
  To: Ilya Chernyshov; +Cc: emacs-orgmode

Ilya Chernyshov <ichernyshovvv@gmail.com> writes:

> Sending the updated patch.

Applied onto main with minor amendments.
I added TINYCHANGE cookie to the docstring.
I added double space "  " between sentences according to our conventions.
I also fixed word order in the NEWS entry.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=6c285af9fb591908578f8cfdc2aec980b4dbae0a

Thanks for your contribution!

You are now added to Org contributor list.
https://git.sr.ht/~bzg/worg/commit/0e93ede98773eb3ec81d3b030d3a2ca5921c89a8

-- 
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>


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

end of thread, other threads:[~2022-11-10  2:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-07 14:32 [PATCH] ox-icalendar: Create export backend options for deadline/scheduled-summary-prefix defcustoms Чернышов Илья
2022-11-09  2:42 ` Ihor Radchenko
2022-11-09 12:12   ` Ilya Chernyshov
2022-11-10  2:43     ` Ihor Radchenko

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).