emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Entities Parsing Code
@ 2011-09-19 21:39 Pavel Panchekha
  2011-10-08 16:06 ` Carsten Dominik
  0 siblings, 1 reply; 2+ messages in thread
From: Pavel Panchekha @ 2011-09-19 21:39 UTC (permalink / raw)
  To: emacs-orgmode

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

I've been noticing that the org-pretty-entities code incorrectly lexes
numbers as part of TeX command names; for example, if I type $\sim2n^2$, the
\sim will not be replaced with a ~ because the 2 is lexed as part of the
command name.  This is incorrect; in TeX, numbers are not legal parts of a
command name.

Here's a patch that fixes the issue:

diff --git a/lisp/org.el b/lisp/org.el
index 73b1073..0db5a0b 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -5735,7 +5735,7 @@ needs to be inserted at a specific position in the
font-
     (when org-pretty-entities
       (catch 'match
        (while (re-search-forward
-               "\\\\\\([a-zA-Z][a-zA-Z0-9]*\\)\\($\\|[^[:alnum:]\n]\\)"
+               "\\\\\\([a-zA-Z]+\\)\\($\\|[^[:alpha:]\n]\\)"
                limit t)
          (if (and (not (org-in-indented-comment-line))
                   (setq ee (org-entity-get (match-string 1)))

-- 
- Pavel Panchekha

[-- Attachment #2: Type: text/html, Size: 2402 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Entities Parsing Code
  2011-09-19 21:39 Entities Parsing Code Pavel Panchekha
@ 2011-10-08 16:06 ` Carsten Dominik
  0 siblings, 0 replies; 2+ messages in thread
From: Carsten Dominik @ 2011-10-08 16:06 UTC (permalink / raw)
  To: Pavel Panchekha; +Cc: emacs-orgmode


On 19.9.2011, at 23:39, Pavel Panchekha wrote:

> I've been noticing that the org-pretty-entities code incorrectly lexes numbers as part of TeX command names; for example, if I type $\sim2n^2$, the \sim will not be replaced with a ~ because the 2 is lexed as part of the command name.  This is incorrect; in TeX, numbers are not legal parts of a command name.

Hi Pavel, this is on purpose, in order to support names like \frac12.  Most, but not all entity names are strict TeX.  You can work around this by inserting spaces - \sim2n^2 looks
quite unreadable to me anyway - I would, also in a TeX file, always write it like 
\sim 2 n^2

- Carsten

> 
> Here's a patch that fixes the issue:
> 
> diff --git a/lisp/org.el b/lisp/org.el
> index 73b1073..0db5a0b 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -5735,7 +5735,7 @@ needs to be inserted at a specific position in the font-
>      (when org-pretty-entities
>        (catch 'match
>         (while (re-search-forward
> -               "\\\\\\([a-zA-Z][a-zA-Z0-9]*\\)\\($\\|[^[:alnum:]\n]\\)"
> +               "\\\\\\([a-zA-Z]+\\)\\($\\|[^[:alpha:]\n]\\)"
>                 limit t)
>           (if (and (not (org-in-indented-comment-line))
>                    (setq ee (org-entity-get (match-string 1)))
> 
> -- 
> - Pavel Panchekha
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-10-08 16:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-19 21:39 Entities Parsing Code Pavel Panchekha
2011-10-08 16:06 ` Carsten Dominik

Code repositories for project(s) associated with this 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).