[PATCH] Fix formatting

2024-02-12 Thread Ilya Chernyshov

Hi, just wanted the code to be more elisp style guide compliant, so here's
a patch that adds spaces before opening parentheses.

>From 0d9b7ce6d5e83d7758566dab6a17642fdf4b9b73 Mon Sep 17 00:00:00 2001
From: Ilya Chernyshov 
Date: Mon, 12 Feb 2024 18:33:29 +0600
Subject: [PATCH] Fix formatting

* lisp/ob-haskell.el (org-babel-interpret-haskell):
* lisp/ol-bibtex.el (org-bibtex-store-link):
* lisp/ol.el (org-link--fontify-links-to-this-file):
* lisp/org-agenda.el (org-agenda-open-link):
(org-agenda-reapply-filters):
* lisp/org-element.el (org-element-timestamp-interpreter):
* lisp/org-macs.el (org-buffer-list):
* lisp/org-pcomplete.el (pcomplete/org-mode/block-option/src):

Fix formatting.
---
 lisp/ob-haskell.el| 2 +-
 lisp/ol-bibtex.el | 2 +-
 lisp/ol.el| 6 +++---
 lisp/org-agenda.el| 4 ++--
 lisp/org-element.el   | 2 +-
 lisp/org-macs.el  | 2 +-
 lisp/org-pcomplete.el | 2 +-
 7 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/lisp/ob-haskell.el b/lisp/ob-haskell.el
index 00be6d52c..178e08424 100644
--- a/lisp/ob-haskell.el
+++ b/lisp/ob-haskell.el
@@ -188,7 +188,7 @@ This function should only be called by `org-babel-execute:haskell'."
 (send-eoe)))
   ;; We now display and capture the value.
  (comint-with-output
-  (lambda()
+  (lambda ()
 (send-txt-to-ghci "__LAST_VALUE_IMPROBABLE_NAME__\n")
 (send-eoe))
  (results (mapcar #'org-strip-quotes
diff --git a/lisp/ol-bibtex.el b/lisp/ol-bibtex.el
index c5a950e2d..b7bfe3059 100644
--- a/lisp/ol-bibtex.el
+++ b/lisp/ol-bibtex.el
@@ -514,7 +514,7 @@ ARG, when non-nil, is a universal prefix argument.  See
 	   (link (concat "file:" (abbreviate-file-name buffer-file-name)
 			 "::" search))
 	   (entry (mapcar ; repair strings enclosed in "..." or {...}
-		   (lambda(c)
+		   (lambda (c)
 		 (if (string-match
 			  "^\\(?:{\\|\"\\)\\(.*\\)\\(?:}\\|\"\\)$" (cdr c))
 			 (cons (car c) (match-string 1 (cdr c))) c))
diff --git a/lisp/ol.el b/lisp/ol.el
index ef3e6addc..00bfaf13a 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -716,14 +716,14 @@ followed by another \"%[A-F0-9]{2}\" group."
 (defun org-link--fontify-links-to-this-file ()
   "Fontify links to the current file in `org-stored-links'."
   (let ((f (buffer-file-name)) a b)
-(setq a (mapcar (lambda(l)
+(setq a (mapcar (lambda (l)
 		  (let ((ll (car l)))
 			(when (and (string-match "^file:\\(.+\\)::" ll)
    (equal f (expand-file-name (match-string 1 ll
 			  ll)))
 		org-stored-links))
 (when (featurep 'org-id)
-  (setq b (mapcar (lambda(l)
+  (setq b (mapcar (lambda (l)
 			(let ((ll (car l)))
 			  (when (and (string-match "^id:\\(.+\\)$" ll)
  (equal f (expand-file-name
@@ -731,7 +731,7 @@ followed by another \"%[A-F0-9]{2}\" group."
 		(match-string 1 ll)) ""
 			ll)))
 		  org-stored-links)))
-(mapcar (lambda(l)
+(mapcar (lambda (l)
 	  (put-text-property 0 (length l) 'face 'font-lock-comment-face l))
 	(delq nil (append a b)
 
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 514359b62..121ac11f6 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -9469,7 +9469,7 @@ It also looks at the text of the entry itself."
 	 trg)
 (cond
  ((and buffer lk)
-  (mapcar (lambda(l)
+  (mapcar (lambda (l)
 		(with-current-buffer buffer
 		  (setq trg (and (string-match org-link-bracket-re l)
  (match-string 1 l)))
@@ -11000,7 +11000,7 @@ current HH:MM time."
 (defun org-agenda-reapply-filters ()
   "Re-apply all agenda filters."
   (mapcar
-   (lambda(f) (when (car f) (org-agenda-filter-apply (car f) (cadr f) t)))
+   (lambda (f) (when (car f) (org-agenda-filter-apply (car f) (cadr f) t)))
`((,org-agenda-tag-filter tag)
  (,org-agenda-category-filter category)
  (,org-agenda-regexp-filter regexp)
diff --git a/lisp/org-element.el b/lisp/org-element.el
index e6df9743a..b8e0fc6dc 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -4383,7 +4383,7 @@ Assume point is at the beginning of the timestamp."
 
 (defun org-element-timestamp-interpreter (timestamp _)
   "Interpret TIMESTAMP object as Org syntax."
-  (let((type (org-element-property :type timestamp)))
+  (let ((type (org-element-property :type timestamp)))
 (if (member type '(active inactive inactive-range active-range))
 (let ((day-start (org-element-property :day-start timestamp))
   (month-start (org-element-property :month-start timestamp))
diff --git a/lisp/org-macs.el b/lisp/org-macs.el
index f14323d23..f713f4b8f 100644
--- a/lisp/org-macs.el
+++ b/lisp/org-macs.el
@@ -336,7 +336,7 @@ If EXCLUDE

Re: [PATCH] testing: Delete duplicate tests

2024-02-09 Thread Ilya Chernyshov
Ihor Radchenko  writes:

> Note that your
> `test-org-tests/test-duplicates-detector-testing-find-duplicates' does
> not look right. I had to adjust the `equal' condition in order to make
> it pass. May you please check if the return value of
> `test-duplicates-detector--find-duplicates' is what you intended?

Yeah, now it works as it should. Thanks. I've made some minor changes
I've described in the attached patch.

>From 8bcd02bac32d3a4442814c2a42b097d642964372 Mon Sep 17 00:00:00 2001
From: Ilya Chernyshov 
Date: Fri, 9 Feb 2024 17:32:58 +0600
Subject: [PATCH] test-duplicates-detector.el: Simplify the docs, refactor,
 optimize the search

*
test-duplicates-detector.el (test-duplicates-detector-duplicate-forms):
Simplify the docstring.  Add that the list also may have information
about duplicate ert test definitions.

*
test-duplicates-detector.el (test-duplicates-detector--find-duplicates):
Don't go through a duplicate ert test definition.

*
test-duplicates-detector.el (test-duplicates-detector--search-forms-recursively):
Replace (car-safe sub-form) with (car sub-form) because we already
checked that sub-form is a cons.
---
 testing/lisp/test-duplicates-detector.el | 51 ++--
 1 file changed, 22 insertions(+), 29 deletions(-)

diff --git a/testing/lisp/test-duplicates-detector.el b/testing/lisp/test-duplicates-detector.el
index 25293f185..58da27c07 100644
--- a/testing/lisp/test-duplicates-detector.el
+++ b/testing/lisp/test-duplicates-detector.el
@@ -61,24 +61,19 @@ Immediate children inside these are not checked for duplicates.")
 (expand-file-name "lisp" org-test-dir) t "\\.el$")))
 
 (defvar test-duplicates-detector-duplicate-forms nil
-  "A nested list of the form:
+  "A list where each element is either:
 
-  (((file test-name [(form-1 . numerical-order)
- (form-2 . numerical-order) ...])
-(dup-form-1 . (numerical-order [numerical-order ...]))
-  [ (dup-form-2 . (numerical-order [numerical-order ...]))
-(dup-form-3 . (numerical-order [numerical-order ...]))
- ...])
-   
-   ((file test-name [(form-1 . numerical-order)
- (form-2 . numerical-order) ...])
+  ((file test-name [(form-1 . numerical-order)
+(form-2 . numerical-order) ...])
 (dup-form-1 . (numerical-order [numerical-order ...]))
   [ (dup-form-2 . (numerical-order [numerical-order ...]))
 (dup-form-3 . (numerical-order [numerical-order ...]))
  ...])
 
-   ...
-  )
+or
+
+  (test-1-symbol . duplicate-of-test-1-symbol)
+
 
 Where
 
@@ -88,31 +83,29 @@ Where
 is a path to duplicates.  For example, the path for the
 duplicates in the following test:
 
- test-ob-haskell-ghci.el
+ test-file.el
 
-  (ertdeftest ob-haskell/session-named-none-means-one-shot-sessions ()
-\"When no session, use a new session.
-  \"none\" is a special name that means `no session'.\"
+  (ertdeftest test-name ()
+\"Docstring.\"
 (let ((var-1 \"value\"))
  (when var-1
(should-not
-(equal 2 (test-ob-haskell-ghci \":session \"none\"\" \"x\" nil)))
-   (test-ob-haskell-ghci \":session none\" \"x=2\")
+(equal 2 (some-func \"string\" \"x\" nil)))
+   (some-func \"string\" \"x=2\")
(should-not
-(equal 2 (test-ob-haskell-ghci \":session \"none\"\" \"x\" nil)))
-   (test-ob-haskell-ghci \":session none\" \"x=2\"
+(equal 2 (some-func \"string\" \"x\" nil)))
+   (some-func \"string\" \"x=2\"
 
 would look like this:
 
-  (\"test-ob-haskell-ghci.el\"
-ob-haskell/session-named-none-means-one-shot-sessions
+  (\"/absolute/path/to/test-file.el\"
+test-name
 (let . 4) (when . 2))
 
 And the records about the duplicates would look like this:
 
-  ((test-ob-haskell-ghci \":session none\" \"x=2\") 5 3)
   ((should-not
-(equal 2 (test-ob-haskell-ghci \":session \"none\"\" \"x\" nil))) 4 2)")
+(equal 2 (some-func \"string\" \"x\" nil))) 4 2)")
 
 (defvar test-duplicates-detector-forms nil
   "Nested alist of found forms and paths to them (not filtered).")
@@ -168,9 +161,9 @@ Duplicate forms will be written to
   (cdddr x
 			 found-deftests)))
 (push (cons test-name (cadr f)) duplicate-tests)
-		  (push deftest found-deftests))
-		(test-duplicates-detector--search-forms-recursively
-		 deftest (list file (cadr deftest)
+		  (push deftest found-deftests)
+  (test-duplicates-detector--search-forms-recursively
+		   deftest (list file test-name)
 

Re: [PATCH] testing: Delete duplicate tests

2024-01-26 Thread Ilya Chernyshov
Ihor Radchenko  writes:

> What about the attached amendment?
> It should simplify things significantly.

Sorry, in my previous patch the test that checks the detector itself was not
even run in 'make test' because of incorrect test prefix.

Your patch does not work as you expect. Could you please revise it?

>From 6eb03414ac4eb8b64160b24dc7fcb805bf782310 Mon Sep 17 00:00:00 2001
From: Ihor Radchenko 
Date: Fri, 26 Jan 2024 14:21:55 +0100
Subject: [PATCH] test-duplicates-detector.el: Add correct prefix to the
 deftest, check if consp

*
testing/lisp/test-duplicates-detector.el (test-duplicates-detector--search-forms-recursively):

*
testing/lisp/test-duplicates-detector.el (test-org-tests/test-duplicates-detector-testing-find-duplicates):
Add correct prefix so that the test could be executed
---
 testing/lisp/test-duplicates-detector.el | 25 
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/testing/lisp/test-duplicates-detector.el b/testing/lisp/test-duplicates-detector.el
index d6f8aca5a..aed8034ee 100644
--- a/testing/lisp/test-duplicates-detector.el
+++ b/testing/lisp/test-duplicates-detector.el
@@ -231,22 +231,23 @@ FORM-PATH is list of the form:
 Write each form to `test-duplicates-detector-forms'"
   (let ((idx 0))
 (dolist (sub-form form)
-  (unless (memq (car-safe sub-form) test-duplicates-progn-forms)
-(push idx (alist-get
-		   sub-form
-   (alist-get form-path test-duplicates-detector-forms
-  nil nil #'equal)
-   nil nil #'equal-including-properties)))
-  (unless (memq (car-safe sub-form)
-		'(should-not should should-error))
-	(test-duplicates-detector--search-forms-recursively
- sub-form
- (append form-path (list (cons (car sub-form) idx)
+  (when (consp sub-form)
+(unless (memq (car-safe sub-form) test-duplicates-progn-forms)
+  (push idx (alist-get
+		 sub-form
+ (alist-get form-path test-duplicates-detector-forms
+nil nil #'equal)
+ nil nil #'equal-including-properties)))
+(unless (memq (car-safe sub-form)
+		  '(should-not should should-error))
+	  (test-duplicates-detector--search-forms-recursively
+   sub-form
+   (append form-path (list (cons (car-safe sub-form) idx))
   (cl-incf idx
 
  Testing the detector itself
 
-(ert-deftest test-duplicates-detector-testing-find-duplicates ()
+(ert-deftest test-org-tests/test-duplicates-detector-testing-find-duplicates ()
   "Test `test-duplicates-detector--find-duplicates'."
   (should
(equal
-- 
2.41.0



Re: [PATCH] testing: Delete duplicate tests

2024-01-23 Thread Ilya Chernyshov
Ihor Radchenko  writes:

> It has been a while since the last update in this thread.
> Ilya, do you need any help with the patch?

Hi, here is the updated patch.

>From 2385ba08a89f2966a6d71f92e8693e7def33e3fe Mon Sep 17 00:00:00 2001
From: Ilya Chernyshov 
Date: Mon, 22 Jan 2024 01:33:56 +0600
Subject: [PATCH] Add testing/lisp/test-duplicates-detector.el

* testing/lisp/test-duplicates-detector.el: Add test unit that checks for
duplicate ert-deftests and forms inside of them.

* testing/lisp/test-org.el (test-org/file-contents): Delete duplicate
`should-' form.

* testing/lisp/test-ob-lob.el (test-ob-lob/call-with-header-arguments,
test-ob-lob/do-not-eval-lob-lines-in-example-blocks-on-export,
test-ob-lob/caching-call-line, test-ob-lob/named-caching-call-line,
test-ob/just-one-results-block): Ignore duplicate forms via
`org-test-ignore-duplicate'

* testing/lisp/test-ob.el (test-ob/just-one-results-block): Ignore
duplicate forms via `org-test-ignore-duplicate'

* testing/lisp/test-ob-R.el (test-ob-R/results-file): Ignore
duplicate forms via `org-test-ignore-duplicate'.

* testing/lisp/test-ob-haskell-ghci.el (ob-haskell/session-named-none-means-one-shot-sessions): Ignore
duplicate forms via `org-test-ignore-duplicate'.

* testing/lisp/test-ob.el
(test-ob/inline-src_blk-default-results-replace-line-1,
test-ob/inline-src_blk-default-results-replace-line-2,
test-ob/inline-src_blk-manual-results-replace,
test-ob/inline-src_blk-results-silent, test-ob/just-one-results-block,
test-ob/remove-inline-result, test-ob/goto-named-src-block): Ignore
duplicate forms via `org-test-ignore-duplicate'.

* testing/lisp/test-org-agenda.el (test-org-agenda/property-timestamp,
test-org-agenda/sticky-agenda-filter-preset): Ignore
duplicate forms via `org-test-ignore-duplicate'

* testing/lisp/test-org-element.el (test-org-element/cache-headline):
Ignore duplicate forms via `org-test-ignore-duplicate'

* testing/lisp/test-org-fold.el (test-org-fold/set-visibility-according-to-property): Ignore duplicate
forms via `org-test-ignore-duplicate'

* testing/lisp/test-org-list.el (test-org-list/list-navigation,
test-org-list/move-item-down, test-org-list/move-item-up): Ignore duplicate
forms via `org-test-ignore-duplicate'

* testing/lisp/test-org-src.el (test-org-src/basic): Ignore duplicate
forms via `org-test-ignore-duplicate'

* testing/lisp/test-org-table.el (test-org-table/org-at-TBLFM-p,
test-org-table/org-table-TBLFM-begin,
test-org-table/org-table-TBLFM-begin-for-multiple-TBLFM-lines,
test-org-table/org-table-TBLFM-begin-for-pultiple-TBLFM-lines-blocks):
Ignore duplicate forms via `org-test-ignore-duplicate'

* testing/lisp/test-org.el (test-org/goto-sibling,
test-org/backward-element, test-org/up-element,
test-org/org-ctrl-c-ctrl-c, test-org/forward-element): Ignore duplicate
forms via `org-test-ignore-duplicate'
---
 testing/lisp/test-duplicates-detector.el | 316 +++
 testing/lisp/test-ob-R.el|   5 +-
 testing/lisp/test-ob-haskell-ghci.el |   3 +-
 testing/lisp/test-ob-lob.el  |  87 ---
 testing/lisp/test-ob.el  | 113 
 testing/lisp/test-ol.el  |  35 +--
 testing/lisp/test-org-agenda.el  |   9 +-
 testing/lisp/test-org-element.el |  18 +-
 testing/lisp/test-org-fold.el|  29 ++-
 testing/lisp/test-org-list.el|  31 ++-
 testing/lisp/test-org-src.el |   3 +-
 testing/lisp/test-org-table.el   | 117 -
 testing/lisp/test-org.el |  38 ++-
 13 files changed, 568 insertions(+), 236 deletions(-)
 create mode 100644 testing/lisp/test-duplicates-detector.el

diff --git a/testing/lisp/test-duplicates-detector.el b/testing/lisp/test-duplicates-detector.el
new file mode 100644
index 0..d39092a9e
--- /dev/null
+++ b/testing/lisp/test-duplicates-detector.el
@@ -0,0 +1,316 @@
+;;; test-duplicates-detector.el --- Tests for finding duplicates in Org tests  -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2023  Ilya Chernyshov
+;; Authors: Ilya Chernyshov 
+
+;; This file is not part of GNU Emacs.
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
+;;
+;;; Commentary:
+
+;; Unit tests that check for duplicate forms and tests in all Org test files.
+
+;; Forms are considered duplicate if they:
+
+;; 1. are `equal-including-properties',
+;; 2. have t

org-agenda: setting face to an item by its tag/category/property

2023-11-16 Thread Ilya Chernyshov


Hi.

Is there a custom variable in org-agenda that allows to set a specific
face (or just foreground/background) for items with specific
property/tag/category?



Re: [PATCH] testing: Delete duplicate tests

2023-11-16 Thread Ilya Chernyshov
Ilya Chernyshov  writes:

> Sure, here it is. In the patch, I added a new file
> (testing/lisp/test-deduplicator.el) with a test that checks for
> duplicate forms (not just should, should-not, should-error macros) in
> all test files.

It also makes sense to add a test that searches for completely equal
`ert-deftest' definitions and tests with equal bodies, but different
names, as you already advised on Matrix. Any other thoughts?



Re: [PATCH] testing: Delete duplicate tests

2023-11-11 Thread Ilya Chernyshov
Ihor Radchenko  writes:

> I saw you using your function to detect the existing duplicate tests.
> However, it would also be nice to add it as a test of its own to detect
> duplicates in future. WDYT?

Sure, here it is. In the patch, I added a new file
(testing/lisp/test-deduplicator.el) with a test that checks for
duplicate forms (not just should, should-not, should-error macros) in
all test files.

Changes in other files serve as an example of how to use
`org-test-ignore-duplicate' to make sure that the test deduplicator
skips certain duplicate forms.

There's a lot of tests to change before merging. I'll handle them and
submit a new patch if you have no questions about the code.

>From 3b38450f7de8bd168d8795728454d9f4db720843 Mon Sep 17 00:00:00 2001
From: Ilya Chernyshov 
Date: Tue, 5 Sep 2023 22:40:59 +0700
Subject: [PATCH] testing: Add testing/lisp/test-deduplicator.el

* testing/lisp/test-deduplicator.el: Add test unit that checks for
duplicate forms in ert tests.

* testing/lisp/test-ob-lob.el (test-ob-lob/caching-call-line,
test-ob-lob/named-caching-call-line, test-ob/just-one-results-block):
Ignore duplicate forms via `org-test-ignore-duplicate'

* testing/lisp/test-ob.el (test-ob/just-one-results-block): Ignore
duplicate forms via `org-test-ignore-duplicate'

* testing/lisp/test-org.el (test-org/goto-sibling,
test-org/backward-element, test-org/up-element): Ignore duplicate
forms via `org-test-ignore-duplicate'
---
 testing/lisp/test-deduplicator.el | 224 ++
 testing/lisp/test-ob-lob.el   |  10 +-
 testing/lisp/test-ob.el   |   3 +-
 testing/lisp/test-org.el  |  81 ++-
 4 files changed, 275 insertions(+), 43 deletions(-)
 create mode 100644 testing/lisp/test-deduplicator.el

diff --git a/testing/lisp/test-deduplicator.el b/testing/lisp/test-deduplicator.el
new file mode 100644
index 0..28b5d66f0
--- /dev/null
+++ b/testing/lisp/test-deduplicator.el
@@ -0,0 +1,224 @@
+;;; test-deduplicator.el --- Tests for finding duplicates in Org tests  -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2023  Ilya Chernyshov
+;; Authors: Ilya Chernyshov 
+
+;; This file is not part of GNU Emacs.
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
+;;
+;;; Commentary:
+
+;; Unit tests that check for duplicate forms (including `should',
+;; `should-not', `should-error') in all Org test files.  Forms are
+;; considered duplicate if they are `equal-including-properties' and
+;; nested at the same level.  To ignore a form or a group of forms,
+;; wrap them in `org-test-ignore-duplicate'.
+
+;;; Code:
+
+(require 'org-test "../testing/org-test")
+
+(defvar test-deduplicator-files
+  (directory-files (expand-file-name "lisp" org-test-dir) t "\\.el$"))
+
+(defvar test-deduplicator-duplicate-forms nil
+  "A nested list of the form:
+
+  (((file test-name [(form-1 . numerical-order)
+ (form-2 . numerical-order) ...])
+(dup-form-1 . (numerical-order [numerical-order ...]))
+  [ (dup-form-2 . (numerical-order [numerical-order ...]))
+(dup-form-3 . (numerical-order [numerical-order ...]))
+ ...])
+   
+   ((file test-name [(form-1 . numerical-order)
+ (form-2 . numerical-order) ...])
+(dup-form-1 . (numerical-order [numerical-order ...]))
+  [ (dup-form-2 . (numerical-order [numerical-order ...]))
+(dup-form-3 . (numerical-order [numerical-order ...]))
+ ...])
+
+   ...
+  )
+
+Where
+
+  (file test-name [(form-1 . numerical-order)
+   (form-2 . numerical-order) ...])
+
+is a path to duplicates.  For example, the path for the
+duplicates in the following test:
+
+ test-ob-haskell-ghci.el
+
+  (ertdeftest ob-haskell/session-named-none-means-one-shot-sessions ()
+\"When no session, use a new session.
+  \"none\" is a special name that means `no session'.\"
+(let ((var-1 \"value\"))
+ (when var-1
+   (should-not (equal 2 (test-ob-haskell-ghci \":session \"none\"\" \"x\" nil)))
+   (test-ob-haskell-ghci \":session none\" \"x=2\")
+   (should-not (equal 2 (test-ob-haskell-ghci \":session \"none\"\" \"x\" nil)))
+   (test-ob-haskell-ghci \":s

Logging previous SCHEDULED property before changing TODO state of a habit

2023-10-09 Thread Ilya Chernyshov


Hi.

Is there anything I can do with my Org config so that every time I
change the TODO state of my habit (example below), Org logs inactive
timestamp from SCHEDULED property before TODO state change?

For example, I have this habit, which I have been forgetting to mark as
DONE/MISSED/WHATEVER for the past several days:


* TODO heading
SCHEDULED: <2023-10-05 Thu +1d>
:PROPERTIES:
:CREATED:  [2023-10-01 Sun 01:25]
:END:


Now, I want Org to log when I done the task and when I missed it, but
instead it inserts the timestamp of current time:


* TODO heading
SCHEDULED: <2023-10-08 Sun +1d>
:PROPERTIES:
:CREATED:  [2023-10-01 Sun 01:25]
:LAST_REPEAT: [2023-10-10 Tue 02:08]
:END:
:LOGBOOK:
- State "DONE"   from "TODO"   [2023-10-10 Tue 02:08]
- State "MISSED" from "TODO"   [2023-10-10 Tue 02:08]
- State "DONE"   from "TODO"   [2023-10-10 Tue 02:08]
:END:


What I want to get instead is:


* TODO heading
SCHEDULED: <2023-10-08 Sun +1d>
:PROPERTIES:
:CREATED:  [2023-10-01 Sun 01:25]
:LAST_REPEAT: [2023-10-10 Tue 02:08]
:END:
:LOGBOOK:
- State "DONE"   from "TODO"   [2023-10-08 Sun]
- State "MISSED" from "TODO"   [2023-10-07 Sat]
- State "DONE"   from "TODO"   [2023-10-06 Fri]
:END:


It would be awesome, if there was a placeholder in org-log-note-headings
(for example "%e") that is replaced with previous SCHEDULED
timestamp. Can we do that? Or is there a better option to achieve that?



[PATCH] testing: Delete useless ert tests

2023-09-16 Thread Ilya Chernyshov

Hi!

I applied my ert test deduplicator on org tests and found some useless tests
which you can see in the patch.

>From 32d83fc5b2ad076dcd8681434a46b4117ac23858 Mon Sep 17 00:00:00 2001
From: Ilya Chernyshov 
Date: Sun, 17 Sep 2023 02:33:51 +0700
Subject: [PATCH] testing: Delete useless ert tests

* testing/lisp/test-ob-C.el: Delete useless test.

* testing/lisp/test-ob-fortran.el: Delete useless test.

* testing/lisp/test-ob-lilypond.el: Delete useless test.

* testing/lisp/test-ob-maxima.el: Delete useless test.
---
 testing/lisp/test-ob-C.el| 3 ---
 testing/lisp/test-ob-fortran.el  | 3 ---
 testing/lisp/test-ob-lilypond.el | 3 ---
 testing/lisp/test-ob-maxima.el   | 3 ---
 4 files changed, 12 deletions(-)

diff --git a/testing/lisp/test-ob-C.el b/testing/lisp/test-ob-C.el
index 8546a48dd..c70534a51 100644
--- a/testing/lisp/test-ob-C.el
+++ b/testing/lisp/test-ob-C.el
@@ -22,9 +22,6 @@
 (unless (featurep 'ob-C)
   (signal 'missing-test-dependency "Support for C code blocks"))
 
-(ert-deftest ob-C/assert ()
-  (should t))
-
 (ert-deftest ob-C/simple-program ()
   "Hello world program."
   (if (executable-find org-babel-C++-compiler)
diff --git a/testing/lisp/test-ob-fortran.el b/testing/lisp/test-ob-fortran.el
index 3bff7b9c4..4947d142b 100644
--- a/testing/lisp/test-ob-fortran.el
+++ b/testing/lisp/test-ob-fortran.el
@@ -23,9 +23,6 @@
 (unless (featurep 'ob-fortran)
   (signal 'missing-test-dependency "Support for Fortran code blocks"))
 
-(ert-deftest ob-fortran/assert ()
-  (should t))
-
 (ert-deftest ob-fortran/simple-program ()
   "Test of hello world program."
   (org-test-at-id "459384e8-1797-4f11-867e-dde0473ea7cc"
diff --git a/testing/lisp/test-ob-lilypond.el b/testing/lisp/test-ob-lilypond.el
index 5f439793b..49a61fcab 100644
--- a/testing/lisp/test-ob-lilypond.el
+++ b/testing/lisp/test-ob-lilypond.el
@@ -26,9 +26,6 @@
 (file-name-directory
  (or load-file-name (buffer-file-name)
 
-(ert-deftest ob-lilypond/assert ()
-  (should t))
-
 (ert-deftest ob-lilypond/feature-provision ()
   (should (featurep 'ob-lilypond)))
 
diff --git a/testing/lisp/test-ob-maxima.el b/testing/lisp/test-ob-maxima.el
index e2433d232..ae9fdc775 100644
--- a/testing/lisp/test-ob-maxima.el
+++ b/testing/lisp/test-ob-maxima.el
@@ -22,9 +22,6 @@
 (unless (featurep 'ob-maxima)
   (signal 'missing-test-dependency "Support for Maxima code blocks"))
 
-(ert-deftest ob-maxima/assert ()
-  (should t))
-
 (ert-deftest ob-maxima/integer-input ()
   "Test of integer input"
   (org-test-at-id "b5842ed4-8e8b-4b18-a1c9-cef006b6a6c8"
-- 
2.41.0



Re: [ANN] org-timeblock: Multi-day views

2023-09-05 Thread Ilya Chernyshov
"Dr. Arne Babenhauserheide"  writes:

Hi

> I started using this, and it’s great! Thank you!

Nice to hear!

> I also found an edge case: I have a deadline set to 23:59, and that
> deadline is only visible in the timeblocks when I only have that task in
> and switch to hiding all hours before the task (then 23:00 to 0:00 is
> large enough that the task shows at the end).

Fixed with https://github.com/ichernyshovvv/org-timeblock/commit/fd60ce1

Thank you for noticing it. Please update the package and check if
everything is ok.



Re: [PATCH] testing: Delete duplicate tests

2023-08-31 Thread Ilya Chernyshov
Ihor Radchenko  writes:

> I have re-introduced the new tests in place of the removed ones,
> according to my and Max's findings. On top of the patch.
>
> Applied, onto main.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=fe85d61a9
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=173b5de0e

Thank you! If a function that checks for duplicate tests is a welcome
addition to org tests, I'll send is as a patch. What do you think?



Re: [ANM] org-timeblock: Schedule your day visually, using timeblocking technique inside Emacs

2023-08-30 Thread Ilya Chernyshov
"Dr. Arne Babenhauserheide"  writes:

> Wow, that looks nice!

Thank you!

>
> If you want to provide a print-export (i.e. for hanging on the door of a
> lecture room), you could see whether it’s easy to translate it to a
> latex time table like this:
> https://hg.sr.ht/~arnebab/stundenplan-wochenplan/browse/stundenplan-7days.tex?rev=tip
> https://www.draketo.de/software/stundenplan.pdf
> https://www.draketo.de/software/stundenplan-wochenplan-latex

I don't understand why I need latex for this. Today I added command
org-timeblock-write (bound to [w]) which you can use now to write
org-timeblock buffer to SVG|PDF|PNG file. However, inkscape has to be
installed in your system.



[ANN] org-timeblock: Multi-day views

2023-08-29 Thread Ilya Chernyshov


[Changed the subject]



Re: [ANM] org-timeblock: Schedule your day visually, using timeblocking technique inside Emacs

2023-08-29 Thread Ilya Chernyshov
Ilya Chernyshov  writes:

> Hi! I wrote a package that provides interactive day view for orgmode
> tasks. With this package you can visually understand your day schedule
> and quickly reschedule your tasks and events. Essentially, this is what
> modern calendars provide, although my package currently only provides
> day view.

Hi

Recently, I implemented multi-day views feature for org-timeblock. You
can now choose the number of days (1-7) displayed via command
org-timeblock-switch-view. Here's a screenshot:

https://raw.githubusercontent.com/ichernyshovvv/org-timeblock/master/screenshots/multi-day-view.png

Quick video demo of multi-day views: https://www.youtube.com/watch?v=aOkRw03Wg3o

Link: https://github.com/ichernyshovvv/org-timeblock



Re: [ANM] org-timeblock: Schedule your day visually, using timeblocking technique inside Emacs

2023-08-10 Thread Ilya Chernyshov
"Fraga, Eric"  writes:

> I have tried again and now it installs.  Thank you.  I do get many
> errors when trying to navigate to different dates and/or scroll up/down
> in the current date being viewed.
>
> For instance, I get the following in trying org-timeblock a second time
> in the current Emacs:

You are not the first person getting this type of error on Emacs 30. I
don't have any suggestion for you except suggesting release versions of
Emacs (28 or 29). Currently, I'm not planning to maintain the package for master
branch. If you use straight.el though, you can use develop branch of
it. Maybe it'll fix the error.



Re: [ANM] org-timeblock: Schedule your day visually, using timeblocking technique inside Emacs

2023-08-10 Thread Ilya Chernyshov
"Fraga, Eric"  writes:

> Hi,
>
> I'm late to this and I don't have the full thread on my system so
> apologies if this has been asked before.
>
> When I try
>
> M-x package-vc-install RET https://github.com/ichernyshovvv/org-timeblock/
>
> according to the instructions given at the gitlab repository, I get an
> error:
>
> --8<---cut here---start->8---
> Debugger entered--Lisp error: (error "Version must be a string")
>   error("Version must be a string")
>   version-to-list((0))

Hi

You got this error because in the Package-Requires header of the package
there were packages without explicitly set versions. Maybe it's a bug, I
don't know. As far as I know, it's acceptable to not define specific
version of a dependency. Anyway, I've fixed that issue in the last
commit. Please, try again.



Re: [ANM] org-timeblock: Schedule your day visually, using timeblocking technique inside Emacs

2023-08-10 Thread Ilya Chernyshov
"Fraga, Eric"  writes:

> Hi,
>
> I'm late to this and I don't have the full thread on my system so
> apologies if this has been asked before.
>
> When I try
>
> M-x package-vc-install RET https://github.com/ichernyshovvv/org-timeblock/
>
> according to the instructions given at the gitlab repository, I get an
> error:
>
> --8<---cut here---start->8---
> Debugger entered--Lisp error: (error "Version must be a string")
>   error("Version must be a string")
>   version-to-list((0))

Hi

You got this error because in the Package-Requires header of the package
there were packages without explicitly set versions. Maybe it's a bug, I
don't know. As far as I know, it's acceptable to not define specific
version of a dependency. Anyway, I've fixed that issue in the last
commit. Please, try again.



Re: [ANM] org-timeblock: Schedule your day visually, using timeblocking technique inside Emacs

2023-08-09 Thread Ilya Chernyshov
Ihor Radchenko  writes:

> Thanks for sharing!
>
> As I mentioned in Matrix chat, it would be nice if you could integrate
> the svg image display into Org agenda as minor mode, displaying the
> interactive svg in place of the time grid. That would be a welcome
> addition to Org core.

It's a great idea. I see that the package could provide minor
and major modes. The minor mode could provide an interactive sliced SVG
image inside org-agenda buffer and the major mode might be implemented in
the same way it's implemented in the package.

I would be interested to hear other devs' opinion on that.



[ANM] org-timeblock: Schedule your day visually, using timeblocking technique inside Emacs

2023-07-31 Thread Ilya Chernyshov


Hi! I wrote a package that provides interactive day view for orgmode
tasks. With this package you can visually understand your day schedule
and quickly reschedule your tasks and events. Essentially, this is what
modern calendars provide, although my package currently only provides
day view.

The package works entirely inside Emacs.

https://github.com/ichernyshovvv/org-timeblock/

A couple of screenshots:

1. 
https://github.com/ichernyshovvv/org-timeblock/raw/master/screenshots/org-timeblock.png
2. 
https://github.com/ichernyshovvv/org-timeblock/raw/master/screenshots/org-timeblock-with-list.png

Screencast. The video itself merely shows how the package works and how
one could quickly operate on his day plan. So, it's not so
informative. See README file in the repo to find out how to start using
it.

https://www.youtube.com/watch?v=tuMcPotV71I

If you have any suggestions, ideas or whatever, please leave comments
here or post on github issues. Also, pull requests are welcome.




[PATCH] testing: Delete duplicate tests

2023-07-12 Thread Ilya Chernyshov

Hello.

In my last patch, I found a duplicate test, so I decided to find all of
the duplicate tests inside testing/lisp/ folder via this function:

(defun count-duplicate-tests ( directory)
  (let (files)
(dolist (file (directory-files (or directory default-directory) t (rx ".el" 
string-end) t))
  (with-current-buffer (find-file-noselect file)
(save-excursion
  (goto-char (point-min))
  (while (search-forward "(ert-deftest" nil t)
(ignore-errors
  (while-let((form (or (read (current-buffer)) t)))
(when (eq (car-safe form) 'should)
  (setf
   (alist-get form (alist-get file files nil nil #'equal) 0 nil 
#'equal)
   (1+ (alist-get form (alist-get file files nil nil #'equal) 0 
nil #'equal))
(seq-remove
 (lambda(file) (null (cdr file)))
 (mapcar
  (lambda(file)
(cons
 (car file)
 (seq-filter
  (lambda(form) (/= (cdr form) 1))
  (cdr file
  files

(setq dups (count-duplicate-tests "~/org-mode/testing/lisp/"))

Then I checked the result manually and deleted some of them.

Here is the patch I wrote:

>From 21ba128bd648c6737ed088abdd2a1824cfe01759 Mon Sep 17 00:00:00 2001
From: Ilya Chernyshov 
Date: Thu, 13 Jul 2023 01:36:33 +0700
Subject: [PATCH] testing: Delete duplicate tests

* testing/lisp/test-ol.el (test-org-link/store-link): Delete a duplicate test.

* testing/lisp/test-org-clock.el (test-org-clock/clocktable/properties): Delete a duplicate test.

* testing/lisp/test-org-element.el (test-org-element/link-parser,
test-org-element/timestamp-parser): Delete duplicate tests.

* testing/lisp/test-org-table.el (test-org-table/get-field): Delete a duplicate test.

* testing/lisp/test-org.el (test-org/auto-fill-function): Delete a duplicate test.
---
 testing/lisp/test-ol.el  |  8 
 testing/lisp/test-org-clock.el   | 15 ---
 testing/lisp/test-org-element.el | 10 --
 testing/lisp/test-org-table.el   |  4 
 testing/lisp/test-org.el |  8 
 5 files changed, 45 deletions(-)

diff --git a/testing/lisp/test-ol.el b/testing/lisp/test-ol.el
index a38d9f979..70be03818 100644
--- a/testing/lisp/test-ol.el
+++ b/testing/lisp/test-ol.el
@@ -301,14 +301,6 @@ See https://github.com/yantar92/org/issues/4.;
(let ((file (buffer-file-name)))
 	 (equal (format "[[file:%s::two]]" file file)
 		(org-store-link nil))
-  (should
-   (let ((org-stored-links nil)
-	 (org-context-in-file-links t))
- (org-test-with-temp-text-in-file "# two"
-   (fundamental-mode)
-   (let ((file (buffer-file-name)))
-	 (equal (format "[[file:%s::two]]" file file)
-		(org-store-link nil))
   (should
(let ((org-stored-links nil)
 	 (org-context-in-file-links t))
diff --git a/testing/lisp/test-org-clock.el b/testing/lisp/test-org-clock.el
index d40939eb6..16cfc63a5 100644
--- a/testing/lisp/test-org-clock.el
+++ b/testing/lisp/test-org-clock.el
@@ -821,21 +821,6 @@ CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00
 :PROPERTIES:
 :A: 1
 :END:
-CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
-  (test-org-clock-clocktable-contents ":properties (\"A\")"
-  ;; Handle missing properties.
-  (should
-   (equal
-"| A | Headline | Time|
-|---+--+-|
-|   | *Total time* | *26:00* |
-|---+--+-|
-| 1 | Foo  | 26:00   |"
-(org-test-with-temp-text
-"* Foo
-:PROPERTIES:
-:A: 1
-:END:
 CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
   (test-org-clock-clocktable-contents ":properties (\"A\")")
 
diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el
index 2e3a249ab..d95195f0d 100644
--- a/testing/lisp/test-org-element.el
+++ b/testing/lisp/test-org-element.el
@@ -2436,11 +2436,6 @@ e^{i\\pi}+1=0
  (let ((file (expand-file-name (buffer-file-name
(insert (format "[[file:%s]]" file))
(equal (org-element-property :path (org-element-context)) file
-  (should
-   (org-test-with-temp-text-in-file ""
- (let ((file (expand-file-name (buffer-file-name
-   (insert (format "[[file:%s]]" file))
-   (equal (org-element-property :path (org-element-context)) file
   ;; ... multi-line link.
   (should
(equal "ls *.org"
@@ -3195,11 +3190,6 @@ Outside list"
 (org-test-with-temp-text "<2023-07-02 Sun 12:00>--<2023-07-02 Sun 13:00>"
   (org-element-property :range-type (org-element-timestamp-parser)))
 'daterange))
-  (should
-   (eq
-(org-test-with-temp-text "<2023-07-02 Sun 12:00>--<2023-07-02 Sun>"
-  (org-element-property :range-type (org-element-timest

Re: [PATCH] org-element-timestamp-interpreter: Return daterange anyway, if DATERANGE is non-nil

2023-07-11 Thread Ilya Chernyshov
Ihor Radchenko  writes:

> The patch looks good in general, but there is at least one test failing
> when I run make test. May you please check?

Inside `org-timestamp-split-range', there was an attempt to intepret a
timestamp object with :type `active'/`inactive' and :range-type
`daterange'/`timerange' which caused an error. Fixed by setting
:range-type to nil before `(org-element-interpret-data split-ts)'.


> Also, see the attached diff where I suggest some comments to explain the
> code logic.

Looks good to me, I just changed a note about
`org-element-timestamp-parser' setting nil for end part if :type is
`active'/`inactive'. That's not true. The actual behavior is that it
sets end date/time to the same values as start date/time even if it's
`active'/`inactive'. So here is the patch:

>From 823e7f39d33977854605485fcae814af0a3fdefe Mon Sep 17 00:00:00 2001
From: Ilya Chernyshov 
Date: Sat, 18 Feb 2023 14:55:39 +0700
Subject: [PATCH] lisp/org-element.el: Add new timestamp property :range-type

* lisp/org-element.el (org-element-timestamp-interpreter): Preserve old
behavior when :range-type is `nil'.  Take into account :range-type
value when interpreting ranges.  When :range-type is `timerange',
return a timerange ().  If :range-type is
`daterange' return a daterange (<...>--<...>).  When :range-type is
nil, return a daterange (as it was before).  When :range-type is
`daterange' or `timerange' and :type is `active'/`inactive', throw an
error.
(org-element-timestamp-parser): Add :range-type property.

* lisp/org.el (org-timestamp-split-range): Make sure that :range-type
is nil for a split timestamp.

* testing/lisp/test-org-element.el
(test-org-element/timestamp-interpreter): Add new tests.
(test-org-element/timestamp-parser): Add tests for :range-type
property.

* etc/ORG-NEWS (Major changes and additions to Org API): Add news about this property.
---
 etc/ORG-NEWS |   7 +
 lisp/org-element.el  | 215 +++-
 lisp/org.el  |   1 +
 testing/lisp/test-org-element.el | 231 ++-
 4 files changed, 355 insertions(+), 99 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 973a97a2f..a4725ae8c 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -200,6 +200,13 @@ a newly created one.
 Previously, one had to use
 
 : (apply #'org-element-create 'section nil (org-element-contents node))
+ New property ~:range-type~ for org-element timestamp object
+
+~org-element-timestamp-parser~ now adds =:range-type= property to each
+timestamp object.  Possible values: ~timerange~, ~daterange~, ~nil~.
+
+~org-element-timestamp-interpreter~ takes into account this property
+and returns an appropriate timestamp string.
 
 *** ~org-priority=show~ command no longer adjusts for scheduled/deadline
 
diff --git a/lisp/org-element.el b/lisp/org-element.el
index 1c9707573..075f64920 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -4043,7 +4043,7 @@ Assume point is at the target."
   "Parse time stamp at point, if any.
 
 When at a time stamp, return a new syntax node of `timestamp' type
-containing `:type', `:raw-value', `:year-start', `:month-start',
+containing `:type', `:range-type', `:raw-value', `:year-start', `:month-start',
 `:day-start', `:hour-start', `:minute-start', `:year-end',
 `:month-end', `:day-end', `:hour-end', `:minute-end',
 `:repeater-type', `:repeater-value', `:repeater-unit',
@@ -4077,6 +4077,10 @@ Assume point is at the beginning of the timestamp."
 			 (activep 'active)
 			 ((or date-end time-range) 'inactive-range)
 			 (t 'inactive)))
+ (range-type (cond
+  (date-end 'daterange)
+  (time-range 'timerange)
+  (t nil)))
 	 (repeater-props
 	  (and (not diaryp)
 		   (string-match "\\([.+]?\\+\\)\\([0-9]+\\)\\([hdwmy]\\)"
@@ -4123,6 +4127,7 @@ Assume point is at the beginning of the timestamp."
 	(org-element-create
  'timestamp
 	 (nconc (list :type type
+  :range-type range-type
 		  :raw-value raw-value
 		  :year-start year-start
 		  :month-start month-start
@@ -4142,99 +4147,121 @@ Assume point is at the beginning of the timestamp."
 
 (defun org-element-timestamp-interpreter (timestamp _)
   "Interpret TIMESTAMP object as Org syntax."
-  (let* ((repeat-string
-	  (concat
-	   (pcase (org-element-property :repeater-type timestamp)
-	 (`cumulate "+") (`catch-up "++") (`restart ".+"))
-	   (let ((val (org-element-property :repeater-value timestamp)))
-	 (and val (number-to-string val)))
-	   (pcase (org-element-property :repeater-unit timestamp)
-	 (`hour "h") (`day "d") (`week "w") (`month "m") (`year "y"
-	 (warning-string
-	  (concat
-	   (pcase (org-element-property :warning-

Re: [PATCH] org-element-timestamp-interpreter: Return daterange anyway, if DATERANGE is non-nil

2023-07-10 Thread Ilya Chernyshov

Hi.

Preserved old behavior for `org-element-timestamp-interpreter'
function for :range-type set to `nil'. The new function

The new function takes into account :range-type value when interpreting
ranges and throws error when :range-type set for `active'/`inactive'
types.

>From aa21a84fa38324f455cb17ac32e656e1242c2135 Mon Sep 17 00:00:00 2001
From: Ilya Chernyshov 
Date: Sat, 18 Feb 2023 14:55:39 +0700
Subject: [PATCH] lisp/org-element.el: Add new timestamp property :range-type

* lisp/org-element (org-element-timestamp-interpreter): Preserve old
behavior when :range-type is `nil'.  Take into account :range-type
value when interpreting ranges.  When :range-type is `timerange',
return a timerange ().  If :range-type is
`daterange' return a daterange (<...>--<...>).  When :range-type is
nil, return a daterange (as it was before).  When :range-type is
`daterange' or `timerange' and :type is `active'/`inactive', throw an
error.
(org-element-timestamp-parser): Add :range-type property.

* testing/lisp/test-org-element
(test-org-element/timestamp-interpreter): Add new tests.
(test-org-element/timestamp-parser): Add tests for :range-type
property.

* etc/ORG-NEWS (Major changes and additions to Org API): Add news about this property.
---
 etc/ORG-NEWS |   7 +
 lisp/org-element.el  | 171 +++--
 testing/lisp/test-org-element.el | 211 ++-
 3 files changed, 290 insertions(+), 99 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index d04e92275..d8d2275d9 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -200,6 +200,13 @@ a newly created one.
 Previously, one had to use
 
 : (apply #'org-element-create 'section nil (org-element-contents node))
+ New property ~:range-type~ for org-element timestamp object
+
+~org-element-timestamp-parser~ now adds =:range-type= property to each
+timestamp object.  Possible values: ~timerange~, ~daterange~, ~nil~.
+
+~org-element-timestamp-interpreter~ takes into account this property
+and returns approptiate timestamp string.
 
 *** ~org-priority=show~ command no longer adjusts for scheduled/deadline
 
diff --git a/lisp/org-element.el b/lisp/org-element.el
index bfb1d206e..5cbc57aab 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -4043,7 +4043,7 @@ Assume point is at the target."
   "Parse time stamp at point, if any.
 
 When at a time stamp, return a new syntax node of `timestamp' type
-containing `:type', `:raw-value', `:year-start', `:month-start',
+containing `:type', `:range-type', `:raw-value', `:year-start', `:month-start',
 `:day-start', `:hour-start', `:minute-start', `:year-end',
 `:month-end', `:day-end', `:hour-end', `:minute-end',
 `:repeater-type', `:repeater-value', `:repeater-unit',
@@ -4077,6 +4077,10 @@ Assume point is at the beginning of the timestamp."
 			 (activep 'active)
 			 ((or date-end time-range) 'inactive-range)
 			 (t 'inactive)))
+ (range-type (cond
+  (date-end 'daterange)
+  (time-range 'timerange)
+  (t nil)))
 	 (repeater-props
 	  (and (not diaryp)
 		   (string-match "\\([.+]?\\+\\)\\([0-9]+\\)\\([hdwmy]\\)"
@@ -4123,6 +4127,7 @@ Assume point is at the beginning of the timestamp."
 	(org-element-create
  'timestamp
 	 (nconc (list :type type
+  :range-type range-type
 		  :raw-value raw-value
 		  :year-start year-start
 		  :month-start month-start
@@ -4142,99 +4147,77 @@ Assume point is at the beginning of the timestamp."
 
 (defun org-element-timestamp-interpreter (timestamp _)
   "Interpret TIMESTAMP object as Org syntax."
-  (let* ((repeat-string
-	  (concat
-	   (pcase (org-element-property :repeater-type timestamp)
-	 (`cumulate "+") (`catch-up "++") (`restart ".+"))
-	   (let ((val (org-element-property :repeater-value timestamp)))
-	 (and val (number-to-string val)))
-	   (pcase (org-element-property :repeater-unit timestamp)
-	 (`hour "h") (`day "d") (`week "w") (`month "m") (`year "y"
-	 (warning-string
-	  (concat
-	   (pcase (org-element-property :warning-type timestamp)
-	 (`first "--") (`all "-"))
-	   (let ((val (org-element-property :warning-value timestamp)))
-	 (and val (number-to-string val)))
-	   (pcase (org-element-property :warning-unit timestamp)
-	 (`hour "h") (`day "d") (`week "w") (`month "m") (`year "y"
-	 (build-ts-string
-	  ;; Build an Org timestamp string from TIME.  ACTIVEP is
-	  ;; non-nil when time stamp is active.  If WITH-TIME-P is
-	  ;; non-nil, add a time part.  HOUR-END and MINUTE-END
-	  ;; specify a time range in the timestamp.  REPEAT-STRING is
-	  ;; the repeater string, if any.
-	  (lambda (time activep  with-time-p hour-end 

Re: [PATCH] org-element-timestamp-interpreter: Return daterange anyway, if DATERANGE is non-nil

2023-07-07 Thread Ilya Chernyshov

Ihor Radchenko  writes:

> Some general stylistic comments:
> 1. You left some whitespace-only blank lines and spaces at the end of
>lines. Please, clean them up.
> 2. Please, use double space between sentences in the commit message and
>link to this thread. See
>https://orgmode.org/worg/org-contribute.html#commit-messages
> 3. I noticed some (let((...) forms. Please put spaces between sexps like
>(let ((...)
>^ space here

I'm sorry for incorrect formatting. Fixed.

> Here, you are manually constructing time part of the timestamp,
> bypassing `org-time-stamp-format' and `org-timestamp-formats'. Please,
> use `org-time-stamp-format' for times as well.
> If necessary, feed free to extend `org-time-stamp-format' and the value
> of `org-timestamp-formats' constant.

I used `org-time-stamp-format' for start time, but I didn't come with the
idea on how to format end time in the current context, so I just used
`(format "-%02d:%02d" hour-end minute-end)'.

> `string-replace' is fragile here. If we ever need to put "<" or ">"
> inside timestamp, random breakages may happen. Please, rewrite.

Fixed.

> Interpreting timestamps with :time-range nil and
> :day-end/:year-end/:month-end non-nil as timerange is a breaking change.
> Let's avoid it.

Timestamp objects (ranges) with :range-type nil are now interpreted as
dateranges, as it was before.


>From 4ee8b8bc065c208374d7a516a7c8dc9fb7d0fe5e Mon Sep 17 00:00:00 2001
From: Ilya Chernyshov 
Date: Sat, 18 Feb 2023 14:55:39 +0700
Subject: [PATCH] lisp/org-element.el: Add new timestamp property :range-type

* lisp/org-element (org-element-timestamp-interpreter): Take into
account :range-type value when interpreting ranges.  When start and
end dates are equal and :range-type is `timerange', return a
timerange ().  If :range-type is `daterange'
always return a daterange (<...>--<...>).  When :range-type is nil,
return a daterange for any range (as it was before).
(org-element-timestamp-parser): Add :range-type property.

* testing/lisp/test-org-element
(test-org-element/timestamp-interpreter): Add new tests.
(test-org-element/timestamp-parser): Add testing for :range-type
property.

* etc/ORG-NEWS (Major changes and additions to Org API): Add news about this property.
---
 etc/ORG-NEWS |   7 ++
 lisp/org-element.el  | 177 +++
 testing/lisp/test-org-element.el | 121 -
 3 files changed, 210 insertions(+), 95 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index d04e92275..d8d2275d9 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -200,6 +200,13 @@ a newly created one.
 Previously, one had to use
 
 : (apply #'org-element-create 'section nil (org-element-contents node))
+ New property ~:range-type~ for org-element timestamp object
+
+~org-element-timestamp-parser~ now adds =:range-type= property to each
+timestamp object.  Possible values: ~timerange~, ~daterange~, ~nil~.
+
+~org-element-timestamp-interpreter~ takes into account this property
+and returns approptiate timestamp string.
 
 *** ~org-priority=show~ command no longer adjusts for scheduled/deadline
 
diff --git a/lisp/org-element.el b/lisp/org-element.el
index bfb1d206e..c6b2d81a1 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -4043,7 +4043,7 @@ Assume point is at the target."
   "Parse time stamp at point, if any.
 
 When at a time stamp, return a new syntax node of `timestamp' type
-containing `:type', `:raw-value', `:year-start', `:month-start',
+containing `:type', `:range-type', `:raw-value', `:year-start', `:month-start',
 `:day-start', `:hour-start', `:minute-start', `:year-end',
 `:month-end', `:day-end', `:hour-end', `:minute-end',
 `:repeater-type', `:repeater-value', `:repeater-unit',
@@ -4077,6 +4077,10 @@ Assume point is at the beginning of the timestamp."
 			 (activep 'active)
 			 ((or date-end time-range) 'inactive-range)
 			 (t 'inactive)))
+ (range-type (cond
+  (date-end 'daterange)
+  (time-range 'timerange)
+  (t nil)))
 	 (repeater-props
 	  (and (not diaryp)
 		   (string-match "\\([.+]?\\+\\)\\([0-9]+\\)\\([hdwmy]\\)"
@@ -4123,6 +4127,7 @@ Assume point is at the beginning of the timestamp."
 	(org-element-create
  'timestamp
 	 (nconc (list :type type
+  :range-type range-type
 		  :raw-value raw-value
 		  :year-start year-start
 		  :month-start month-start
@@ -4142,98 +4147,84 @@ Assume point is at the beginning of the timestamp."
 
 (defun org-element-timestamp-interpreter (timestamp _)
   "Interpret TIMESTAMP object as Org syntax."
-  (let* ((repeat-string
-	  (concat
-	   (pcase (org-element-property :repeater-type timestamp)
-	 (`cumulate "+") (`catch-up &

Re: [PATCH] org-element-timestamp-interpreter: Return daterange anyway, if DATERANGE is non-nil

2023-07-01 Thread Ilya Chernyshov
Hello!

In the new patch I added :range-type timestamp property, adjusted
interpreter,
parser functions, added tests for the property.



On Wed, Feb 22, 2023 at 11:21 AM Ihor Radchenko  wrote:

> I suggest introducing a new timestamp property :range-type. It can be
> nil, timerange, or daterange.
>
> Changing :type values will not be backwards-compatible.
>
From d95418110897bdde85a74734bb5b5fa7a3c77b92 Mon Sep 17 00:00:00 2001
From: Ilya Chernyshov 
Date: Sat, 18 Feb 2023 14:55:39 +0700
Subject: [PATCH] New timestamp property :range-type

* lisp/org-element (org-element-timestamp-interpreter): For ranges:
When :range-type is nil or `timerange', return timerange () if date-start and date-end are equal; return
daterange(<...>--<...>) otherwise. When :range-type is `daterange',
return daterange anyway. Refactor the code.

* lisp/org-element (org-element-timestamp-parser): Add :range-type property

* testing/lisp/test-org-element
(test-org-element/timestamp-interpreter): Add new tests.
(test-org-element/timestamp-parser): Add testing for :range-type
property.
---
 lisp/org-element.el  | 168 ++-
 testing/lisp/test-org-element.el |  86 +---
 2 files changed, 149 insertions(+), 105 deletions(-)

diff --git a/lisp/org-element.el b/lisp/org-element.el
index bfb1d206e..13dd41e5d 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -4043,7 +4043,7 @@ Assume point is at the target."
   "Parse time stamp at point, if any.
 
 When at a time stamp, return a new syntax node of `timestamp' type
-containing `:type', `:raw-value', `:year-start', `:month-start',
+containing `:type', `:range-type', `:raw-value', `:year-start', `:month-start',
 `:day-start', `:hour-start', `:minute-start', `:year-end',
 `:month-end', `:day-end', `:hour-end', `:minute-end',
 `:repeater-type', `:repeater-value', `:repeater-unit',
@@ -4077,6 +4077,10 @@ Assume point is at the beginning of the timestamp."
 			 (activep 'active)
 			 ((or date-end time-range) 'inactive-range)
 			 (t 'inactive)))
+ (range-type (cond
+  (date-end 'daterange)
+  (time-range 'timerange)
+  (t nil)))
 	 (repeater-props
 	  (and (not diaryp)
 		   (string-match "\\([.+]?\\+\\)\\([0-9]+\\)\\([hdwmy]\\)"
@@ -4123,6 +4127,7 @@ Assume point is at the beginning of the timestamp."
 	(org-element-create
  'timestamp
 	 (nconc (list :type type
+  :range-type range-type
 		  :raw-value raw-value
 		  :year-start year-start
 		  :month-start month-start
@@ -4142,98 +4147,75 @@ Assume point is at the beginning of the timestamp."
 
 (defun org-element-timestamp-interpreter (timestamp _)
   "Interpret TIMESTAMP object as Org syntax."
-  (let* ((repeat-string
-	  (concat
-	   (pcase (org-element-property :repeater-type timestamp)
-	 (`cumulate "+") (`catch-up "++") (`restart ".+"))
-	   (let ((val (org-element-property :repeater-value timestamp)))
-	 (and val (number-to-string val)))
-	   (pcase (org-element-property :repeater-unit timestamp)
-	 (`hour "h") (`day "d") (`week "w") (`month "m") (`year "y"
-	 (warning-string
-	  (concat
-	   (pcase (org-element-property :warning-type timestamp)
-	 (`first "--") (`all "-"))
-	   (let ((val (org-element-property :warning-value timestamp)))
-	 (and val (number-to-string val)))
-	   (pcase (org-element-property :warning-unit timestamp)
-	 (`hour "h") (`day "d") (`week "w") (`month "m") (`year "y"
-	 (build-ts-string
-	  ;; Build an Org timestamp string from TIME.  ACTIVEP is
-	  ;; non-nil when time stamp is active.  If WITH-TIME-P is
-	  ;; non-nil, add a time part.  HOUR-END and MINUTE-END
-	  ;; specify a time range in the timestamp.  REPEAT-STRING is
-	  ;; the repeater string, if any.
-	  (lambda (time activep  with-time-p hour-end minute-end)
-	(let ((ts (format-time-string
-   (org-time-stamp-format with-time-p)
-		   time)))
-	  (when (and hour-end minute-end)
-		(string-match "[012]?[0-9]:[0-5][0-9]" ts)
-		(setq ts
-		  (replace-match
-		   (format "\\&-%02d:%02d" hour-end minute-end)
-		   nil nil ts)))
-	  (unless activep (setq ts (format "[%s]" (substring ts 1 -1
-	  (dolist (s (list repeat-string warning-string))
-		(when (org-string-nw-p s)
-		  (setq ts (concat (substring ts 0 -1)
-   " "
-   s
-   (substring ts -1)
-	  ;; Return value.
-	  ts)))
-	 (type (org-element-property :type timestamp)))
-(pcase type
-  ((or `active `inactive)
-   (let* ((minute-start (org-element-property :minute-start timestamp))
-	  (minute-end (org-element

Re: [PATCH] org-element-timestamp-interpreter: Return daterange anyway, if DATERANGE is non-nil

2023-02-20 Thread Ilya Chernyshov
You suggest to split timestamp types active/inactive-range to 
active/inactive-timerange, active/inactive-daterange?


On February 20, 2023 6:07:19 PM GMT+07:00, Ihor Radchenko  
wrote:
>Ilya Chernyshov  writes:
>
>> So, an option is needed that controls whether to return a 
>> daterange
>> (even it's possible to return a timerange) or a timerange (if the 
>> dates
>> in the range are equal).
>>
>> I wrote a patch that handles this problem, could you please review 
>> the
>> code and give some advice to improve it?
>
>What about recording the type of timestamp range in the parser?
>Then, interpreter can simply examine the range type and emit the correct
>timestamp string.
>
>-- 
>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>


Re: [PATCH] org-element-timestamp-interpreter: Return daterange anyway, if DATERANGE is non-nil

2023-02-19 Thread Ilya Chernyshov


I forgot to attach the patch :)

>From b47324bc804e64e6cef482ba4897a457252e803a Mon Sep 17 00:00:00 2001
From: Ilya Chernyshov 
Date: Sat, 18 Feb 2023 14:55:39 +0700
Subject: [PATCH] org-element-timestamp-interpreter: Return daterange anyway,
 if DATERANGE is non-nil

* lisp/org-element (org-element-timestamp-interpreter): Replace
silenced argument with optional argument DATERANGE which controls
whether to return daterange (even if dates in the range are equal) or
timerange (if it's possible). Refactor the code.

* lisp/org-element (org-element-planning-interpreter): Call
`org-element-timestamp-interpreter' without second argument.

* lisp/org-element (org-element-clock-interpreter): Call
`org-element-timestamp-interpreter' with DATERANGE set to t, because
clock entries only support daterange format.

* lisp/org-element (org-element-interpret-data): Call
`org-element-timestamp-interpreter' on timestamp object with DATERANGE
set to t, if it's inactive-range.

* testing/lisp/test-org-element
(test-org-element/timestamp-interpreter): Expect timerange returned
for timestamp of type active-range from
`org-element-timestamp-interpreter' and `org-test-parse-and-interpret'
calls. Add tests for `org-element-timestamp-interpreter' with
DATERANGE argument.
---
 lisp/org-element.el  | 180 ++-
 testing/lisp/test-org-element.el |  28 -
 2 files changed, 106 insertions(+), 102 deletions(-)

diff --git a/lisp/org-element.el b/lisp/org-element.el
index d7847a678..9649c6951 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -2042,7 +2042,7 @@ (defun org-element-clock-interpreter (clock _)
   "Interpret CLOCK element as Org syntax."
   (concat "CLOCK: "
 	  (org-element-timestamp-interpreter
-	   (org-element-property :value clock) nil)
+	   (org-element-property :value clock) t)
 	  (let ((duration (org-element-property :duration clock)))
 	(and duration
 		 (concat " => "
@@ -2673,15 +2673,15 @@ (defun org-element-planning-interpreter (planning _)
 	 (list (let ((deadline (org-element-property :deadline planning)))
 		 (when deadline
 		   (concat org-element-deadline-keyword " "
-			   (org-element-timestamp-interpreter deadline nil
+			   (org-element-timestamp-interpreter deadline
 	   (let ((scheduled (org-element-property :scheduled planning)))
 		 (when scheduled
 		   (concat org-element-scheduled-keyword " "
-			   (org-element-timestamp-interpreter scheduled nil
+			   (org-element-timestamp-interpreter scheduled
 	   (let ((closed (org-element-property :closed planning)))
 		 (when closed
 		   (concat org-element-closed-keyword " "
-			   (org-element-timestamp-interpreter closed nil))
+			   (org-element-timestamp-interpreter closed))
" "))
 
 
@@ -4020,100 +4020,79 @@ (defun org-element-timestamp-parser ()
 		 repeater-props
 		 warning-props))
 
-(defun org-element-timestamp-interpreter (timestamp _)
-  "Interpret TIMESTAMP object as Org syntax."
-  (let* ((repeat-string
-	  (concat
-	   (pcase (org-element-property :repeater-type timestamp)
-	 (`cumulate "+") (`catch-up "++") (`restart ".+"))
-	   (let ((val (org-element-property :repeater-value timestamp)))
-	 (and val (number-to-string val)))
-	   (pcase (org-element-property :repeater-unit timestamp)
-	 (`hour "h") (`day "d") (`week "w") (`month "m") (`year "y"
-	 (warning-string
-	  (concat
-	   (pcase (org-element-property :warning-type timestamp)
-	 (`first "--") (`all "-"))
-	   (let ((val (org-element-property :warning-value timestamp)))
-	 (and val (number-to-string val)))
-	   (pcase (org-element-property :warning-unit timestamp)
-	 (`hour "h") (`day "d") (`week "w") (`month "m") (`year "y"
-	 (build-ts-string
-	  ;; Build an Org timestamp string from TIME.  ACTIVEP is
-	  ;; non-nil when time stamp is active.  If WITH-TIME-P is
-	  ;; non-nil, add a time part.  HOUR-END and MINUTE-END
-	  ;; specify a time range in the timestamp.  REPEAT-STRING is
-	  ;; the repeater string, if any.
-	  (lambda (time activep  with-time-p hour-end minute-end)
-	(let ((ts (format-time-string
-   (org-time-stamp-format with-time-p)
-		   time)))
-	  (when (and hour-end minute-end)
-		(string-match "[012]?[0-9]:[0-5][0-9]" ts)
-		(setq ts
-		  (replace-match
-		   (format "\\&-%02d:%02d" hour-end minute-end)
-		   nil nil ts)))
-	  (unless activep (setq ts (format "[%s]" (substring ts 1 -1
-	  (dolist (s (list repeat-string warning-string))
-		(when (org-string-nw-p s)
-		  (setq ts (concat (substring ts 0 -1)
-   " "
-   s
-   (substring ts -1)
-	  ;; Return value.
-	 

[PATCH] org-element-timestamp-interpreter: Return daterange anyway, if DATERANGE is non-nil

2023-02-19 Thread Ilya Chernyshov

Hello, guys

`org-element-timestamp-interpreter' function returns string of the 
form
"<2023-02-19 Sun 10:00>--<2023-02-19 Sun 10:30>" for a timestamp 
object
passed to it. The better result would be "<2023-02-19 Sun 
10:00-10:30>".


This function is also used for interpreting clock entries, which 
only
have the format of "[2023-02-19 Sun 10:00]--[2023-02-19 Sun 
10:30]".


So, an option is needed that controls whether to return a 
daterange
(even it's possible to return a timerange) or a timerange (if the 
dates

in the range are equal).

I wrote a patch that handles this problem, could you please review 
the

code and give some advice to improve it?

--
Best,
Ilya



Re: Timestamp and timestamp range definitions

2023-02-16 Thread Ilya Chernyshov


Ihor Radchenko  writes:

Updating the manual will make more sense. Would you mind writing 
a patch?


Of course.

>From da84673301de7e9453cb359536235d8ce56399f1 Mon Sep 17 00:00:00 2001
From: Ilya Chernyshov 
Date: Fri, 17 Feb 2023 01:23:27 +0700
Subject: [PATCH] org-manual.org: Update timestamp and timerange definitions

* doc/org-manual.org (Timestamps): Document that time specification of the
form <2023-02-17 Fri 10:00-12:00> is not a timestamp, but a timerange.
---
 doc/org-manual.org | 27 +--
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 2d38cf76c..5b6633417 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -5915,12 +5915,12 @@ ** Timestamps
 #+cindex: deadlines
 #+cindex: scheduling
 
-A timestamp is a specification of a date (possibly with a time or
-a range of times) in a special format, either =<2003-09-16 Tue>= or
-=<2003-09-16 Tue 09:39>= or =<2003-09-16 Tue 12:00-12:30>=[fn:19].
-A timestamp can appear anywhere in the headline or body of an Org tree
-entry.  Its presence causes entries to be shown on specific dates in
-the agenda (see [[*Weekly/daily agenda]]).  We distinguish:
+A timestamp is a specification of a date (possibly with a time) in a
+special format, either =<2003-09-16 Tue>= or
+=<2003-09-16 Tue 09:39>=[fn:19].  A timestamp can appear anywhere in
+the headline or body of an Org tree entry.  Its presence causes
+entries to be shown on specific dates in the agenda (see [[*Weekly/daily
+agenda]]).  We distinguish:
 
 - Plain timestamp; Event; Appointment ::
 
@@ -5935,7 +5935,7 @@ ** Timestamps
   ,* Meet Peter at the movies
 <2006-11-01 Wed 19:15>
   ,* Discussion on climate change
-<2006-11-02 Thu 20:00-22:00>
+<2006-11-02 Thu>
   #+end_example
 
 - Timestamp with repeater interval ::
@@ -5974,15 +5974,22 @@ ** Timestamps
 
   #+cindex: timerange
   #+cindex: date range
-  Two timestamps connected by =--= denote a range.  The headline is
-  shown on the first and last day of the range, and on any dates that
-  are displayed and fall in the range.  Here is an example:
+  Two timestamps connected by =--= denote a range.  In the agenda, the
+  headline is shown on the first and last day of the range, and on any
+  dates that are displayed and fall in the range.  Here is an example:
 
   #+begin_example
   ,** Meeting in Amsterdam
  <2004-08-23 Mon>--<2004-08-26 Thu>
   #+end_example
 
+  Timerange is a timestamp consisting of two time units connected by =-=
+
+  #+begin_example
+  ,* Discussion on climate change
+ <2006-11-02 Thu 10:00-12:00>
+  #+end_example
+
 - Inactive timestamp ::
 
   #+cindex: timestamp, inactive
-- 
2.39.0



--
Best,
Ilya


Timestamp and timestamp range definitions

2023-02-12 Thread Ilya Chernyshov

Hello

What's a type of timestamp <2022-10-15 Sat 10:00-13:00>?


From org-manual:


the definition for a timestamp is:

A timestamp is a specification of a date (possibly with a time or 
a range of times) in a
special format, either '<2003-09-16 Tue>' or '<2003-09-16 Tue 
09:39>'

or ‘<2003-09-16 Tue 12:00-12:30>'

Also, the definition for timestamp range is:

Two timestamps connected by '--' denote a range. The headline is 
shown on
the first and last day of the range, and on any dates that are 
displayed and fall

in the range. Here is an example:
,* Meeting in Amsterdam
<2004-08-23 Mon>--<2004-08-26 Thu>

But, according to tests in test-org-element.el such a timestamp is
considered a timerange [added in commit cb32494e2]:

(should
  (eq 'active-range
  (org-test-with-temp-text "<2012-03-29 Thu 7:30-16:40>"
 (org-element-property :type (org-element-context)

So, we either should change the behavior of
(org-element-timestamp-parser) or update the definitions of 
timestamp

and timestamp range in org-manual. What do you think?
--
Best,
Ilya



Re: [PATCH] org-datetree.el: Allow datetrees with TODO, priority, tags

2023-01-13 Thread Ilya Chernyshov


Ihor Radchenko  writes:


Ilya Chernyshov  writes:


 (defun org-datetree--find-create
@@ -169,18 +167,19 @@ component.  If INSERT is non-nil and 
there is no match then it is

 inserted into the buffer."
   (when (or month day)
 (org-narrow-to-subtree))
-  (let ((re (format regex-template year month day))
+  (let ((re (format org-complex-heading-regexp-format
+(format regex-template year month day)))


These changes make the docstring for `org-datetree--find-create'
incorrect:

(defun org-datetree--find-create
(regex-template year  month day insert)
  "Find the datetree matched by REGEX-TEMPLATE for YEAR, 
  MONTH, or DAY.
REGEX-TEMPLATE is passed to `format' with YEAR, MONTH, and 
DAY as
arguments.  Match group 1 is compared against the specified 
date
component.  If INSERT is non-nil and there is no match then 
it is

inserted into the buffer."

Please update the docstring to reflect the new behaviour.


Hi!

Since the last patch, I've made the following changes, thanks to 
your

recommendations in Matrix chat:

1. Added a new optional argument MATCH-TITLE to
`org-datetree--find-create' that controls whether to match
REGEX-TEMPLATE against heading title inside complex heading (the 
match

is done via `org-complex-heading-regexp-format') or to match
REGEX-TEMPLATE against the whole heading line(old behavior). That 
way,

we won't break old calls to the function.

2. Added `replace-match' call that renames the first implicitly 
numbered
match group inside REGEX-TEMPLATE to first explicitly numbered 
one. The

replace is performed only if MATCH-TITLE is non-nil(that is,
`org-complex-heading-regexp-format' is used). That way we ensure 
that

even if in the future `org-complex-heading-regexp-format' will be
changed (the number of match groups will be different), we can get
access to the right group matching a date component without 
modifying
the source code of the function. Is there a better way to ensure 
that?


>From 481d8b4049f09cf880b584635a778e976a609f5c Mon Sep 17 00:00:00 2001
From: Ilya Chernyshov 
Date: Thu, 15 Dec 2022 02:08:15 +0600
Subject: [PATCH] lisp/org-datetree.el: Allow datetrees with TODO, priority,
 tags

* org-datetree.el (org-datetree--find-create): Add optional argument
MATCH-TITLE that controls whether to match REGEX-TEMPLATE against
heading title inside complex heading or to match REGEX-TEMPLATE
against the whole heading line.

* org-datetree.el (org-datetree--find-create-group,
org-datetree-find-iso-week-create): Allow finding a datetree with TODO
state, priority, tags, statistics cookies, or COMMENT keyword.

* testing/lisp/test-org-datetree.el
(test-org-datetree/find-date-create,
test-org-datetree/find-iso-week-create): Add tests for a datetree with
tags, TODO or priority keywords.

* etc/ORG-NEWS (Datetree structure headlines can now be complex):
Document the change.

* doc/org-manual.org: Update datetree definition.
---
 doc/org-manual.org|  3 +-
 etc/ORG-NEWS  |  6 
 lisp/org-datetree.el  | 57 ---
 testing/lisp/test-org-datetree.el | 16 +
 4 files changed, 61 insertions(+), 21 deletions(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index f3b77ebad..f816f8725 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -22507,7 +22507,8 @@ level.
 ,*** 2022-10-08 Saturday
 #+end_example
 
-Tags are allowed in the tree structure.
+TODO state, priority, tags, statistics cookies, and COMMENT keywords
+are allowed in the tree structure.
 
 [fn:31] This is always the other, not the user.  See the variable
 ~org-link-from-user-regexp~.
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index c5d9bdf6e..0aeb76f2f 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -55,6 +55,12 @@ document header:
 ,#+LATEX_HEADER: \DefineVerbatimEnvironment{lstlisting}{Verbatim}{...whatever...}
 #+END_src
 
+** New features
+*** Datetree structure headlines can now be complex
+
+TODO state, priority, tags, statistics cookies, and COMMENT keywords
+are allowed in the tree structure.
+
 * Version 9.6
 
 ** Important announcements and breaking changes
diff --git a/lisp/org-datetree.el b/lisp/org-datetree.el
index 035ef047a..8a617e90c 100644
--- a/lisp/org-datetree.el
+++ b/lisp/org-datetree.el
@@ -99,16 +99,15 @@ If time-period is month, then group entries by month."
 	  (month (calendar-extract-month d))
 	  (day (calendar-extract-day d)))
   (org-datetree--find-create
-   "^\\*+[ \t]+\\([12][0-9]\\{3\\}\\)\\(\\s-*?\
-\\([ \t]:[[:alnum:]:_@#%%]+:\\)?\\s-*$\\)"
-   year)
+   "\\([12][0-9]\\{3\\}\\)"
+   year nil nil nil t)
   (org-datetree--find-create
-   "^\\*+[ \t]+%d-\\([01][0-9]\\) \\w+$"
-   year month)
+   "%d-\\([01][0-9]\\) \\w+"
+   year month nil nil t)
   (when (eq time-grouping 'day)
 	(org-datetree--find-create
-	

Re: [PATCH] org-datetree.el: Allow datetrees with TODO, priority, tags

2023-01-11 Thread Ilya Chernyshov


Ihor Radchenko  writes:


Ilya Chernyshov  writes:


 (defun org-datetree--find-create
@@ -169,18 +167,19 @@ component.  If INSERT is non-nil and 
there is no match then it is

 inserted into the buffer."
   (when (or month day)
 (org-narrow-to-subtree))
-  (let ((re (format regex-template year month day))
+  (let ((re (format org-complex-heading-regexp-format
+(format regex-template year month day)))


These changes make the docstring for `org-datetree--find-create'
incorrect:

(defun org-datetree--find-create
(regex-template year  month day insert)
  "Find the datetree matched by REGEX-TEMPLATE for YEAR, 
  MONTH, or DAY.
REGEX-TEMPLATE is passed to `format' with YEAR, MONTH, and 
DAY as
arguments.  Match group 1 is compared against the specified 
date
component.  If INSERT is non-nil and there is no match then 
it is

inserted into the buffer."

Please update the docstring to reflect the new behaviour.


Changed the docs, please review the new patch.

>From 2345abe57d4942a47fd55c2c6f741ef5c2643d47 Mon Sep 17 00:00:00 2001
From: Ilya Chernyshov 
Date: Thu, 15 Dec 2022 02:08:15 +0600
Subject: [PATCH] lisp/org-datetree.el: Allow datetrees with TODO, priority,
 tags

* org-datetree.el (org-datetree--find-create,
org-datetree--find-create-group, org-datetree-find-iso-week-create):
Allow finding a datetree with TODO state, priority, tags, statistics
cookies, or COMMENT keyword.

* testing/lisp/test-org-datetree.el
(test-org-datetree/find-date-create,
test-org-datetree/find-iso-week-create): Add tests for a datetree with
tags, TODO or priority keywords.

* etc/ORG-NEWS (Datetree structure headlines can now be complex):
Document the change.

* doc/org-manual.org: Update datetree definition.
---
 doc/org-manual.org|  3 ++-
 etc/ORG-NEWS  |  7 +++
 lisp/org-datetree.el  | 35 ++-
 testing/lisp/test-org-datetree.el | 16 ++
 4 files changed, 46 insertions(+), 15 deletions(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index f3b77ebad..f816f8725 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -22507,7 +22507,8 @@ level.
 ,*** 2022-10-08 Saturday
 #+end_example
 
-Tags are allowed in the tree structure.
+TODO state, priority, tags, statistics cookies, and COMMENT keywords
+are allowed in the tree structure.
 
 [fn:31] This is always the other, not the user.  See the variable
 ~org-link-from-user-regexp~.
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index c5d9bdf6e..0c9c7bf91 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -55,6 +55,13 @@ document header:
 ,#+LATEX_HEADER: \DefineVerbatimEnvironment{lstlisting}{Verbatim}{...whatever...}
 #+END_src
 
+** New features
+*** Datetree structure headlines can now be complex
+
+~org-datetree--find-create~ function can now find datetree
+headlines with TODO state, priority, tags, statistics cookies, or
+COMMENT keyword
+
 * Version 9.6
 
 ** Important announcements and breaking changes
diff --git a/lisp/org-datetree.el b/lisp/org-datetree.el
index 035ef047a..22d9760b0 100644
--- a/lisp/org-datetree.el
+++ b/lisp/org-datetree.el
@@ -99,15 +99,14 @@ If time-period is month, then group entries by month."
 	  (month (calendar-extract-month d))
 	  (day (calendar-extract-day d)))
   (org-datetree--find-create
-   "^\\*+[ \t]+\\([12][0-9]\\{3\\}\\)\\(\\s-*?\
-\\([ \t]:[[:alnum:]:_@#%%]+:\\)?\\s-*$\\)"
+   "\\([12][0-9]\\{3\\}\\)"
year)
   (org-datetree--find-create
-   "^\\*+[ \t]+%d-\\([01][0-9]\\) \\w+$"
+   "%d-\\([01][0-9]\\) \\w+"
year month)
   (when (eq time-grouping 'day)
 	(org-datetree--find-create
-	 "^\\*+[ \t]+%d-%02d-\\([0123][0-9]\\) \\w+$"
+ "%d-%02d-\\([0123][0-9]\\) \\w+"
 	 year month day)
 
 ;;;###autoload
@@ -147,40 +146,48 @@ will be built under the headline at point."
 	   (week (nth 0 iso-date)))
   ;; ISO 8601 week format is %G-W%V(-%u)
   (org-datetree--find-create
-   "^\\*+[ \t]+\\([12][0-9]\\{3\\}\\)\\(\\s-*?\
-\\([ \t]:[[:alnum:]:_@#%%]+:\\)?\\s-*$\\)"
+   "\\([12][0-9]\\{3\\}\\)"
weekyear nil nil
(format-time-string "%G" time))
   (org-datetree--find-create
-   "^\\*+[ \t]+%d-W\\([0-5][0-9]\\)$"
+   "%d-W\\([0-5][0-9]\\)"
weekyear week nil
(format-time-string "%G-W%V" time))
   ;; For the actual day we use the regular date instead of ISO week.
   (org-datetree--find-create
-   "^\\*+[ \t]+%d-%02d-\\([0123][0-9]\\) \\w+$"
+   "%d-%02d-\\([0123][0-9]\\) \\w+"
year month day
 
 (defun org-datetree--find-create
 (regex-template year  month day insert)
   "Find the datetree matched by REGEX-TEMPLATE for YEAR, MONTH, or DAY.
-REGEX-TEMPLATE is passed to `fo

Re: [PATCH] org-datetree.el: Allow datetrees with TODO, priority, tags

2023-01-05 Thread Ilya Chernyshov



Thanks!
Instead of manually constructing the regexp, you can use
`org-complex-heading-regexp-format'.


Thanks for the tip. Applied changes in the new patch.

>From 8a32385ae2ccbbc0caa35eda9a8184c165e3afcd Mon Sep 17 00:00:00 2001
From: Ilya Chernyshov 
Date: Thu, 15 Dec 2022 02:08:15 +0600
Subject: [PATCH] lisp/org-datetree.el: Allow datetrees with TODO, priority,
 tags

* org-datetree.el (org-datetree--find-create,
org-datetree--find-create-group, org-datetree-find-iso-week-create):
Allow finding a datetree with TODO state, priority, tags, statistics
cookies, or COMMENT keyword.

* testing/lisp/test-org-datetree.el
(test-org-datetree/find-date-create,
test-org-datetree/find-iso-week-create): Add tests for a datetree with
tags, TODO or priority keywords.

* etc/ORG-NEWS (Datetree structure headlines can now be complex):
Document the change.

* doc/org-manual.org: Update datetree definition.
---
 doc/org-manual.org|  3 ++-
 etc/ORG-NEWS  |  7 +++
 lisp/org-datetree.el  | 23 +++
 testing/lisp/test-org-datetree.el | 16 
 4 files changed, 36 insertions(+), 13 deletions(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index f3b77ebad..f816f8725 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -22507,7 +22507,8 @@ level.
 ,*** 2022-10-08 Saturday
 #+end_example
 
-Tags are allowed in the tree structure.
+TODO state, priority, tags, statistics cookies, and COMMENT keywords
+are allowed in the tree structure.
 
 [fn:31] This is always the other, not the user.  See the variable
 ~org-link-from-user-regexp~.
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index c5d9bdf6e..0c9c7bf91 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -55,6 +55,13 @@ document header:
 ,#+LATEX_HEADER: \DefineVerbatimEnvironment{lstlisting}{Verbatim}{...whatever...}
 #+END_src
 
+** New features
+*** Datetree structure headlines can now be complex
+
+~org-datetree--find-create~ function can now find datetree
+headlines with TODO state, priority, tags, statistics cookies, or
+COMMENT keyword
+
 * Version 9.6
 
 ** Important announcements and breaking changes
diff --git a/lisp/org-datetree.el b/lisp/org-datetree.el
index 035ef047a..cebb4e279 100644
--- a/lisp/org-datetree.el
+++ b/lisp/org-datetree.el
@@ -99,15 +99,14 @@ If time-period is month, then group entries by month."
 	  (month (calendar-extract-month d))
 	  (day (calendar-extract-day d)))
   (org-datetree--find-create
-   "^\\*+[ \t]+\\([12][0-9]\\{3\\}\\)\\(\\s-*?\
-\\([ \t]:[[:alnum:]:_@#%%]+:\\)?\\s-*$\\)"
+   "\\([12][0-9]\\{3\\}\\)"
year)
   (org-datetree--find-create
-   "^\\*+[ \t]+%d-\\([01][0-9]\\) \\w+$"
+   "%d-\\([01][0-9]\\) \\w+"
year month)
   (when (eq time-grouping 'day)
 	(org-datetree--find-create
-	 "^\\*+[ \t]+%d-%02d-\\([0123][0-9]\\) \\w+$"
+ "%d-%02d-\\([0123][0-9]\\) \\w+"
 	 year month day)
 
 ;;;###autoload
@@ -147,17 +146,16 @@ will be built under the headline at point."
 	   (week (nth 0 iso-date)))
   ;; ISO 8601 week format is %G-W%V(-%u)
   (org-datetree--find-create
-   "^\\*+[ \t]+\\([12][0-9]\\{3\\}\\)\\(\\s-*?\
-\\([ \t]:[[:alnum:]:_@#%%]+:\\)?\\s-*$\\)"
+   "\\([12][0-9]\\{3\\}\\)"
weekyear nil nil
(format-time-string "%G" time))
   (org-datetree--find-create
-   "^\\*+[ \t]+%d-W\\([0-5][0-9]\\)$"
+   "%d-W\\([0-5][0-9]\\)"
weekyear week nil
(format-time-string "%G-W%V" time))
   ;; For the actual day we use the regular date instead of ISO week.
   (org-datetree--find-create
-   "^\\*+[ \t]+%d-%02d-\\([0123][0-9]\\) \\w+$"
+   "%d-%02d-\\([0123][0-9]\\) \\w+"
year month day
 
 (defun org-datetree--find-create
@@ -169,18 +167,19 @@ component.  If INSERT is non-nil and there is no match then it is
 inserted into the buffer."
   (when (or month day)
 (org-narrow-to-subtree))
-  (let ((re (format regex-template year month day))
+  (let ((re (format org-complex-heading-regexp-format
+(format regex-template year month day)))
 	match)
 (goto-char (point-min))
 (while (and (setq match (re-search-forward re nil t))
-		(goto-char (match-beginning 1))
-		(< (string-to-number (match-string 1)) (or day month year
+		(goto-char (match-beginning 5))
+		(< (string-to-number (match-string 5)) (or day month year
 (cond
  ((not match)
   (goto-char (point-max))
   (unless (bolp) (insert "\n"))
   (org-datetree-insert-line year month day insert))
- ((= (string-to-number (match-string 1)) (or day month year))
+ ((= (string-to-number (match-string 5)) (or day month year))
   (beginning-of-line))
  (t
   (beginning-of-line)
diff --git a/testing/lisp/test-org-dat

[PATCH] org-datetree.el: Allow datetrees with TODO, priority, tags

2023-01-04 Thread Ilya Chernyshov
Hi,

Here is a patch that allows to find datetree headlines that contain tags,
TODO or priority keywords.

Sometimes you need to set TODOs or tags to such headlines. When you do
this, next time you capture under this datetree, you get a new datetree
with the same date in the same file, which is annoying. This patch fixes it.
From 4d3194adf417ae5bad78c35a783ebca7974b8167 Mon Sep 17 00:00:00 2001
From: Ilya Chernyshov 
Date: Thu, 15 Dec 2022 02:08:15 +0600
Subject: [PATCH] lisp/org-datetree.el: Allow datetrees with TODO, priority,
 tags

* org-datetree.el (org-datetree--find-create-group,
org-datetree-find-iso-week-create): Allow finding a datetree with
TODO keyword, priority keyword or tag group.

* testing/lisp/test-org-datetree.el
(test-org-datetree/find-date-create,
test-org-datetree/find-iso-week-create): Add tests for a datetree with
tags, TODO or priority keywords.

* etc/ORG-NEWS (Datetree structure headlines can now have tags, TODO, priority keywords): Document the change.

* doc/org-manual.org: Update datetree definition.
---
 doc/org-manual.org|  2 +-
 etc/ORG-NEWS  |  7 ++
 lisp/org-datetree.el  | 42 +++
 testing/lisp/test-org-datetree.el | 16 
 4 files changed, 56 insertions(+), 11 deletions(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index f3b77ebad..4dfa91a94 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -22507,7 +22507,7 @@ level.
 ,*** 2022-10-08 Saturday
 #+end_example
 
-Tags are allowed in the tree structure.
+Tags, TODO, priority keywords are allowed in the tree structure.
 
 [fn:31] This is always the other, not the user.  See the variable
 ~org-link-from-user-regexp~.
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index c5d9bdf6e..794bdf143 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -55,6 +55,13 @@ document header:
 ,#+LATEX_HEADER: \DefineVerbatimEnvironment{lstlisting}{Verbatim}{...whatever...}
 #+END_src
 
+** New features
+*** Datetree structure headlines can now have tags, TODO, priority keywords
+
+~org-datetree-find-iso-week-create~ and
+~org-datetree--find-create-group~ functions can now find datetree
+headlines with tags, TODO or priority keywords
+
 * Version 9.6
 
 ** Important announcements and breaking changes
diff --git a/lisp/org-datetree.el b/lisp/org-datetree.el
index 035ef047a..37e1ddf96 100644
--- a/lisp/org-datetree.el
+++ b/lisp/org-datetree.el
@@ -97,17 +97,28 @@ If time-period is month, then group entries by month."
 (goto-char (point-min))
 (let ((year (calendar-extract-year d))
 	  (month (calendar-extract-month d))
-	  (day (calendar-extract-day d)))
+	  (day (calendar-extract-day d))
+  (regexp-prefix (concat "^\\*+\\(?: +" (regexp-opt org-todo-keywords-1) "\\)?"
+ "\\(?: +\\[#.\\]\\)?"))
+  (tags-re "\\(?:[ \t]+:[[:alnum:]_@#%%:]+:\\)?[ \t]*$"))
   (org-datetree--find-create
-   "^\\*+[ \t]+\\([12][0-9]\\{3\\}\\)\\(\\s-*?\
-\\([ \t]:[[:alnum:]:_@#%%]+:\\)?\\s-*$\\)"
+   (concat
+regexp-prefix
+" +\\([12][0-9]\\{3\\}\\)"
+tags-re)
year)
   (org-datetree--find-create
-   "^\\*+[ \t]+%d-\\([01][0-9]\\) \\w+$"
+   (concat
+regexp-prefix
+" +%d-\\([01][0-9]\\) \\w+"
+tags-re)
year month)
   (when (eq time-grouping 'day)
 	(org-datetree--find-create
-	 "^\\*+[ \t]+%d-%02d-\\([0123][0-9]\\) \\w+$"
+ (concat
+  regexp-prefix
+  " +%d-%02d-\\([0123][0-9]\\) \\w+"
+  tags-re)
 	 year month day)
 
 ;;;###autoload
@@ -144,20 +155,31 @@ will be built under the headline at point."
 	   (iso-date (calendar-iso-from-absolute
 		  (calendar-absolute-from-gregorian d)))
 	   (weekyear (nth 2 iso-date))
-	   (week (nth 0 iso-date)))
+	   (week (nth 0 iso-date))
+   (regexp-prefix (concat "^\\*+\\(?: +" (regexp-opt org-todo-keywords-1) "\\)?"
+  "\\(?: +\\[#.\\]\\)?"))
+   (tags-re "\\(?:[ \t]+:[[:alnum:]_@#%%:]+:\\)?[ \t]*$"))
   ;; ISO 8601 week format is %G-W%V(-%u)
   (org-datetree--find-create
-   "^\\*+[ \t]+\\([12][0-9]\\{3\\}\\)\\(\\s-*?\
-\\([ \t]:[[:alnum:]:_@#%%]+:\\)?\\s-*$\\)"
+   (concat
+regexp-prefix
+" +\\([12][0-9]\\{3\\}\\)"
+tags-re)
weekyear nil nil
(format-time-string "%G" time))
   (org-datetree--find-create
-   "^\\*+[ \t]+%d-W\\([0-5][0-9]\\)$"
+   (concat
+regexp-prefix
+" +%d-W\\([0-5][0-9]\\)"
+tags-re)
weekyear week nil
(format-time-string "%G-W%V" time))
   ;; For the actual day we use the regular date instead of ISO week.
   (org-datetree--find-create
-   "^\\*+[ \t]+%d

Re: [PATCH] ox-icalendar: Create export backend options for deadline/scheduled-summary-prefix defcustoms

2022-11-09 Thread Ilya Chernyshov
Sending the updated patch.

On Wed, Nov 9, 2022 at 8:42 AM Ihor Radchenko  wrote:

> Чернышов Илья  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>
>
From 74cc1a6b879c1b856fdc9205b4e042582f658f6c Mon Sep 17 00:00:00 2001
From: Ilya Chernyshov 
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 s