Prechádzať zdrojové kódy

ob: Preserve comma escaping when inserting results

* lisp/ob-core.el (org-babel-insert-result): Fix typo
* testing/lisp/test-ob.el (test-ob/preserve-comma-escape): New test.

Reported-by: "Berry, Charles" <ccberry@ucsd.edu>
<http://lists.gnu.org/r/emacs-orgmode/2019-08/msg00250.html>
Nicolas Goaziou 5 rokov pred
rodič
commit
4848b8b9aa
2 zmenil súbory, kde vykonal 27 pridanie a 1 odobranie
  1. 1 1
      lisp/ob-core.el
  2. 26 0
      testing/lisp/test-ob.el

+ 1 - 1
lisp/ob-core.el

@@ -2307,7 +2307,7 @@ INFO may provide the values of these header arguments (in the
 			   (setq start inline-start)
 			   (setq finish inline-finish)
 			   (setq no-newlines t))
-			 (let ((before-finish (marker-position end)))
+			 (let ((before-finish (copy-marker end)))
 			   (goto-char end)
 			   (insert (concat finish (unless no-newlines "\n")))
 			   (goto-char beg)

+ 26 - 0
testing/lisp/test-ob.el

@@ -1532,6 +1532,32 @@ echo \"$data\"
        (buffer-substring-no-properties (line-beginning-position)
 				       (point-max)))))))
 
+(ert-deftest test-ob/preserve-comma-escape ()
+  "Preserve comma escapes when inserting results."
+  (should
+   (equal
+    "#+begin_example
+line 1
+,* headline 2
+,* headline 3
+,* headline 4
+,* headline 5
+#+end_example
+"
+    (org-test-with-temp-text "#+begin_src emacs-lisp :wrap example
+\"line 1
+,* headline 2
+,* headline 3
+,* headline 4
+,* headline 5
+\"
+#+end_src
+"
+      (org-babel-execute-src-block)
+      (let ((case-fold-search t)) (search-forward "result" nil t))
+      (downcase (buffer-substring-no-properties (line-beginning-position 2)
+						(point-max)))))))
+
 (ert-deftest test-ob/safe-header-args ()
   "Detect safe and unsafe header args."
   (let ((safe-args '((:cache . "foo")