Function: org-babel-examplify-region

org-babel-examplify-region is an interactive and byte-compiled function defined in ob-core.el.gz.

Signature

(org-babel-examplify-region BEG END &optional RESULTS-SWITCHES INLINE)

Documentation

Comment out region BEG..END using the inline == or : org example quote.

When INLINE is non-nil, use the inline verbatim markup. When INLINE is nil and RESULTS-SWITCHES is non-nil, RESULTS-SWITCHES is used as a string to be appended to #+begin_example line.

Key Bindings

Aliases

org-babel-examplize-region (obsolete since 9.0)

Source Code

;; Defined in /usr/src/emacs/lisp/org/ob-core.el.gz
(defun org-babel-examplify-region (beg end &optional results-switches inline)
  "Comment out region BEG..END using the inline `==' or `: ' org example quote.
When INLINE is non-nil, use the inline verbatim markup.
When INLINE is nil and RESULTS-SWITCHES is non-nil, RESULTS-SWITCHES is
used as a string to be appended to #+begin_example line."
  (interactive "*r")
  (let ((maybe-cap
	 (lambda (str)
	   (if org-babel-uppercase-example-markers (upcase str) str))))
    (if inline
	(save-excursion
	  (goto-char beg)
	  (insert (format org-babel-inline-result-wrap
			  (delete-and-extract-region beg end))))
      (let ((size (count-lines beg end)))
	(save-excursion
	  (cond ((= size 0))	      ; do nothing for an empty result
		((< size org-babel-min-lines-for-block-output)
		 (goto-char beg)
		 (dotimes (_ size)
		   (forward-line 0) (insert ": ") (forward-line 1)))
		(t
		 (goto-char beg)
		 (insert (if results-switches
			     (format "%s%s\n"
				     (funcall maybe-cap "#+begin_example")
				     results-switches)
			   (funcall maybe-cap "#+begin_example\n")))
		 (let ((p (point)))
		   (if (markerp end) (goto-char end) (forward-char (- end beg)))
		   (org-escape-code-in-region p (point)))
		 (insert (funcall maybe-cap "#+end_example\n")))))))))