DONE =\C-c \C-o= to open results of source block
This commit is contained in:
parent
89dbf83e2a
commit
2fd9accd98
2 changed files with 69 additions and 59 deletions
|
@ -44,9 +44,8 @@ then run `org-babel-execute-src-block'."
|
|||
"If `point' is on a source code block, then open that block's
|
||||
results with `org-babel-open-src-block-results', otherwise defer
|
||||
to `org-open-at-point'."
|
||||
(message "opening at point")
|
||||
(or (org-babel-open-src-block-result)
|
||||
ad-do-it))
|
||||
(interactive "P")
|
||||
(or (call-interactively #'org-babel-open-src-block-result) ad-do-it))
|
||||
|
||||
(defun org-babel-pop-to-session-maybe ()
|
||||
"Detect if this is context for a org-babel src-block and if so
|
||||
|
@ -194,8 +193,7 @@ the header arguments specified at the source code block."
|
|||
source code block, otherwise return nil. With optional prefix
|
||||
argument RE-RUN the source-code block is evaluated even if
|
||||
results already exist."
|
||||
(interactive)
|
||||
(message "opening src block results")
|
||||
(interactive "P")
|
||||
(when (org-babel-get-src-block-info)
|
||||
(save-excursion
|
||||
;; go to the results, if there aren't any then run the block
|
||||
|
@ -205,14 +203,18 @@ results already exist."
|
|||
(move-end-of-line 1) (forward-char 1)
|
||||
;; open the results
|
||||
(if (looking-at org-bracket-link-regexp)
|
||||
(org-open-at-point) ;; file
|
||||
;; vector or scalar
|
||||
;; file results
|
||||
(org-open-at-point)
|
||||
(let ((results (org-babel-read-result)))
|
||||
(pop-to-buffer (get-buffer-create "org-babel-results"))
|
||||
(delete-region (point-min) (point-max))
|
||||
(if (listp results)
|
||||
(insert (orgtbl-to-tsv (list results) nil))
|
||||
(insert results))))
|
||||
(flet ((echo-res (result)
|
||||
(if (stringp result) result (format "%S" result))))
|
||||
(pop-to-buffer (get-buffer-create "org-babel-results"))
|
||||
(delete-region (point-min) (point-max))
|
||||
(if (listp results)
|
||||
;; table result
|
||||
(insert (orgtbl-to-generic results '(:sep "\t" :fmt echo-res)))
|
||||
;; scalar result
|
||||
(insert (echo-res results))))))
|
||||
t)))
|
||||
|
||||
(defun org-babel-process-value-result (result result-params)
|
||||
|
|
102
org-babel.org
102
org-babel.org
|
@ -207,7 +207,7 @@ would then be [[#sandbox][the sandbox]].
|
|||
#+end_src
|
||||
|
||||
|
||||
* Tasks [36/58]
|
||||
* Tasks [37/58]
|
||||
** PROPOSED raise elisp error when source-blocks return errors
|
||||
Not sure how/if this would work, but it may be desirable.
|
||||
|
||||
|
@ -453,52 +453,6 @@ In interactive use we might want to allow the user to choose between
|
|||
screen and file output. In non-interactive use such as export, it
|
||||
would be file output (subject to the :exports directives).
|
||||
|
||||
** STARTED =\C-c \C-o= to open results of source block
|
||||
by adding a =defadvice= to =org-open-at-point= we can use the common
|
||||
=\C-c \C-o= keybinding to open the results of a source-code block.
|
||||
This would be especially useful for source-code blocks which generate
|
||||
graphical results and insert a file link as the results in the
|
||||
org-mode buffer. (see [[* figure out how to handle graphic output][TODO figure out how to handle graphic output]]).
|
||||
This could also act reasonably with other results types...
|
||||
|
||||
- file :: use org-open-at-point to open the file
|
||||
- scalar :: open results unquoted in a new buffer
|
||||
- tabular :: export the table to a new buffer and open that buffer
|
||||
|
||||
#+srcname: task-opening-results-of-blocks
|
||||
#+begin_src ditaa :results replace :file blue.png :cmdline -r
|
||||
+---------+
|
||||
| cBLU |
|
||||
| |
|
||||
| +----+
|
||||
| |cPNK|
|
||||
| | |
|
||||
+----+----+
|
||||
#+end_src
|
||||
|
||||
#+resname:
|
||||
[[file:blue.png][blue.png]]
|
||||
|
||||
#+srcname: task-open-vector
|
||||
#+begin_src emacs-lisp
|
||||
'((1 2) (3 4))
|
||||
#+end_src
|
||||
|
||||
#+resname:
|
||||
| 1 | 2 |
|
||||
| 3 | 4 |
|
||||
|
||||
#+srcname: task-open-scalar
|
||||
#+begin_src emacs-lisp
|
||||
3
|
||||
#+end_src
|
||||
|
||||
#+resname:
|
||||
: 3
|
||||
|
||||
|
||||
|
||||
|
||||
** TODO Finalise behaviour regarding vector/scalar output
|
||||
*** DONE Stop spaces causing vector output
|
||||
This simple example of multilingual chaining produces vector output if
|
||||
|
@ -976,6 +930,60 @@ to the command if BUFF is not given.)
|
|||
2) The function is called inside of a =write.table= function call
|
||||
writing the results to a table
|
||||
3) The table is read using =org-table-import=
|
||||
|
||||
** DONE =\C-c \C-o= to open results of source block
|
||||
by adding a =defadvice= to =org-open-at-point= we can use the common
|
||||
=\C-c \C-o= keybinding to open the results of a source-code block.
|
||||
This would be especially useful for source-code blocks which generate
|
||||
graphical results and insert a file link as the results in the
|
||||
org-mode buffer. (see [[* figure out how to handle graphic output][TODO figure out how to handle graphic output]]).
|
||||
This could also act reasonably with other results types...
|
||||
|
||||
- file :: use org-open-at-point to open the file
|
||||
- scalar :: open results unquoted in a new buffer
|
||||
- tabular :: export the table to a new buffer and open that buffer
|
||||
|
||||
when called with a prefix argument the block is re-run
|
||||
|
||||
#+srcname: task-opening-results-of-blocks
|
||||
#+begin_src ditaa :results replace :file blue.png :cmdline -r
|
||||
+---------+
|
||||
| cBLU |
|
||||
| |
|
||||
| +----+
|
||||
| |cPNK|
|
||||
| | |
|
||||
+----+----+
|
||||
#+end_src
|
||||
|
||||
#+resname:
|
||||
[[file:blue.png][blue.png]]
|
||||
|
||||
#+srcname: task-open-vector
|
||||
#+begin_src emacs-lisp
|
||||
'((1 2) (3 4))
|
||||
#+end_src
|
||||
|
||||
#+resname:
|
||||
| 1 | 2 |
|
||||
| 3 | 4 |
|
||||
|
||||
#+srcname: task-open-scalar
|
||||
#+begin_src ruby :results output
|
||||
8.times do |n|
|
||||
puts "row #{n}"
|
||||
end
|
||||
#+end_src
|
||||
|
||||
#+resname:
|
||||
: row 0
|
||||
: row 1
|
||||
: row 2
|
||||
: row 3
|
||||
: row 4
|
||||
: row 5
|
||||
: row 6
|
||||
: row 7
|
||||
** DONE add =:tangle= family of header arguments
|
||||
values are
|
||||
- no :: don't include source-code block when tangling
|
||||
|
|
Loading…
Reference in a new issue