diff --git a/lisp/org-exp.el b/lisp/org-exp.el index 00fd6c8..9de5e5f 100644 --- a/lisp/org-exp.el +++ b/lisp/org-exp.el @@ -2204,6 +2204,8 @@ in the list) and remove property and value from the list in LISTVAR." (defvar htmlp) ;; dynamically scoped (defvar latexp) ;; dynamically scoped (defvar org-export-latex-verbatim-wrap) ;; defined in org-latex.el +(defvar org-export-latex-listings) ;; defined in org-latex.el +(defvar org-export-latex-listings-langs) ;; defined in org-latex.el (defun org-export-format-source-code-or-example (backend lang code &optional opts indent) @@ -2310,8 +2312,20 @@ INDENT was the original indentation of the block." ((eq backend 'latex) (setq rtn (org-export-number-lines rtn 'latex 0 0 num cont rpllbl fmt)) (concat "\n#+BEGIN_LaTeX\n" - (org-add-props (concat (car org-export-latex-verbatim-wrap) - rtn (cdr org-export-latex-verbatim-wrap)) + (org-add-props + (if org-export-latex-listings + (concat + (if lang + (let* ((lang-sym (intern (concat ":" lang))) + (lstlang (or (plist-get org-export-latex-listings-langs + lang-sym) + lang))) + (format "\\lstset{language=%s}\n" lstlang)) + "") + "\\begin{lstlisting}\n" + rtn "\\end{lstlisting}\n") + (concat (car org-export-latex-verbatim-wrap) + rtn (cdr org-export-latex-verbatim-wrap))) '(org-protected t)) "#+END_LaTeX\n\n")) ((eq backend 'ascii) diff --git a/lisp/org-latex.el b/lisp/org-latex.el index fdf9ae2..f80e221 100644 --- a/lisp/org-latex.el +++ b/lisp/org-latex.el @@ -69,6 +69,9 @@ org-deadline-string "\\|" org-closed-string"\\)") "Regexp matching special time planning keywords plus the time after it.") +(defvar org-export-latex-listings nil + "If non-nil then source code blocks will be fontified using the +listings package.") (defvar latexp) ; dynamically scoped from org.el (defvar re-quote) ; dynamically scoped from org.el @@ -297,6 +300,12 @@ Defaults to \\begin{verbatim} and \\end{verbatim}." :type '(cons (string :tag "Open") (string :tag "Close"))) +(defcustom org-export-latex-listings-langs + '(:emacs-lisp "lisp") + "Property list mapping languages to their listing language counterpart." + :group 'org-export-latex + :type 'plist) + (defcustom org-export-latex-remove-from-headlines '(:todo nil :priority nil :tags nil) "A plist of keywords to remove from headlines. OBSOLETE.