* [PATCH] Distinguish = and ~ delimiters in LaTeX export
@ 2011-01-29 18:40 Thomas S. Dye
2011-01-30 15:30 ` Carsten Dominik
2011-01-30 17:49 ` Sébastien Vauban
0 siblings, 2 replies; 10+ messages in thread
From: Thomas S. Dye @ 2011-01-29 18:40 UTC (permalink / raw)
To: Org Mode
[-- Attachment #1: Type: text/plain, Size: 605 bytes --]
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.
Tom
[-- Attachment #2: 0001-Changed-org-export-latex-emphasis-alist-to-distingui.patch --]
[-- Type: application/octet-stream, Size: 1716 bytes --]
From 024b03e14f4b1348f2f07c25306ee8ab9ee33215 Mon Sep 17 00:00:00 2001
From: Tom Dye <tsd@tsdye.com>
Date: Sat, 29 Jan 2011 08:31:57 -1000
Subject: [PATCH] Changed org-export-latex-emphasis-alist to distinguish = from ~
delimiters. Added reference to org-export-latex-use-verb in docstring.
---
lisp/org-latex.el | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/lisp/org-latex.el b/lisp/org-latex.el
index a45546a..3fd67b0 100644
--- a/lisp/org-latex.el
+++ b/lisp/org-latex.el
@@ -230,16 +230,16 @@ are written as utf8 files."
("/" "\\emph{%s}" nil)
("_" "\\underline{%s}" nil)
("+" "\\st{%s}" nil)
- ("=" "\\verb" t)
+ ("=" "\\texttt{%s}" 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.
-The third element decides whether to protect converted text from other
-conversions."
+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\", and org-export-latex-use-verb is not
+nil, Org will automatically select a delimiter character that is
+not in the string. The third element decides whether to protect
+converted text from other conversions."
:group 'org-export-latex
:type 'alist)
--
1.7.1
[-- Attachment #3: Type: text/plain, Size: 1 bytes --]
[-- 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
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] Distinguish = and ~ delimiters in LaTeX export
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
2011-01-30 18:23 ` Thomas S. Dye
2011-01-30 17:49 ` Sébastien Vauban
1 sibling, 2 replies; 10+ messages in thread
From: Carsten Dominik @ 2011-01-30 15:30 UTC (permalink / raw)
To: Thomas S. Dye; +Cc: Org Mode
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Distinguish = and ~ delimiters in LaTeX export
2011-01-30 15:30 ` Carsten Dominik
@ 2011-01-30 15:32 ` Carsten Dominik
2011-01-30 18:23 ` Thomas S. Dye
1 sibling, 0 replies; 10+ messages in thread
From: Carsten Dominik @ 2011-01-30 15:32 UTC (permalink / raw)
To: Carsten Dominik; +Cc: Org Mode
[-- 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
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] Distinguish = and ~ delimiters in LaTeX export
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 17:49 ` Sébastien Vauban
2011-01-30 18:44 ` Thomas S. Dye
` (2 more replies)
1 sibling, 3 replies; 10+ messages in thread
From: Sébastien Vauban @ 2011-01-30 17:49 UTC (permalink / raw)
To: emacs-orgmode-mXXj517/zsQ
Hi Thomas,
"Thomas S. Dye" wrote:
> 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.
What's the real use of that variable? I mean, wouldn't it be more simple if
Org's export behavior was just based on the contents of
org-export-latex-emphasis-alist? Is there verbatim in it, we use verbatim. Is
is texttt in it, we use texttt...
In fact, in which cases do we want to override what's described in the alist?
Best regards,
Seb
--
Sébastien Vauban
_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode-mXXj517/zsQ@public.gmane.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Distinguish = and ~ delimiters in LaTeX export
2011-01-30 15:30 ` Carsten Dominik
2011-01-30 15:32 ` Carsten Dominik
@ 2011-01-30 18:23 ` Thomas S. Dye
2011-02-01 10:30 ` Bastien
1 sibling, 1 reply; 10+ messages in thread
From: Thomas S. Dye @ 2011-01-30 18:23 UTC (permalink / raw)
To: Carsten Dominik; +Cc: Org Mode
On Jan 30, 2011, at 5:30 AM, 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
>
Aloha Carsten,
Yes, I do. Your patch works here for the use cases I had in mind.
I'm pleased that you were able to make the patch work for other use
cases as well. Also, I like having org-export-latex-use-verb default
to t instead of nil. It is nice to have the \verb command immediately
at hand.
Thanks for looking into this.
All the best,
Tom
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Re: [PATCH] Distinguish = and ~ delimiters in LaTeX export
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
2 siblings, 0 replies; 10+ messages in thread
From: Thomas S. Dye @ 2011-01-30 18:44 UTC (permalink / raw)
To: Sébastien Vauban; +Cc: emacs-orgmode
On Jan 30, 2011, at 7:49 AM, Sébastien Vauban wrote:
> Hi Thomas,
>
> "Thomas S. Dye" wrote:
>> 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.
>
> What's the real use of that variable? I mean, wouldn't it be more
> simple if
> Org's export behavior was just based on the contents of
> org-export-latex-emphasis-alist? Is there verbatim in it, we use
> verbatim. Is
> is texttt in it, we use texttt...
>
> In fact, in which cases do we want to override what's described in
> the alist?
>
> Best regards,
> Seb
>
> --
> Sébastien Vauban
Aloha Seb,
Do you mean the variable org-export-latex-use-verb? I haven't looked
into its history in the git repo. Currently it defaults to nil, so
\verb is not used and \texttt is used in its place.
Carsten has a patch on the list today that changes the default to t,
which means that what you see in the alist is pretty much what you
get. For reasons having to do with typesetting code snippets (that I
don't fully understand), Carsten protects special characters in
\texttt. This means that the alist doesn't contain a markup character
that yields straight \texttt, though it should be straightforward to
add one.
I hope this helps. In any event, it represents the limit of my
understanding of what goes on in org-latex.el, which I freely admit
falls far short of full comprehension.
All the best,
Tom
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Distinguish = and ~ delimiters in LaTeX export
2011-01-30 18:23 ` Thomas S. Dye
@ 2011-02-01 10:30 ` Bastien
0 siblings, 0 replies; 10+ messages in thread
From: Bastien @ 2011-02-01 10:30 UTC (permalink / raw)
To: Thomas S. Dye; +Cc: Org Mode, Carsten Dominik
"Thomas S. Dye" <tsd@tsdye.com> writes:
> Yes, I do. Your patch works here for the use cases I had in mind. I'm
> pleased that you were able to make the patch work for other use cases as
> well. Also, I like having org-export-latex-use-verb default to t instead
> of nil. It is nice to have the \verb command immediately at hand.
>
> Thanks for looking into this.
I have now applied this patch -- thanks to both of you for it!
--
Bastien
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Re: [PATCH] Distinguish = and ~ delimiters in LaTeX export
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
2 siblings, 0 replies; 10+ messages in thread
From: Bastien @ 2011-02-01 11:09 UTC (permalink / raw)
To: Sébastien Vauban; +Cc: emacs-orgmode
Hi Sebastian,
Sébastien Vauban <wxhgmqzgwmuf@spammotel.com> writes:
> What's the real use of that variable? I mean, wouldn't it be more simple if
> Org's export behavior was just based on the contents of
> org-export-latex-emphasis-alist? Is there verbatim in it, we use verbatim. Is
> is texttt in it, we use texttt...
That would be ideal.
But there is no real bijection between Org's sober emphasis markup and
LaTeX markup possibilities. So the purpose of such a variable is to add
some flexibility.
HTH,
--
Bastien
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Re: [PATCH] Distinguish = and ~ delimiters in LaTeX export
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
2 siblings, 1 reply; 10+ messages in thread
From: Carsten Dominik @ 2011-02-01 11:17 UTC (permalink / raw)
To: Sébastien Vauban; +Cc: emacs-orgmode
On Jan 30, 2011, at 6:49 PM, Sébastien Vauban wrote:
> Hi Thomas,
>
> "Thomas S. Dye" wrote:
>> 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.
>
> What's the real use of that variable? I mean, wouldn't it be more
> simple if
> Org's export behavior was just based on the contents of
> org-export-latex-emphasis-alist? Is there verbatim in it, we use
> verbatim. Is
> is texttt in it, we use texttt...
I did put the variable in while I was developing this feature, not
being sure if I could get it to work properly, so to give me
flexibility to switch the feature on and off. The variable is not
meant for the user (then it would have been a defcustom), just a
convenience for the programmer.
Hope this makes it more clear.
- Carsten
>
> In fact, in which cases do we want to override what's described in
> the alist?
>
> Best regards,
> Seb
>
> --
> Sébastien Vauban
>
>
> _______________________________________________
> 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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Re: [PATCH] Distinguish = and ~ delimiters in LaTeX export
2011-02-01 11:17 ` Carsten Dominik
@ 2011-02-01 17:04 ` Bastien
0 siblings, 0 replies; 10+ messages in thread
From: Bastien @ 2011-02-01 17:04 UTC (permalink / raw)
To: Carsten Dominik; +Cc: Sébastien Vauban, emacs-orgmode
Carsten Dominik <carsten.dominik@gmail.com> writes:
> I did put the variable in while I was developing this feature, not being
> sure if I could get it to work properly, so to give me flexibility to
> switch the feature on and off. The variable is not meant for the user
> (then it would have been a defcustom), just a convenience for the
> programmer.
>
> Hope this makes it more clear.
It does -- I've removed this variable now.
Thanks,
--
Bastien
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2011-02-01 17:11 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
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).