[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org ea9d5b45db 012/101: org-element-create: Allow singl
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org ea9d5b45db 012/101: org-element-create: Allow single &rest argument as a list |
Date: |
Sat, 1 Jul 2023 09:58:52 -0400 (EDT) |
branch: externals/org
commit ea9d5b45db19493a81f342c539b656049a12daca
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Ihor Radchenko <yantar92@posteo.net>
org-element-create: Allow single &rest argument as a list
* lisp/org-element-ast.el (org-element-create): Add special case when
CHILDREN contains a single list of Org notes:
(let ((children (list a b c ...)))
(org-element-create 'type nil children))
This will simplify creating new elements when children are stored in a
list.
---
lisp/org-element-ast.el | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/lisp/org-element-ast.el b/lisp/org-element-ast.el
index a98e879c13..c575f2aad7 100644
--- a/lisp/org-element-ast.el
+++ b/lisp/org-element-ast.el
@@ -905,6 +905,12 @@ Optional argument PROPS, when non-nil, is a plist defining
the
properties of the node. CHILDREN can be elements, objects or
strings.
+When CHILDREN is a single anonymous node, use its contents as children
+nodes. This way,
+ (org-element-create 'section nil (org-element-contents node))
+will yield expected results with contents of another node adopted into
+a newly created one.
+
When TYPE is `plain-text', CHILDREN must contain a single node -
string. Alternatively, TYPE can be a string. When TYPE is nil or
`anonymous', PROPS must be nil."
@@ -934,7 +940,11 @@ string. Alternatively, TYPE can be a string. When TYPE
is nil or
(org-add-props (car children) props))
((pred stringp)
(if props (org-add-props type props) type))
- (_ (apply #'org-element-adopt (list type props) children))))
+ (_
+ (if (and (= 1 (length children))
+ (org-element-type-p (car children) 'anonymous))
+ (apply #'org-element-adopt (list type props) (car children))
+ (apply #'org-element-adopt (list type props) children)))))
(defun org-element-copy (datum &optional keep-contents)
"Return a copy of DATUM.
- [elpa] externals/org bc29f5de41 038/101: org-element: New `org-element-*property*' functions, (continued)
- [elpa] externals/org bc29f5de41 038/101: org-element: New `org-element-*property*' functions, ELPA Syncer, 2023/07/01
- [elpa] externals/org 7cbc441915 044/101: org-entry-get-with-inheritance: Use org-element API, ELPA Syncer, 2023/07/01
- [elpa] externals/org 31d53cb015 056/101: org-end-of-subtree: Use org-element API, ELPA Syncer, 2023/07/01
- [elpa] externals/org 7dee228569 063/101: org-element-at-point-no-context: Update docstring, ELPA Syncer, 2023/07/01
- [elpa] externals/org e1a2ea65ef 064/101: Allow syntax nodes to be supplied in place of POM in API functions, ELPA Syncer, 2023/07/01
- [elpa] externals/org 16d7cdcf52 068/101: org-manual: Remove unused drawer properties to disable, ELPA Syncer, 2023/07/01
- [elpa] externals/org 96b754c105 083/101: org-get-category, org-get-tags: Clarify that match data is modified, ELPA Syncer, 2023/07/01
- [elpa] externals/org fcde1f779d 090/101: test-org-element/at-point: Add new test, ELPA Syncer, 2023/07/01
- [elpa] externals/org 383d5dacb7 096/101: org-fold-show-set-visibility: Fix lineage visibility, ELPA Syncer, 2023/07/01
- [elpa] externals/org 4a8849340d 005/101: org-element-ast: New functions to map and resolve property values, ELPA Syncer, 2023/07/01
- [elpa] externals/org ea9d5b45db 012/101: org-element-create: Allow single &rest argument as a list,
ELPA Syncer <=
- [elpa] externals/org a8286a5a9e 015/101: org-element: Record origin buffer when parsing, ELPA Syncer, 2023/07/01
- [elpa] externals/org 5e94d5cef6 026/101: org-element-map: Allow FUN to be a lisp form, ELPA Syncer, 2023/07/01
- [elpa] externals/org 4fcdcb456d 021/101: org-element: Defer large buffer substrings when parsing, ELPA Syncer, 2023/07/01
- [elpa] externals/org 01351f3eab 067/101: Restructure file organization, ELPA Syncer, 2023/07/01
- [elpa] externals/org 69383dfc24 031/101: org-ascii--current-justification: Use `org-element-lineage-map', ELPA Syncer, 2023/07/01
- [elpa] externals/org 771074ba5e 047/101: org-in-archived-heading-p: Use org-element API, ELPA Syncer, 2023/07/01
- [elpa] externals/org 5898fcf269 061/101: Remove unused declares, ELPA Syncer, 2023/07/01
- [elpa] externals/org 3ce57e17a0 071/101: org-item-re: Convert into defsubst, ELPA Syncer, 2023/07/01
- [elpa] externals/org 52c63f5cce 095/101: org-lint-export-option-keywords: Small refactoring, ELPA Syncer, 2023/07/01
- [elpa] externals/org 7f337a2b95 098/101: org-fold-core: Fix isearch with `org-fold-core-isearch-open-function', ELPA Syncer, 2023/07/01