[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals-release/org f138810065 1/2: org-element: Allow inlineta
From: |
ELPA Syncer |
Subject: |
[elpa] externals-release/org f138810065 1/2: org-element: Allow inlinetasks to be commented and archived |
Date: |
Sun, 25 Dec 2022 07:57:58 -0500 (EST) |
branch: externals-release/org
commit f13881006587568d5060d91fa52176394dbcf965
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Ihor Radchenko <yantar92@posteo.net>
org-element: Allow inlinetasks to be commented and archived
* lisp/org-element.el (org-element-inlinetask-parser): Parse
inlinetasks closer to headings. In particular, recognize COMMENT
keyword and ARCHIVE tag in inlinetasks on parser level.
* testing/lisp/test-org.el (test-org/comment-dwim): Add tests for
inlinetasks and for uncommenting headings.
Reported-by: Alain.Cochard@unistra.fr
Link: https://orgmode.org/list/25508.20192.899342.932809@gargle.gargle.HOWL
---
lisp/org-element.el | 16 ++++++++++++++--
testing/lisp/test-org.el | 20 ++++++++++++++++++++
2 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/lisp/org-element.el b/lisp/org-element.el
index 71c242ea65..e049c65d6b 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -1365,7 +1365,16 @@ Assume point is at beginning of the inline task."
(priority (and (looking-at "\\[#.\\][ \t]*")
(progn (goto-char (match-end 0))
(aref (match-string 0) 2))))
- (title-start (point))
+ (commentedp
+ (and (let ((case-fold-search nil))
+ (looking-at org-element-comment-string))
+ (goto-char (match-end 0))
+ (when (looking-at-p "\\(?:[ \t]\\|$\\)")
+ (point))))
+ (title-start (prog1 (point)
+ (unless (or todo priority commentedp)
+ ;; Headline like "* :tag:"
+ (skip-chars-backward " \t"))))
(tags (when (re-search-forward
"[ \t]+\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$"
(line-end-position)
@@ -1375,6 +1384,7 @@ Assume point is at beginning of the inline task."
(title-end (point))
(raw-value (org-trim
(buffer-substring-no-properties title-start title-end)))
+ (archivedp (member org-element-archive-tag tags))
(task-end (save-excursion
(end-of-line)
(and (re-search-forward org-element-headline-re limit t)
@@ -1410,7 +1420,9 @@ Assume point is at beginning of the inline task."
:todo-keyword todo
:todo-type todo-type
:post-blank (1- (count-lines (or task-end begin) end))
- :post-affiliated begin)
+ :post-affiliated begin
+ :archivedp archivedp
+ :commentedp commentedp)
time-props
standard-props))))
(org-element-put-property
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index 3f61b83657..47cb8d8813 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -175,6 +175,26 @@
(org-test-with-temp-text "* Test"
(call-interactively #'org-comment-dwim)
(buffer-string))))
+ ;; Uncomment a heading
+ (should
+ (equal "* Test"
+ (org-test-with-temp-text "* COMMENT Test"
+ (call-interactively #'org-comment-dwim)
+ (buffer-string))))
+ ;; Comment an inlinetask
+ (should
+ (equal "*** COMMENT Test"
+ (let ((org-inlinetask-min-level 3))
+ (org-test-with-temp-text "*** Test"
+ (call-interactively #'org-comment-dwim)
+ (buffer-string)))))
+ ;; Uncomment an inlinetask
+ (should
+ (equal "*** Test"
+ (let ((org-inlinetask-min-level 3))
+ (org-test-with-temp-text "*** COMMENT Test"
+ (call-interactively #'org-comment-dwim)
+ (buffer-string)))))
;; In a source block, use appropriate syntax.
(should
(equal " ;; "