0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-08-25 05:32:51 +00:00

LaTeX export: Automatically choose \verb delimiter

This commit is contained in:
Carsten Dominik 2009-03-14 08:36:48 +01:00
parent 722fc9a490
commit 8461b96e79
2 changed files with 27 additions and 5 deletions

View file

@ -1,5 +1,10 @@
2009-03-14 Carsten Dominik <carsten.dominik@gmail.com> 2009-03-14 Carsten Dominik <carsten.dominik@gmail.com>
* org-export-latex.el (org-export-latex-emphasis-alist): Better
defaults for verbose emphasis.
(org-export-latex-emph-format): New function.
(org-export-latex-fontify): Call `org-export-latex-emph-format'.
* org-agenda.el (org-agenda-menu): Add new commands to menu. * org-agenda.el (org-agenda-menu): Add new commands to menu.
(org-agenda-do-date-later, org-agenda-do-date-earlier) (org-agenda-do-date-later, org-agenda-do-date-earlier)
(org-agenda-date-later-minutes, org-agenda-date-earlier-minutes) (org-agenda-date-later-minutes, org-agenda-date-earlier-minutes)

View file

@ -165,12 +165,14 @@ to represent the section title."
("/" "\\emph{%s}" nil) ("/" "\\emph{%s}" nil)
("_" "\\underline{%s}" nil) ("_" "\\underline{%s}" nil)
("+" "\\texttt{%s}" nil) ("+" "\\texttt{%s}" nil)
("=" "\\verb=%s=" nil) ("=" "\\verb" t)
("~" "\\verb~%s~" t)) ("~" "\\verb" t))
"Alist of LaTeX expressions to convert emphasis fontifiers. "Alist of LaTeX expressions to convert emphasis fontifiers.
Each element of the list is a list of three elements. Each element of the list is a list of three elements.
The first element is the character used as a marker for fontification. The first element is the character used as a marker for fontification.
The second element is a formatting string to wrap fontified text with. The second element is a formatting string to wrap fontified text with.
If it is \"\\verb\", Org will automatically select a deimiter
character that is not in the string.
The third element decides whether to protect converted text from other The third element decides whether to protect converted text from other
conversions." conversions."
:group 'org-export-latex :group 'org-export-latex
@ -1203,8 +1205,7 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
(string-match (string-match
"[|\n]" (buffer-substring beg end)))))) "[|\n]" (buffer-substring beg end))))))
(setq rpl (concat (match-string 1) (setq rpl (concat (match-string 1)
(format (org-export-latex-protect-char-in-string (org-export-latex-emph-format (cadr emph)
'("\\" "{" "}") (cadr emph))
(match-string 4)) (match-string 4))
(match-string 5))) (match-string 5)))
(if (caddr emph) (if (caddr emph)
@ -1212,6 +1213,22 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
(replace-match rpl t t))) (replace-match rpl t t)))
(backward-char))) (backward-char)))
(defun org-export-latex-emph-format (format string)
"Format an emphasis string and handle the \\verb special case."
(when (equal format "\\verb")
(save-match-data
(let ((ll "~,./?;':\"|!@#%^&-_=+abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ<>()[]{}"))
(catch 'exit
(loop for i from 0 to (1- (length ll)) do
(if (not (string-match (regexp-quote (substring ll i (1+ i)))
string))
(progn
(setq format (concat "\\verb" (substring ll i (1+ i))
"%s" (substring ll i (1+ i))))
(throw 'exit nil))))))))
(setq string (org-export-latex-protect-string
(format format string))))
(defun org-export-latex-links () (defun org-export-latex-links ()
;; Make sure to use the LaTeX hyperref and graphicx package ;; Make sure to use the LaTeX hyperref and graphicx package
;; or send some warnings. ;; or send some warnings.