Просмотр исходного кода

babel: Allow table to end neatly with terminal hline

Prior to this, a terminal hline would leave dangling empty cells:

 #+TBLNAME: A
 |---+---+---|
 | a | b | c |
 |---+---+---|

 #+begin_src emacs-lisp :var tab=A
 tab
 #+end_src

 #+results:
 |---+---+---|
 | a | b | c |
 |---+---+---|
 |   |   |   |
Dan Davison 16 лет назад
Родитель
Сommit
59d499ff51
1 измененных файлов с 3 добавлено и 2 удалено
  1. 3 2
      contrib/babel/lisp/org-babel.el

+ 3 - 2
contrib/babel/lisp/org-babel.el

@@ -776,20 +776,21 @@ code ---- the results are extracted in the syntax of the source
         (setq result (concat result "\n")))
         (setq result (concat result "\n")))
       (save-excursion
       (save-excursion
 	(let ((existing-result (org-babel-where-is-src-block-result t info hash))
 	(let ((existing-result (org-babel-where-is-src-block-result t info hash))
-	      (results-switches (cdr (assoc :results_switches (third info)))))
+	      (results-switches (cdr (assoc :results_switches (third info)))) beg)
 	  (when existing-result (goto-char existing-result) (forward-line 1))
 	  (when existing-result (goto-char existing-result) (forward-line 1))
 	  (setq results-switches
 	  (setq results-switches
                 (if results-switches (concat " " results-switches) ""))
                 (if results-switches (concat " " results-switches) ""))
 	  (cond
 	  (cond
 	   ;; assume the result is a table if it's not a string
 	   ;; assume the result is a table if it's not a string
 	   ((not (stringp result))
 	   ((not (stringp result))
+	    (setq beg (point))
 	    (insert (concat (orgtbl-to-orgtbl
 	    (insert (concat (orgtbl-to-orgtbl
 			     (if (or (eq 'hline (car result))
 			     (if (or (eq 'hline (car result))
 				     (and (listp (car result))
 				     (and (listp (car result))
 					  (listp (cdr (car result)))))
 					  (listp (cdr (car result)))))
 				 result (list result))
 				 result (list result))
 			     '(:fmt (lambda (cell) (format "%s" cell)))) "\n"))
 			     '(:fmt (lambda (cell) (format "%s" cell)))) "\n"))
-	    (forward-line -1) (org-cycle))
+	    (goto-char beg) (org-cycle))
 	   ((member "file" result-params)
 	   ((member "file" result-params)
 	    (insert result))
 	    (insert result))
 	   ((member "html" result-params)
 	   ((member "html" result-params)