瀏覽代碼

ob-exp: Fix export of src blocks with flags

* lisp/ob-exp.el (org-babel-exp-code): Fix export of src blocks with
  flags.
* testing/lisp/test-ob-exp.el (ob-export/export-src-block-with-flags):
  New test.

Thanks to Giuseppe Lipari for reporting it.
Nicolas Goaziou 11 年之前
父節點
當前提交
dde6af3a62
共有 2 個文件被更改,包括 11 次插入1 次删除
  1. 2 1
      lisp/ob-exp.el
  2. 9 0
      testing/lisp/test-ob-exp.el

+ 2 - 1
lisp/ob-exp.el

@@ -341,11 +341,12 @@ replaced with its value."
    org-babel-exp-code-template
    `(("lang"  . ,(nth 0 info))
      ("body"  . ,(org-escape-code-in-string (nth 1 info)))
+     ("flags" . ,(let ((f (assq :flags (nth 2 info))))
+		   (when f (concat " " (cdr f)))))
      ,@(mapcar (lambda (pair)
 		 (cons (substring (symbol-name (car pair)) 1)
 		       (format "%S" (cdr pair))))
 	       (nth 2 info))
-     ("flags" . ,(let ((f (nth 3 info))) (when f (concat " " f))))
      ("name"  . ,(or (nth 4 info) "")))))
 
 (defun org-babel-exp-results (info type &optional silent hash)

+ 9 - 0
testing/lisp/test-ob-exp.el

@@ -303,6 +303,15 @@ Here is one at the end of a line. =2=
       (org-export-execute-babel-code)
       (buffer-string)))))
 
+(ert-deftest ob-export/export-src-block-with-flags ()
+  "Test exporting a source block with a flag."
+  (should
+   (string-match "\\`#\\+BEGIN_SRC emacs-lisp -some-flag$"
+    (org-test-with-temp-text
+	"#+BEGIN_SRC emacs-lisp :flags -some-flag\n\(+ 1 1)\n#+END_SRC"
+      (org-export-execute-babel-code)
+      (buffer-string)))))
+
 (provide 'test-ob-exp)
 
 ;;; test-ob-exp.el ends here