org-ascii--current-justification: Use `org-element-lineage-map'

This commit is contained in:
Ihor Radchenko 2023-05-22 15:13:41 +02:00
parent 44baf8f2b8
commit 69383dfc24
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 13 additions and 10 deletions

View File

@ -632,16 +632,19 @@ INFO is a plist used as a communication channel."
"Return expected justification for ELEMENT's contents.
Return value is a symbol among `left', `center', `right' and
`full'."
(let (justification)
(while (and (not justification)
(setq element (org-element-property :parent element)))
(pcase (org-element-type element)
(`center-block (setq justification 'center))
(`special-block
(let ((name (org-element-property :type element)))
(cond ((string= name "JUSTIFYRIGHT") (setq justification 'right))
((string= name "JUSTIFYLEFT") (setq justification 'left)))))))
(or justification 'left)))
(or (org-element-lineage-map
element
(lambda (el)
(pcase (org-element-type el)
(`center-block 'center)
(`special-block
(let ((name (org-element-property :type element)))
(cond ((string= name "JUSTIFYRIGHT") 'right)
((string= name "JUSTIFYLEFT") 'left))))))
'(center-block 'special-block)
nil 'first-match)
;; default
'left))
(defun org-ascii--build-title
(element info text-width &optional underline notags toc)