Browse Source

ox-latex: Do not overwrite provided numbering options in minted and listings

* lisp/ox-latex.el (org-latex-src-block): Do not overwrite provided
  numbering options in minted and listings.

If "numbers" option (resp. "linenos" option) is provided in
`org-latex-listings-options' (resp. `org-latex-minted-options'),
export will ignore "+n" and "-n" switches from source blocks.
Nicolas Goaziou 12 years ago
parent
commit
6ab71385f8
1 changed files with 14 additions and 10 deletions
  1. 14 10
      lisp/ox-latex.el

+ 14 - 10
lisp/ox-latex.el

@@ -2102,7 +2102,9 @@ contextual information."
 		"\\begin{minted}[%s]{%s}\n%s\\end{minted}"
 		"\\begin{minted}[%s]{%s}\n%s\\end{minted}"
 		;; Options.
 		;; Options.
 		(org-latex--make-option-string
 		(org-latex--make-option-string
-		 (if (not num-start) org-latex-minted-options
+		 (if (or (not num-start)
+			 (assoc "linenos" org-latex-minted-options))
+		     org-latex-minted-options
 		   (append `(("linenos")
 		   (append `(("linenos")
 			     ("firstnumber" ,(number-to-string (1+ num-start))))
 			     ("firstnumber" ,(number-to-string (1+ num-start))))
 			   org-latex-minted-options)))
 			   org-latex-minted-options)))
@@ -2147,15 +2149,17 @@ contextual information."
 	   ;; Options.
 	   ;; Options.
 	   (format "\\lstset{%s}\n"
 	   (format "\\lstset{%s}\n"
 		   (org-latex--make-option-string
 		   (org-latex--make-option-string
-		    (append org-latex-listings-options
-			    `(("language" ,lst-lang))
-			    (when label `(("label" ,label)))
-			    (when caption-str `(("caption" ,caption-str)))
-			    (cond ((not num-start) '(("numbers" "none")))
-				  ((zerop num-start) '(("numbers" "left")))
-				  (t `(("numbers" "left")
-				       ("firstnumber"
-					,(number-to-string (1+ num-start)))))))))
+		    (append
+		     org-latex-listings-options
+		     `(("language" ,lst-lang))
+		     (when label `(("label" ,label)))
+		     (when caption-str `(("caption" ,caption-str)))
+		     (cond ((assoc "numbers" org-latex-listings-options) nil)
+			   ((not num-start) '(("numbers" "none")))
+			   ((zerop num-start) '(("numbers" "left")))
+			   (t `(("numbers" "left")
+				("firstnumber"
+				 ,(number-to-string (1+ num-start)))))))))
 	   ;; Source code.
 	   ;; Source code.
 	   (format
 	   (format
 	    "\\begin{lstlisting}\n%s\\end{lstlisting}"
 	    "\\begin{lstlisting}\n%s\\end{lstlisting}"