Function: org-babel-insert-header-arg

org-babel-insert-header-arg is an autoloaded, interactive and byte-compiled function defined in ob-core.el.gz.

Signature

(org-babel-insert-header-arg &optional HEADER-ARG VALUE)

Documentation

Insert a header argument and its value.

HEADER-ARG and VALUE, when provided, are the header argument name and its value. When HEADER-ARG or VALUE are nil, offer interactive completion from lists of common args and values.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/org/ob-core.el.gz
;;;###autoload
(defun org-babel-insert-header-arg (&optional header-arg value)
  "Insert a header argument and its value.
HEADER-ARG and VALUE, when provided, are the header argument name and
its value.  When HEADER-ARG or VALUE are nil, offer interactive
completion from lists of common args and values."
  (interactive)
  (let* ((info (org-babel-get-src-block-info 'no-eval))
	 (lang (car info))
	 (begin (nth 5 info))
	 (lang-headers (intern (concat "org-babel-header-args:" lang)))
	 (headers (org-babel-combine-header-arg-lists
		   org-babel-common-header-args-w-values
		   (when (boundp lang-headers) (eval lang-headers t))))
	 (header-arg (or header-arg
			 (completing-read
			  "Header Arg: "
			  (mapcar
			   (lambda (header-spec) (symbol-name (car header-spec)))
			   headers))))
	 (vals (cdr (assoc (intern header-arg) headers)))
	 (value (or value
		    (cond
		     ((eq vals :any)
		      (read-from-minibuffer "value: "))
		     ((listp vals)
		      (mapconcat
		       (lambda (group)
			 (let ((arg (completing-read
				     "Value: "
				     (cons "default"
					   (mapcar #'symbol-name group)))))
			   (if (and arg (not (string= "default" arg)))
			       (concat arg " ")
			     "")))
		       vals ""))))))
    (save-excursion
      (goto-char begin)
      (goto-char (line-end-position))
      (unless (= (char-before (point)) ?\ ) (insert " "))
      (insert ":" header-arg) (when value (insert " " value)))))