From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: [PATCH] Distinguish = and ~ delimiters in LaTeX export Date: Sun, 30 Jan 2011 16:32:46 +0100 Message-ID: References: <7D426067-ED81-42E7-B517-29F06F35EB8F@tsdye.com> Mime-Version: 1.0 (Apple Message framework v936) Content-Type: multipart/mixed; boundary=Apple-Mail-1-266786408 Return-path: Received: from [140.186.70.92] (port=33757 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PjZGm-0006WC-7n for emacs-orgmode@gnu.org; Sun, 30 Jan 2011 10:32:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PjZGk-000357-Sd for emacs-orgmode@gnu.org; Sun, 30 Jan 2011 10:32:52 -0500 Received: from mail-fx0-f41.google.com ([209.85.161.41]:49061) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PjZGk-00034m-Hp for emacs-orgmode@gnu.org; Sun, 30 Jan 2011 10:32:50 -0500 Received: by fxm12 with SMTP id 12so5759520fxm.0 for ; Sun, 30 Jan 2011 07:32:49 -0800 (PST) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Carsten Dominik Cc: Org Mode --Apple-Mail-1-266786408 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Forgot to attach the patch... --Apple-Mail-1-266786408 Content-Disposition: attachment; filename=verb.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="verb.patch" Content-Transfer-Encoding: 7bit Changes at master Modified lisp/org-latex.el diff --git a/lisp/org-latex.el b/lisp/org-latex.el index 4d2d79a..9b32943 100644 --- a/lisp/org-latex.el +++ b/lisp/org-latex.el @@ -230,14 +230,15 @@ are written as utf8 files." ("/" "\\emph{%s}" nil) ("_" "\\underline{%s}" nil) ("+" "\\st{%s}" nil) - ("=" "\\verb" t) + ("=" "\\protectedtexttt" t) ("~" "\\verb" t)) "Alist of LaTeX expressions to convert emphasis fontifiers. Each element of the list is a list of three elements. The first element is the character used as a marker for fontification. The second element is a formatting string to wrap fontified text with. If it is \"\\verb\", Org will automatically select a delimiter -character that is not in the string. +character that is not in the string. \"\\protectedtexttt\" will use \\texttt +to typeset and try to protect special characters. The third element decides whether to protect converted text from other conversions." :group 'org-export-latex @@ -1977,12 +1978,14 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER." (replace-match rpl t t))) (backward-char))) -(defvar org-export-latex-use-verb nil) +(defvar org-export-latex-use-verb t + "Toggle the use of \\verb for ~ emphasis. +Set to nil for \\texttt, t for \\verb.") (defun org-export-latex-emph-format (format string) "Format an emphasis string and handle the \\verb special case." - (when (equal format "\\verb") + (when (member format '("\\verb" "\\protectedtexttt")) (save-match-data - (if org-export-latex-use-verb + (if (and (equal format "\\verb") org-export-latex-use-verb) (let ((ll "~,./?;':\"|!@#%^&-_=+abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ<>()[]{}")) (catch 'exit (loop for i from 0 to (1- (length ll)) do @@ -2005,7 +2008,9 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER." (setq string (substring string (1+ (match-beginning 0)))) (setq char (or (cdr (assoc char trans)) (concat "\\" char)) rtn (concat rtn char))) - (setq string (concat rtn string) format "\\texttt{%s}"))))) + (setq string (concat rtn string) format "\\texttt{%s}") + (while (string-match "--" string) + (setq string (replace-match "-{}-" t t string))))))) (format format string)) (defun org-export-latex-links () --Apple-Mail-1-266786408 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit On Jan 30, 2011, at 4:30 PM, Carsten Dominik wrote: > Aloha Tom, > > On Jan 29, 2011, at 7:40 PM, Thomas S. Dye wrote: > >> Aloha all, >> >> The default value of org-export-latex-emphasis-alist treats the = >> and ~ delimiters as \\verb. Both settings are ignored because org- >> export-latex-use-verb is nil by default. The = and ~ delimiters >> produce \texttt{} instead of \verb. This patch distinguishes = and >> ~ by changing the default for = to \\texttt{%s}. >> >> The docstring has also been changed to refer to org-export-latex- >> use-verb. >> >> With this patch, users exporting to LaTeX will be able to use = for >> \texttt text in LaTeX moving environments and ~ for \verb text in >> places where it is safe to use this construct. > > This is a pretty good patch, but I think we should still modify it. > Org users traditionally use =stuff= to mark code pieces, and I think > it is still important to escape special characters like ^ and ~ and > others. > > The modified patch below does the following: > > - Like your patch, it makes Org use \\verb for the ~...~ emphasis. > - For =...= emphasis, it uses a new keyword \\protectedtexttt. > This will protect special characters and then do texttt. And I > have extended the protection to include multiple hyphens by > converting > "--" to "-{}-". > > Do you agree with this solution? > > - Carsten > > >> >> Tom >> >> <0001-Changed-org-export-latex-emphasis-alist-to-distingui.patch> >> _______________________________________________ >> Emacs-orgmode mailing list >> Please use `Reply All' to send replies to the list. >> Emacs-orgmode@gnu.org >> http://lists.gnu.org/mailman/listinfo/emacs-orgmode > --Apple-Mail-1-266786408 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --Apple-Mail-1-266786408--