summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2014-09-20 14:40:01 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2014-09-20 15:06:22 +0200
commitaaa7aa983dbd54fe3c111acf7fd561900cdf5987 (patch)
treed4c3c7d7d5cb5c8f60586ac8fc8e8dc5afea0a9f
parent0491ae52045c8f55a8e47fd1111f07f343479686 (diff)
downloadorg-mode-aaa7aa983dbd54fe3c111acf7fd561900cdf5987.tar.gz
ox-ascii: Implement plain-lists own extra margin
* lisp/ox-ascii.el (org-ascii-list-margin): New variable. (ascii): New property. (org-ascii--current-text-width, org-ascii-plain-list): Take into account list margin. * doc/org.texi (Publishing options): * etc/ORG-NEWS (argument): Document new variable.
-rw-r--r--doc/org.texi1
-rw-r--r--etc/ORG-NEWS3
-rw-r--r--lisp/ox-ascii.el25
3 files changed, 28 insertions, 1 deletions
diff --git a/doc/org.texi b/doc/org.texi
index c876906..7d98d51 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -13807,6 +13807,7 @@ however, override everything.
@item @code{:ascii-inlinetask-width} @tab @code{org-ascii-inlinetask-width}
@item @code{:ascii-inner-margin} @tab @code{org-ascii-inner-margin}
@item @code{:ascii-links-to-notes} @tab @code{org-ascii-links-to-notes}
+@item @code{:ascii-list-margin} @tab @code{org-ascii-list-margin}
@item @code{:ascii-paragraph-spacing} @tab @code{org-ascii-paragraph-spacing}
@item @code{:ascii-quote-margin} @tab @code{org-ascii-quote-margin}
@item @code{:ascii-table-keep-all-vertical-lines} @tab @code{org-ascii-table-keep-all-vertical-lines}
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 62181cb..8a5b8c1 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -61,6 +61,9 @@ which is now obsolete. As a consequence, this change also deprecates
*** Markdown export supports switches in source blocks
For example, it is now possible to number lines using the =-n= switch
in a source block.
+*** New option in ASCII export
+Plain lists can have an extra margin by setting
+~org-ascii-list-margin~ variable to an appopriate integer.
*** New blocks in ASCII export
ASCII export now supports =#+BEGIN_JUSTIFYRIGHT= and
=#+BEGIN_JUSTIFYLEFT= blocks. See documentation for details.
diff --git a/lisp/ox-ascii.el b/lisp/ox-ascii.el
index 047b74e..6f2b43a 100644
--- a/lisp/ox-ascii.el
+++ b/lisp/ox-ascii.el
@@ -133,6 +133,7 @@
(:ascii-inlinetask-width nil nil org-ascii-inlinetask-width)
(:ascii-inner-margin nil nil org-ascii-inner-margin)
(:ascii-links-to-notes nil nil org-ascii-links-to-notes)
+ (:ascii-list-margin nil nil org-ascii-list-margin)
(:ascii-paragraph-spacing nil nil org-ascii-paragraph-spacing)
(:ascii-quote-margin nil nil org-ascii-quote-margin)
(:ascii-table-keep-all-vertical-lines
@@ -184,6 +185,15 @@ This margin is applied on both sides of the text."
:package-version '(Org . "8.0")
:type 'integer)
+(defcustom org-ascii-list-margin 0
+ "Width of margin used for plain lists, in characters.
+This margin applies to top level list only, not to its
+sub-lists."
+ :group 'org-export-ascii
+ :version "24.5"
+ :package-version '(Org . "8.3")
+ :type 'integer)
+
(defcustom org-ascii-inlinetask-width 30
"Width of inline tasks, in number of characters.
This number ignores any margin."
@@ -581,6 +591,15 @@ INFO is a plist used as a communication channel."
'(quote-block verse-block))
count parent)
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))))
+ (plist-get info :ascii-list-margin))
;; Text width within a plain-list is restricted by
;; indentation of current item. If that's the case,
;; compute it with the help of `:structure' property from
@@ -1558,7 +1577,11 @@ the plist used as a communication channel."
"Transcode a PLAIN-LIST element from Org to ASCII.
CONTENTS is the contents of the list. INFO is a plist holding
contextual information."
- contents)
+ (let ((margin (plist-get info :ascii-list-margin)))
+ (if (or (< margin 1)
+ (eq (org-element-type (org-export-get-parent plain-list)) 'item))
+ contents
+ (org-ascii--indent-string contents margin))))
;;;; Plain Text