0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-09-29 21:07:54 +00:00

adding a function for inspecting code block information e.g., header arguments

* lisp/ob.el (org-babel-view-src-block-info): New function to inspect code blocks.
* lisp/ob-keys.el (org-babel-key-bindings): Key bindings for org-babel-view-src-block-info.
* doc/orgcard.tex: Documentation of new Babel function.
This commit is contained in:
Eric Schulte 2011-07-25 10:45:37 -06:00
parent 07a2f48209
commit b1724e02fb
3 changed files with 31 additions and 0 deletions

View file

@ -445,6 +445,7 @@ formula, \kbd{:=} a field formula.
\key{open results of code block at point}{C-c C-o}
\key{check code block at point for errors}{C-c C-v c}
\key{view expanded body of code block at point}{C-c C-v v}
\key{view information about code block at point}{C-c C-v I}
\key{go to named code block}{C-c C-v g}
\key{go to named result}{C-c C-v r}
\key{go to the head of the current code block}{C-c C-v u}

View file

@ -79,6 +79,8 @@ functions which are assigned key bindings, and see
("l" . org-babel-load-in-session)
("\C-i" . org-babel-lob-ingest)
("i" . org-babel-lob-ingest)
("\C-I" . org-babel-view-src-block-info)
("I" . org-babel-view-src-block-info)
("\C-z" . org-babel-switch-to-session)
("z" . org-babel-switch-to-session-with-code)
("\C-a" . org-babel-sha1-hash)

View file

@ -250,6 +250,34 @@ then run `org-babel-execute-src-block'."
(progn (org-babel-eval-wipe-error-buffer)
(org-babel-execute-src-block current-prefix-arg info) t) nil)))
;;;###autoload
(defun org-babel-view-src-block-info ()
"Display information on the current source block.
This includes header arguments, language and name, and is largely
a window into the `org-babel-get-src-block-info' function."
(interactive)
(let ((info (org-babel-get-src-block-info 'light)))
(flet ((full (it) (> (length it) 0))
(printf (fmt &rest args) (princ (apply #'format fmt args))))
(when info
(with-help-window (help-buffer)
(let ((name (nth 4 info))
(lang (nth 0 info))
(switches (nth 3 info))
(header-args (nth 2 info)))
(when name (printf "Name: %s\n" name))
(when lang (printf "Lang: %s\n" lang))
(when (full switches) (printf "Switches: %s\n" switches))
(printf "Header Arguments:\n")
(dolist (pair (sort header-args
(lambda (a b) (string< (symbol-name (car a))
(symbol-name (car b))))))
(when (full (cdr pair))
(printf "\t%S%s\t%s\n"
(car pair)
(if (> (length (format "%S" (car pair))) 7) "" "\t")
(cdr pair))))))))))
;;;###autoload
(defun org-babel-expand-src-block-maybe ()
"Conditionally expand a source block.