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 |
 |---+---+---|
 |   |   |   |
This commit is contained in:
Dan Davison 2010-04-10 16:49:40 -04:00
parent 8c827ba5ba
commit 59d499ff51
1 changed files with 3 additions and 2 deletions

View File

@ -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)