Function: org-latex-src--engrave-code

org-latex-src--engrave-code is a byte-compiled function defined in ox-latex.el.gz.

Signature

(org-latex-src--engrave-code CONTENT LANG &optional THEME OPTIONS INLINE)

Documentation

Engrave CONTENT to LaTeX in a LANG-mode buffer, and give the result.

When the THEME symbol is non-nil, that theme will be used.

When INLINE is nil, a Verbatim environment wrapped in a Code environment will be used. When t, a Verb command will be used.

When OPTIONS is provided, as either a string or list of key-value pairs accepted by org-latex--make-option-string, it is passed to the Verbatim environment or Verb command.

Source Code

;; Defined in /usr/src/emacs/lisp/org/ox-latex.el.gz
(defun org-latex-src--engrave-code (content lang &optional theme options inline)
  "Engrave CONTENT to LaTeX in a LANG-mode buffer, and give the result.
When the THEME symbol is non-nil, that theme will be used.

When INLINE is nil, a Verbatim environment wrapped in a Code
environment will be used.  When t, a Verb command will be used.

When OPTIONS is provided, as either a string or list of key-value
pairs accepted by `org-latex--make-option-string', it is passed
to the Verbatim environment or Verb command."
  (if (require 'engrave-faces-latex nil t)
      (let* ((lang-mode (and lang (org-src-get-lang-mode lang)))
             (engrave-faces-current-preset-style
              (if theme
                  (engrave-faces-get-theme theme)
                engrave-faces-current-preset-style))
             (engraved-buffer
              (with-temp-buffer
                (insert (replace-regexp-in-string "\n\\'" "" content))
                (when lang-mode
                  (if (functionp lang-mode)
                      (funcall lang-mode)
                    (warn "Cannot engrave code as %s. %s is undefined."
                          lang lang-mode)))
                (engrave-faces-latex-buffer)))
             (engraved-code
              (with-current-buffer engraved-buffer
                (buffer-string)))
             (engraved-options
              (when options
                (concat "["
                        (if (listp options)
                            (org-latex--make-option-string options)
                          options)
                        "]")))
             (engraved-wrapped
              (if inline
                  (concat "\\Verb" engraved-options "{" engraved-code "}")
                (concat "\\begin{Code}\n\\begin{Verbatim}" engraved-options "\n"
                        engraved-code "\n\\end{Verbatim}\n\\end{Code}"))))
        (kill-buffer engraved-buffer)
        (if theme
            (concat "{\\engravedtheme"
                    (replace-regexp-in-string "[^A-Za-z]" ""
                                              (symbol-name theme))
                    engraved-wrapped
                    "}")
          engraved-wrapped))
    (user-error "Cannot engrave code as `engrave-faces-latex' is unavailable")))