emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Carsten Dominik <carsten.dominik@gmail.com>
To: Carsten Dominik <carsten.dominik@gmail.com>
Cc: Org Mode <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] Distinguish = and ~ delimiters in LaTeX export
Date: Sun, 30 Jan 2011 16:32:46 +0100	[thread overview]
Message-ID: <D7C7FE9C-D601-4EDC-B06E-D576A68D4729@gmail.com> (raw)
In-Reply-To: <A6B771FB-7E8B-474E-8A12-E13363D78FFC@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 31 bytes --]

Forgot to attach the patch...


[-- Attachment #2: verb.patch --]
[-- Type: application/octet-stream, Size: 2349 bytes --]

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 ()


[-- Attachment #3: Type: text/plain, Size: 1694 bytes --]





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
>


[-- Attachment #4: Type: text/plain, Size: 201 bytes --]

_______________________________________________
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

  reply	other threads:[~2011-01-30 15:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-29 18:40 [PATCH] Distinguish = and ~ delimiters in LaTeX export Thomas S. Dye
2011-01-30 15:30 ` Carsten Dominik
2011-01-30 15:32   ` Carsten Dominik [this message]
2011-01-30 18:23   ` Thomas S. Dye
2011-02-01 10:30     ` Bastien
2011-01-30 17:49 ` Sébastien Vauban
2011-01-30 18:44   ` Thomas S. Dye
2011-02-01 11:09   ` Bastien
2011-02-01 11:17   ` Carsten Dominik
2011-02-01 17:04     ` Bastien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D7C7FE9C-D601-4EDC-B06E-D576A68D4729@gmail.com \
    --to=carsten.dominik@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).