瀏覽代碼

Column view: Protect vertical bars in fields when capturing column view

Capturing column view creates an Org-mode table, where the field
values cannot have vertical bars.  These are now protected.
Carsten Dominik 16 年之前
父節點
當前提交
164678d549
共有 4 個文件被更改,包括 27 次插入9 次删除
  1. 8 0
      lisp/ChangeLog
  2. 7 5
      lisp/org-colview-xemacs.el
  3. 6 4
      lisp/org-colview.el
  4. 6 0
      lisp/org.el

+ 8 - 0
lisp/ChangeLog

@@ -1,5 +1,13 @@
 2009-06-18  Carsten Dominik  <carsten.dominik@gmail.com>
 
+	* org-colview.el (org-columns-capture-view): Protect vertical bars
+	in column values.
+
+	* org-colview-xemacs.el (org-columns-capture-view): Protect
+	vertical bars in column values.
+
+	* org.el (org-quote-vert): New function.
+
 	* org-latex.el (org-export-latex-verbatim-wrap): New option.
 
 	* org-exp.el (org-export-format-source-code-or-example): Use

+ 7 - 5
lisp/org-colview-xemacs.el

@@ -1282,11 +1282,13 @@ of fields."
               (goto-char (match-beginning 0))
               (setq row nil)
               (loop for i from 0 to (1- n) do
-		    (push (or (get-char-property (point)
-						 'org-columns-value-modified)
-			      (get-char-property (point) 'org-columns-value)
-			      "")
-			  row)
+		    (push 
+		     (org-quote-vert
+		      (or (get-char-property (point)
+					     'org-columns-value-modified)
+			  (get-char-property (point) 'org-columns-value)
+			  ""))
+		     row)
 		    (org-columns-forward-char))
               (setq row (nreverse row))
               (unless (and skip-empty-rows

+ 6 - 4
lisp/org-colview.el

@@ -1092,10 +1092,12 @@ of fields."
                    (get-char-property (match-beginning 0) 'org-columns-key))
 	  (setq row nil)
 	  (loop for i from 0 to (1- n) do
-		(push (or (get-char-property (+ (match-beginning 0) i) 'org-columns-value-modified)
-			  (get-char-property (+ (match-beginning 0) i) 'org-columns-value)
-			  "")
-		      row))
+		(push
+		 (org-quote-vert
+		  (or (get-char-property (+ (match-beginning 0) i) 'org-columns-value-modified)
+		      (get-char-property (+ (match-beginning 0) i) 'org-columns-value)
+		      ""))
+		 row))
 	  (setq row (nreverse row))
 	  (unless (and skip-empty-rows
 		       (eq 1 (length (delete "" (delete-dups (copy-sequence row))))))

+ 6 - 0
lisp/org.el

@@ -15365,6 +15365,12 @@ and end of string."
 		    list)))
     (nreverse list)))
 
+(defun org-quote-vert (s)
+  "Replace \"|\" with \"\\vert\"."
+  (while (string-match "|" s)
+    (setq s (replace-match "\\vert" t t s)))
+  s)
+
 (defun org-uuidgen-p (s)
   "Is S an ID created by UUIDGEN?"
   (string-match "\\`[0-9a-f]\\{8\\}-[0-9a-f]\\{4\\}-[0-9a-f]\\{4\\}-[0-9a-f]\\{4\\}-[0-9a-f]\\{12\\}\\'" (downcase s)))