forked from mirrors/org-mode
org-element: List interpretation doesn't depend on its structure
* lisp/org-element.el (org-element-item-interpreter): Simplify bullet creation. (org-element-plain-list-interpreter): Fix wrong bullets, if needed. This change allows to intrepret plain lists without providing list's structure, which can be a bit hairy. For example, the following snippet now suffices to create a list programmatically: (org-element-interpret-data '(plain-list nil (item (:bullet "-") (paragraph nil "a")) (item (:bullet "-") (paragraph nil "b"))))
This commit is contained in:
parent
eb2eacf91d
commit
ecba5542e6
|
@ -1024,22 +1024,7 @@ Assume point is at the beginning of the item."
|
||||||
(defun org-element-item-interpreter (item contents)
|
(defun org-element-item-interpreter (item contents)
|
||||||
"Interpret ITEM element as Org syntax.
|
"Interpret ITEM element as Org syntax.
|
||||||
CONTENTS is the contents of the element."
|
CONTENTS is the contents of the element."
|
||||||
(let* ((bullet
|
(let* ((bullet (org-list-bullet-string (org-element-property :bullet item)))
|
||||||
(let* ((beg (org-element-property :begin item))
|
|
||||||
(struct (org-element-property :structure item))
|
|
||||||
(pre (org-list-prevs-alist struct))
|
|
||||||
(bul (org-element-property :bullet item)))
|
|
||||||
(org-list-bullet-string
|
|
||||||
(if (not (eq (org-list-get-list-type beg struct pre) 'ordered)) "-"
|
|
||||||
(let ((num
|
|
||||||
(car
|
|
||||||
(last
|
|
||||||
(org-list-get-item-number
|
|
||||||
beg struct pre (org-list-parents-alist struct))))))
|
|
||||||
(format "%d%s"
|
|
||||||
num
|
|
||||||
(if (eq org-plain-list-ordered-item-terminator ?\)) ")"
|
|
||||||
".")))))))
|
|
||||||
(checkbox (org-element-property :checkbox item))
|
(checkbox (org-element-property :checkbox item))
|
||||||
(counter (org-element-property :counter item))
|
(counter (org-element-property :counter item))
|
||||||
(tag (let ((tag (org-element-property :tag item)))
|
(tag (let ((tag (org-element-property :tag item)))
|
||||||
|
@ -1109,7 +1094,11 @@ Assume point is at the beginning of the list."
|
||||||
(defun org-element-plain-list-interpreter (plain-list contents)
|
(defun org-element-plain-list-interpreter (plain-list contents)
|
||||||
"Interpret PLAIN-LIST element as Org syntax.
|
"Interpret PLAIN-LIST element as Org syntax.
|
||||||
CONTENTS is the contents of the element."
|
CONTENTS is the contents of the element."
|
||||||
contents)
|
(with-temp-buffer
|
||||||
|
(insert contents)
|
||||||
|
(goto-char (point-min))
|
||||||
|
(org-list-repair)
|
||||||
|
(buffer-string)))
|
||||||
|
|
||||||
|
|
||||||
;;;; Quote Block
|
;;;; Quote Block
|
||||||
|
|
Loading…
Reference in New Issue