Explorar o código

ASCII export: Remove narrowing of columns for export

Carsten Dominik %!s(int64=15) %!d(string=hai) anos
pai
achega
6e33c3fc3c
Modificáronse 3 ficheiros con 28 adicións e 2 borrados
  1. 8 0
      lisp/ChangeLog
  2. 16 0
      lisp/org-ascii.el
  3. 4 2
      lisp/org-table.el

+ 8 - 0
lisp/ChangeLog

@@ -1,5 +1,13 @@
 2010-02-12  Carsten Dominik  <carsten.dominik@gmail.com>
 
+	* org-ascii.el (org-export-ascii-table-widen-columns): New
+	option.
+	(org-export-ascii-preprocess): Realign tables to remove narrowing
+	if `org-export-ascii-table-widen-columns' is set.
+
+	* org-table.el (org-table-do-narrow): New variable.
+	(org-table-align): Narrow only if `org-table-do-narrow' is t.
+
 	* org.el (org-deadline, org-schedule): Allow updating if the
 	relevant time stamp does not have a repeater, i.e. do not require
 	that no time stamp has a repeater.

+ 16 - 0
lisp/org-ascii.el

@@ -65,6 +65,13 @@ for column grouping."
   :group 'org-export-ascii
   :type 'boolean)
 
+(defcustom org-export-ascii-table-widen-columns t
+  "Non-nil means widen narrowed columns for export.
+When nil, narrowed columns will look in ASCII export just like in org-mode,
+i.e. with \"=>\" as ellipsis."
+  :group 'org-export-ascii
+  :type 'boolean)
+
 ;;; Hooks
 
 (defvar org-export-ascii-final-hook nil
@@ -483,6 +490,15 @@ publishing directory."
 
 (defun org-export-ascii-preprocess (parameters)
   "Do extra work for ASCII export"
+  ;;
+  ;; Realign tables to get rid of narrowing
+  (when org-export-ascii-table-widen-columns
+    (let ((org-table-do-narrow nil))
+      (goto-char (point-min))
+      (org-table-map-tables
+       (lambda ()
+	 (org-if-unprotected
+	  (org-table-align))))))
   ;; Put quotes around verbatim text
   (goto-char (point-min))
   (while (re-search-forward org-verbatim-re nil t)

+ 4 - 2
lisp/org-table.el

@@ -575,6 +575,7 @@ When nil, simply write \"#ERROR\" in corrupted fields.")
 (make-variable-buffer-local 'org-table-overlay-coordinates)
 
 (defvar org-last-recalc-line nil)
+(defvar org-table-do-narrow t)   ; for dynamic scoping
 (defconst org-narrow-column-arrow "=>"
   "Used as display property in narrowed table columns.")
 
@@ -621,7 +622,8 @@ When nil, simply write \"#ERROR\" in corrupted fields.")
 
     ;; Check if we are narrowing any columns
     (goto-char beg)
-    (setq narrow (and org-format-transports-properties-p
+    (setq narrow (and org-table-do-narrow
+		      org-format-transports-properties-p
 		      (re-search-forward "<[rl]?[0-9]+>" end t)))
     (goto-char beg)
     (setq falign (re-search-forward "<[rl][0-9]*>" end t))
@@ -666,7 +668,7 @@ When nil, simply write \"#ERROR\" in corrupted fields.")
 	  (setq e (pop c))
 	  (when (and (stringp e) (string-match "^<\\([rl]\\)?\\([0-9]+\\)?>$" e))
 	    (if (match-end 1) (setq falign1 (match-string 1 e)))
-	    (if (match-end 2)
+	    (if (and org-table-do-narrow (match-end 2))
 		(setq fmax (string-to-number (match-string 2 e)) c nil))))
 	;; Find fields that are wider than fmax, and shorten them
 	(when fmax