mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-09-29 22:47:56 +00:00
org-babel: allow header args to be specified on #+lob line
This commit is contained in:
parent
6c147f0b1e
commit
7c32bc5672
|
@ -55,7 +55,7 @@ add files to this list use the `org-babel-lob-ingest' command."
|
|||
|
||||
;; functions for executing lob one-liners
|
||||
|
||||
(defvar org-babel-lob-one-liner-regexp "#\\+lob:[ \t]+\\([^\(\)\n]+\\)\(\\([^\n]*\\)\)[ \t]*\n")
|
||||
(defvar org-babel-lob-one-liner-regexp "#\\+lob:[ \t]+\\([^\(\)\n]+\\)\(\\([^\n]*\\)\)[ \t]*\\([^\n]*\\)\n")
|
||||
|
||||
(defun org-babel-lob-execute-maybe ()
|
||||
"Detect if this is context for a org-babel Library Of Babel
|
||||
|
@ -63,7 +63,7 @@ src-block and if so then run the appropriate source block from
|
|||
the Library."
|
||||
(interactive)
|
||||
(let ((info (org-babel-lob-get-info)))
|
||||
(if info (progn (org-babel-lob-execute info) t) nil)))
|
||||
(if (first info) (progn (org-babel-lob-execute info) t) nil)))
|
||||
|
||||
(add-hook 'org-ctrl-c-ctrl-c-hook 'org-babel-lob-execute-maybe)
|
||||
|
||||
|
@ -81,13 +81,16 @@ the word 'call'."
|
|||
(save-excursion
|
||||
(move-beginning-of-line 1)
|
||||
(if (looking-at org-babel-lob-one-liner-regexp)
|
||||
(org-babel-clean-text-properties
|
||||
(format "%s(%s)" (match-string 1) (match-string 2)))))))
|
||||
|
||||
(mapcar #'org-babel-clean-text-properties
|
||||
(list (format "%s(%s)" (match-string 1) (match-string 2))
|
||||
(match-string 3)))))))
|
||||
|
||||
(defun org-babel-lob-execute (info)
|
||||
(let ((params (org-babel-merge-params
|
||||
org-babel-default-header-args
|
||||
(org-babel-parse-header-arguments (concat ":var results=" info)))))
|
||||
(org-babel-parse-header-arguments
|
||||
(org-babel-clean-text-properties
|
||||
(concat ":var results=" (mapconcat #'identity info " ")))))))
|
||||
(org-babel-execute-src-block nil (list "emacs-lisp" "results" params))))
|
||||
|
||||
(provide 'org-babel-lob)
|
||||
|
|
|
@ -480,7 +480,7 @@ line. If no result exists for this block then create a
|
|||
(save-excursion
|
||||
(let* ((on-lob-line (progn (beginning-of-line 1)
|
||||
(looking-at org-babel-lob-one-liner-regexp)))
|
||||
(name (if on-lob-line (org-babel-lob-get-info) (org-babel-get-src-block-name)))
|
||||
(name (if on-lob-line (first (org-babel-lob-get-info)) (org-babel-get-src-block-name)))
|
||||
(head (unless on-lob-line (org-babel-where-is-src-block-head))) end)
|
||||
(when head (goto-char head))
|
||||
(or (and name (org-babel-find-named-result name))
|
||||
|
|
Loading…
Reference in a new issue