org-element: Improve description item's interpretation
* lisp/org-element.el (org-element-item-interpreter): Improve indentation of description items.
This commit is contained in:
parent
8730f80c0d
commit
00dbb3089f
|
@ -1287,36 +1287,40 @@ 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-element-property :bullet item)))
|
(let ((tag (pcase (org-element-property :tag item)
|
||||||
|
(`nil nil)
|
||||||
|
(tag (format "%s :: " (org-element-interpret-data tag)))))
|
||||||
|
(bullet
|
||||||
(org-list-bullet-string
|
(org-list-bullet-string
|
||||||
(cond ((not (string-match "[0-9a-zA-Z]" bullet)) "- ")
|
(cond
|
||||||
|
((not (string-match-p "[0-9a-zA-Z]"
|
||||||
|
(org-element-property :bullet item))) "- ")
|
||||||
((eq org-plain-list-ordered-item-terminator ?\)) "1)")
|
((eq org-plain-list-ordered-item-terminator ?\)) "1)")
|
||||||
(t "1.")))))
|
(t "1.")))))
|
||||||
(checkbox (org-element-property :checkbox item))
|
(concat
|
||||||
(counter (org-element-property :counter item))
|
bullet
|
||||||
(tag (let ((tag (org-element-property :tag item)))
|
(pcase (org-element-property :counter item)
|
||||||
(and tag (org-element-interpret-data tag))))
|
(`nil nil)
|
||||||
(pre-blank
|
(counter (format "[@%d] " counter)))
|
||||||
(min (or (org-element-property :pre-blank item)
|
(pcase (org-element-property :checkbox item)
|
||||||
;; 0 is specific to paragraphs at the beginning of
|
|
||||||
;; the item, so we use 1 as a fall-back value,
|
|
||||||
;; which is more universal.
|
|
||||||
1)
|
|
||||||
;; Lists ends after more than two consecutive empty
|
|
||||||
;; lines: limit ourselves to 2 newline characters.
|
|
||||||
2))
|
|
||||||
(ind (make-string (length bullet) ?\s)))
|
|
||||||
;; Indent contents.
|
|
||||||
(concat bullet
|
|
||||||
(and counter (format "[@%d] " counter))
|
|
||||||
(pcase checkbox
|
|
||||||
(`on "[X] ")
|
(`on "[X] ")
|
||||||
(`off "[ ] ")
|
(`off "[ ] ")
|
||||||
(`trans "[-] ")
|
(`trans "[-] ")
|
||||||
(_ nil))
|
(_ nil))
|
||||||
(and tag (format "%s :: " tag))
|
tag
|
||||||
(when contents
|
(when contents
|
||||||
(let ((contents (replace-regexp-in-string
|
(let* ((ind (make-string (if tag 5 (length bullet)) ?\s))
|
||||||
|
(pre-blank
|
||||||
|
(min (or (org-element-property :pre-blank item)
|
||||||
|
;; 0 is specific to paragraphs at the
|
||||||
|
;; beginning of the item, so we use 1 as
|
||||||
|
;; a fall-back value, which is more universal.
|
||||||
|
1)
|
||||||
|
;; Lists ends after more than two consecutive
|
||||||
|
;; empty lines: limit ourselves to 2 newline
|
||||||
|
;; characters.
|
||||||
|
2))
|
||||||
|
(contents (replace-regexp-in-string
|
||||||
"\\(^\\)[ \t]*\\S-" ind contents nil nil 1)))
|
"\\(^\\)[ \t]*\\S-" ind contents nil nil 1)))
|
||||||
(if (= pre-blank 0) (org-trim contents)
|
(if (= pre-blank 0) (org-trim contents)
|
||||||
(concat (make-string pre-blank ?\n) contents)))))))
|
(concat (make-string pre-blank ?\n) contents)))))))
|
||||||
|
|
Loading…
Reference in New Issue