emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/org 69383dfc24 031/101: org-ascii--current-justificatio


From: ELPA Syncer
Subject: [elpa] externals/org 69383dfc24 031/101: org-ascii--current-justification: Use `org-element-lineage-map'
Date: Sat, 1 Jul 2023 09:59:02 -0400 (EDT)

branch: externals/org
commit 69383dfc240a3be08cfb57d4f1d8727bbb0df902
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Ihor Radchenko <yantar92@posteo.net>

    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 410ca05ddd..c209bb637d 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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]