diff options
author | Eric Schulte <schulte.eric@gmail.com> | 2011-07-25 10:45:37 -0600 |
---|---|---|
committer | Eric Schulte <schulte.eric@gmail.com> | 2011-07-25 10:50:56 -0600 |
commit | b1724e02fbc52f1c578bb5ff281f5eb7a23222d2 (patch) | |
tree | 98e4ee209494f9b86d9bd4013cc6cfc962829adf | |
parent | 07a2f48209a8a5c162027ce30cae5ab95147532f (diff) | |
download | org-mode-b1724e02fbc52f1c578bb5ff281f5eb7a23222d2.tar.gz |
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.
-rw-r--r-- | doc/orgcard.tex | 1 | ||||
-rw-r--r-- | lisp/ob-keys.el | 2 | ||||
-rw-r--r-- | lisp/ob.el | 28 |
3 files changed, 31 insertions, 0 deletions
diff --git a/doc/orgcard.tex b/doc/orgcard.tex index a79371f..b55f024 100644 --- a/doc/orgcard.tex +++ b/doc/orgcard.tex @@ -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} diff --git a/lisp/ob-keys.el b/lisp/ob-keys.el index 3b5b42d..881e60a 100644 --- a/lisp/ob-keys.el +++ b/lisp/ob-keys.el @@ -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) @@ -251,6 +251,34 @@ then run `org-babel-execute-src-block'." (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. Detect if this is context for a org-babel src-block and if so |