From 69383dfc240a3be08cfb57d4f1d8727bbb0df902 Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Mon, 22 May 2023 15:13:41 +0200 Subject: [PATCH] org-ascii--current-justification: Use `org-element-lineage-map' --- lisp/ox-ascii.el | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/lisp/ox-ascii.el b/lisp/ox-ascii.el index 410ca05dd..c209bb637 100644 --- a/lisp/ox-ascii.el +++ b/lisp/ox-ascii.el @@ -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)