Re: [AUCTeX] fontification question

2017-04-28 Thread Arash Esbati
Mosè Giordano  writes:

> I think that start writing tests for fontification may be a good idea
> at some point ;-)

True, I started with it sometimes ago as I was playing with
fontification of verb macros:

http://git.savannah.gnu.org/cgit/auctex.git/tree/tests/latex/fontification-verb-macros.tex

> Fontification tends to be often broken and it's hard to understand
> what was actually broken and what's the status-quo that we want to
> preserve.

You're right about "how do we want to have it in the first place?"  I
put my idea behind my patch in the document attached.

Comments welcome.

Best, Arash



fontification-general.tex
Description: TeX document
___
auctex mailing list
auctex@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex


Re: [AUCTeX] fontification question

2017-04-28 Thread Mosè Giordano
I think that start writing tests for fontification may be a good idea
at some point ;-)  Fontification tends to be often broken and it's
hard to understand what was actually broken and what's the status-quo
that we want to preserve.

Bye,
Mosè

2017-04-28 13:32 GMT+02:00 Arash Esbati :
> Arash Esbati  writes:
>
>> Tassilo Horn  writes:
>>
>>> Ah, right. Well, then I guess your patch makes sense. Feel free to
>>> commit it.
>>
>> Done.  Best, Arash
>
> Well, I have found one use-case where the patch still doesn't fit: expl3
> syntax.  Please consider this snippet:
>
> \cs_new:Npn \foo_bar:Nn #1#2
> {
>   \cs_if_exist:NTF #1
>   { \__foo_bar:n {#2} }
>   { \__foo_bar:nn {#2} { literal } }
> }
>
> Current code doesn't work on \__foo_bar:n.  My plan is to install this
> patch:
>
> --8<---cut here---start->8---
> diff --git a/font-latex.el b/font-latex.el
> index ea3e829a..2f662965 100644
> --- a/font-latex.el
> +++ b/font-latex.el
> @@ -1782,6 +1782,11 @@ marks boundaries for searching for group ends."
>   (throw 'extend group-start)
>nil)))
>
> +(defvar font-latex-match-simple-exclude-list
> +  '("-" "," "/" "&" "#" "_")
> +  "List of characters directly after \"\\\" excluded from fontification.
> +Each character is a string.")
> +
>  (defun font-latex-match-simple-command (limit)
>"Search for command like \\foo before LIMIT."
>;; \s_ matches chars with symbol syntax, \sw chars with word syntax, \s. 
> chars
> @@ -1793,7 +1798,10 @@ marks boundaries for searching for group ends."
> "\\(\\s_\\|\\sw\\|\\s.\\)\\(?:\\s_\\|\\sw\\)*" limit 
> t)))
>  (pos (funcall search)))
>  (while (and pos
> -   (member (match-string 1) '("-" "," "/" "&" "#" "_")))
> +   (member (match-string 1)
> +   (if (eq major-mode 'doctex-mode)
> +   (remove "_" font-latex-match-simple-exclude-list)
> + font-latex-match-simple-exclude-list)))
>(setq pos (funcall search)))
>  pos))
> --8<---cut here---end--->8---
>
> Then it works at least in doctex-mode.  I'm reluctant to include
> something like this in expl3.el:
>
> (set (make-local-variable 'font-latex-match-simple-exclude-list)
>  (remove "_" font-latex-match-simple-exclude-list))
>
> It breaks too much for little benefit.  I will also contact the author
> of expl3.el; he tends to have good ideas :-)
>
> Best, Arash
>

___
auctex mailing list
auctex@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex


Re: [AUCTeX] fontification question

2017-04-28 Thread Arash Esbati
Arash Esbati  writes:

> Tassilo Horn  writes:
>
>> Ah, right. Well, then I guess your patch makes sense. Feel free to
>> commit it.
>
> Done.  Best, Arash

Well, I have found one use-case where the patch still doesn't fit: expl3
syntax.  Please consider this snippet:

\cs_new:Npn \foo_bar:Nn #1#2
{
  \cs_if_exist:NTF #1
  { \__foo_bar:n {#2} }
  { \__foo_bar:nn {#2} { literal } }
}

Current code doesn't work on \__foo_bar:n.  My plan is to install this
patch:

--8<---cut here---start->8---
diff --git a/font-latex.el b/font-latex.el
index ea3e829a..2f662965 100644
--- a/font-latex.el
+++ b/font-latex.el
@@ -1782,6 +1782,11 @@ marks boundaries for searching for group ends."
  (throw 'extend group-start)
   nil)))

+(defvar font-latex-match-simple-exclude-list
+  '("-" "," "/" "&" "#" "_")
+  "List of characters directly after \"\\\" excluded from fontification.
+Each character is a string.")
+
 (defun font-latex-match-simple-command (limit)
   "Search for command like \\foo before LIMIT."
   ;; \s_ matches chars with symbol syntax, \sw chars with word syntax, \s. 
chars
@@ -1793,7 +1798,10 @@ marks boundaries for searching for group ends."
"\\(\\s_\\|\\sw\\|\\s.\\)\\(?:\\s_\\|\\sw\\)*" limit 
t)))
 (pos (funcall search)))
 (while (and pos
-   (member (match-string 1) '("-" "," "/" "&" "#" "_")))
+   (member (match-string 1)
+   (if (eq major-mode 'doctex-mode)
+   (remove "_" font-latex-match-simple-exclude-list)
+ font-latex-match-simple-exclude-list)))
   (setq pos (funcall search)))
 pos))
--8<---cut here---end--->8---

Then it works at least in doctex-mode.  I'm reluctant to include
something like this in expl3.el:

(set (make-local-variable 'font-latex-match-simple-exclude-list) 
 (remove "_" font-latex-match-simple-exclude-list))

It breaks too much for little benefit.  I will also contact the author
of expl3.el; he tends to have good ideas :-)

Best, Arash

___
auctex mailing list
auctex@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex