summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2016-07-25 15:36:09 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2016-07-25 15:36:09 +0200
commitb6dfc7565405c6b2e618c8dcc3c122ab2f1b041a (patch)
treee92de1f1273b79fbdb3999e9a9dafc3ba8bf3052
parent72461eaeaf0317a211a01d31f85eeed0d0ab7b0a (diff)
downloadorg-mode-b6dfc7565405c6b2e618c8dcc3c122ab2f1b041a.tar.gz
ox-ascii: Use cl-lib
* lisp/ox-ascii.el (org-ascii--current-text-width): Refactor code. (org-ascii--list-listings): (org-ascii--list-tables): Use "cl-" prefix.
-rw-r--r--lisp/ox-ascii.el40
1 files changed, 21 insertions, 19 deletions
diff --git a/lisp/ox-ascii.el b/lisp/ox-ascii.el
index e954980..33ef9a4 100644
--- a/lisp/ox-ascii.el
+++ b/lisp/ox-ascii.el
@@ -27,9 +27,9 @@
;;; Code:
-(eval-when-compile (require 'cl))
(require 'ox)
(require 'ox-publish)
+(require 'cl-lib)
(declare-function aa2u "ext:ascii-art-to-unicode" ())
@@ -564,8 +564,9 @@ INFO is a plist used as a communication channel."
;; Total width is determined by the presence, or not, of an
;; inline task among ELEMENT parents.
(total-width
- (if (loop for parent in genealogy
- thereis (eq (org-element-type parent) 'inlinetask))
+ (if (cl-some (lambda (parent)
+ (eq (org-element-type parent) 'inlinetask))
+ genealogy)
(plist-get info :ascii-inlinetask-width)
;; No inlinetask: Remove global margin from text width.
(- (plist-get info :ascii-text-width)
@@ -584,19 +585,20 @@ INFO is a plist used as a communication channel."
(- total-width
;; Each `quote-block' and `verse-block' above narrows text
;; width by twice the standard margin size.
- (+ (* (loop for parent in genealogy
- when (memq (org-element-type parent)
- '(quote-block verse-block))
- count parent)
- 2 (plist-get info :ascii-quote-margin))
+ (+ (* (cl-count-if (lambda (parent)
+ (memq (org-element-type parent)
+ '(quote-block verse-block)))
+ genealogy)
+ 2
+ (plist-get info :ascii-quote-margin))
;; Apply list margin once per "top-level" plain-list
;; containing current line
- (* (let ((count 0))
- (dolist (e genealogy count)
- (and (eq (org-element-type e) 'plain-list)
- (not (eq (org-element-type (org-export-get-parent e))
- 'item))
- (incf count))))
+ (* (cl-count-if
+ (lambda (e)
+ (and (eq (org-element-type e) 'plain-list)
+ (not (eq (org-element-type (org-export-get-parent e))
+ 'item))))
+ genealogy)
(plist-get info :ascii-list-margin))
;; Text width within a plain-list is restricted by
;; indentation of current item. If that's the case,
@@ -604,9 +606,9 @@ INFO is a plist used as a communication channel."
;; parent item, if any.
(let ((item
(if (eq (org-element-type element) 'item) element
- (loop for parent in genealogy
- when (eq (org-element-type parent) 'item)
- return parent))))
+ (cl-find-if (lambda (parent)
+ (eq (org-element-type parent) 'item))
+ genealogy))))
(if (not item) 0
;; Compute indentation offset of the current item,
;; that is the sum of the difference between its
@@ -806,7 +808,7 @@ generation. INFO is a plist used as a communication channel."
;; filling (like contents of a description list item).
(let* ((initial-text
(format (org-ascii--translate "Listing %d:" info)
- (incf count)))
+ (cl-incf count)))
(initial-width (string-width initial-text)))
(concat
initial-text " "
@@ -846,7 +848,7 @@ generation. INFO is a plist used as a communication channel."
;; filling (like contents of a description list item).
(let* ((initial-text
(format (org-ascii--translate "Table %d:" info)
- (incf count)))
+ (cl-incf count)))
(initial-width (string-width initial-text)))
(concat
initial-text " "