|
|
@@ -150,7 +150,7 @@ form. (language body header-arguments-alist)"
|
|
|
"Insert RESULT into the current buffer after the end of the
|
|
|
current source block. With optional argument REPLACE replace any
|
|
|
existing results currently located after the source block."
|
|
|
- (if replace (litorgy-remove-result))
|
|
|
+ (if replace (litorgy-remove-result (listp result)))
|
|
|
(if (and (stringp result)
|
|
|
(not (or (string-equal (substring result -1)
|
|
|
"\n")
|
|
|
@@ -160,25 +160,29 @@ existing results currently located after the source block."
|
|
|
(save-excursion
|
|
|
(re-search-forward "^#\\+end_src" nil t) (open-line 1) (forward-char 2)
|
|
|
(if (stringp result)
|
|
|
- (litorgy-examplize-region (point) (progn (insert result) (point)))
|
|
|
- (insert ;; for now lets assume the result is a table if it's not a string
|
|
|
- (orgtbl-to-orgtbl result '(:fmt (lambda (cell) (format "%S" cell)))))
|
|
|
- (forward-line -1)
|
|
|
- (org-cycle))))
|
|
|
+ (litorgy-examplize-region (point) (progn (insert result) (point))))
|
|
|
+ (insert ;; for now lets assume the result is a table if it's not a string
|
|
|
+ (concat (orgtbl-to-orgtbl result '(:fmt (lambda (cell) (format "%S" cell)))) "\n"))
|
|
|
+ (forward-line -1)
|
|
|
+ (org-cycle)))
|
|
|
|
|
|
-(defun litorgy-remove-result ()
|
|
|
- "Remove the result following the current source block"
|
|
|
+(defun litorgy-remove-result (&optional table)
|
|
|
+ "Remove the result following the current source block. If
|
|
|
+optional argument TABLE is supplied then remove the table
|
|
|
+following the block rather than the fixed width example."
|
|
|
(save-excursion
|
|
|
(re-search-forward "^#\\+end_src" nil t)
|
|
|
(forward-char 1)
|
|
|
(delete-region (point)
|
|
|
(save-excursion (forward-line 1)
|
|
|
- (while (if (looking-at ": ")
|
|
|
- (progn (while (looking-at ": ")
|
|
|
- (forward-line 1)) t))
|
|
|
- (forward-line 1))
|
|
|
- (forward-line -1)
|
|
|
- (point)))))
|
|
|
+ (if table
|
|
|
+ (org-table-end)
|
|
|
+ (while (if (looking-at ": ")
|
|
|
+ (progn (while (looking-at ": ")
|
|
|
+ (forward-line 1)) t))
|
|
|
+ (forward-line 1))
|
|
|
+ (forward-line -1)
|
|
|
+ (point))))))
|
|
|
|
|
|
(defun litorgy-examplize-region (beg end)
|
|
|
"Comment out region using the ': ' org example quote."
|