Re: verbatim shorthand problem

2023-08-31 Thread Arash Esbati
Mandar Mitra  writes:

> Arash Esbati wrote (Fri, Aug 25, 2023 at 11:38:36AM +0200):
>> Can you please file a bug report for this, incl. a MWE starting with
>> emacs -Q?  TIA.
>> 
>> For the time being, you can use delimiters instead of braces for the
>> optional argument which works, e.g.:
>> 
>> \lstinline[language=C,basicstyle=\ttfamily]|for (i=0; i<8; i++) 
>> printf("%c\n"), str1 [ i]);|
>
> Thanks very much for confirming, and for the work-around! Will file
> the bug report with an MWE this weekend.

I think I now see what's going wrong.  Can you please apply this patch
to font-latex.el and try it again?  I presume you're using AUCTeX from
the repo.

--8<---cut here---start->8---
diff --git a/font-latex.el b/font-latex.el
index 7617b5cc..083f72b4 100644
--- a/font-latex.el
+++ b/font-latex.el
@@ -1084,7 +1084,7 @@ have changed."
   ;; An opening curly brace as delimiter is valid, but
   ;; allowing it might screw up fontification of stuff
   ;; like "\url{...} foo \textbf{<--!...}".
-  "\\([^a-z@*\n\f{]\\).*?"
+  "\\([^a-z@*\n\f{[]\\).*?"
   ;; Give an escape char at the end of the verbatim
   ;; construct punctuation syntax.  Prevents wrong
   ;; fontification of stuff like "\verb|foo\|".
--8<---cut here---end--->8---

Best, Arash



Re: verbatim shorthand problem

2023-08-25 Thread Mandar Mitra
Arash Esbati wrote (Fri, Aug 25, 2023 at 11:38:36AM +0200):
> Can you please file a bug report for this, incl. a MWE starting with
> emacs -Q?  TIA.
> 
> For the time being, you can use delimiters instead of braces for the
> optional argument which works, e.g.:
> 
> \lstinline[language=C,basicstyle=\ttfamily]|for (i=0; i<8; i++) 
> printf("%c\n"), str1 [ i]);|

Thanks very much for confirming, and for the work-around! Will file the bug 
report with an MWE this weekend.

Warm regards,
Mandar.



Re: verbatim shorthand problem

2023-08-25 Thread Arash Esbati
Arash Esbati  writes:

> For the time being, you can use delimiters instead of braces for the
> optional argument which works, e.g.:
  

mandatory argument, sorry.

> \lstinline[language=C,basicstyle=\ttfamily]|for (i=0; i<8; i++) 
> printf("%c\n"), str1 [ i]);|



Re: verbatim shorthand problem

2023-08-25 Thread Arash Esbati
Mandar Mitra  writes:

> I'm facing a fontification problem with \lstinline + beamer. Just
> wondering if it might be vaguely related to your fix for
> fancyvrb.el. I have the following line in a frame environment:
>
> \lstinline[language=C,basicstyle=\ttfamily]{for (i=0; i<8; i++) 
> printf("%c\n", str1[i]);} \\
>
> The attached screenshot suggests that the closing ] of str1[i] somehow
> throws fontification off-track.

No, it has nothing to do with my latest change to fancyvrb.el.  I can
reproduce what you describe but I don't understand why.  As you said,
AUCTeX currently gets confused by the pair of brackets inside the
mandatory argument

> If this does NOT sound like an "Ah, of course" type problem, then I'll
> try and put together an MWE starting with emacs -Q. Could you please
> let me know?

Can you please file a bug report for this, incl. a MWE starting with
emacs -Q?  TIA.

For the time being, you can use delimiters instead of braces for the
optional argument which works, e.g.:

\lstinline[language=C,basicstyle=\ttfamily]|for (i=0; i<8; i++) printf("%c\n"), 
str1 [ i]);|

Best, Arash



Re: verbatim shorthand problem

2023-08-22 Thread Mandar Mitra
Arash Esbati wrote (Fri, Aug 18, 2023 at 01:46:12PM +0200):
> Werner LEMBERG  writes:
> 
> > ... the phrase *shouldn't* is not something I really like :-)
> 
> I thought so ;-)
> 
> I installed a change (fe3ef154) and now fancyvrb.el supports verbatim
> characters OOTB.  Note that you have to set `LaTeX-fancyvrb-chars'.  Do
> you want to give it a roll?

I'm facing a fontification problem with \lstinline + beamer. Just wondering if 
it might be vaguely related to your fix for fancyvrb.el. I have the following 
line in a frame environment:

\lstinline[language=C,basicstyle=\ttfamily]{for (i=0; i<8; i++) printf("%c\n", 
str1[i]);} \\

The attached screenshot suggests that the closing ] of str1[i] somehow throws 
fontification off-track.

If this does NOT sound like an "Ah, of course" type problem, then I'll try and 
put together an MWE starting with emacs -Q. Could you please let me know?

Many thanks,
Mandar.

lstinline.pdf
Description: Adobe PDF document


Re: verbatim shorthand problem

2023-08-18 Thread Werner LEMBERG


> I installed a change (fe3ef154) and now fancyvrb.el supports
> verbatim characters OOTB.  Note that you have to set
> `LaTeX-fancyvrb-chars'.  Do you want to give it a roll?

It works fine, thanks for the quick fix!


Werner



Re: verbatim shorthand problem

2023-08-18 Thread Arash Esbati
Werner LEMBERG  writes:

> ... the phrase *shouldn't* is not something I really like :-)

I thought so ;-)

I installed a change (fe3ef154) and now fancyvrb.el supports verbatim
characters OOTB.  Note that you have to set `LaTeX-fancyvrb-chars'.  Do
you want to give it a roll?

Best, Arash



Re: verbatim shorthand problem

2023-08-18 Thread Werner LEMBERG


> You could try something like this in your .tex file:
> 
>   \usepackage{shortvrb,fvextra}

Yeah, I considered that too but ...

> It shouldn't break your .tex file and will help AUCTeX to DTRT.

... the phrase *shouldn't* is not something I really like :-)

>> Or maybe it makes sense to always activate the (possibly adapted)
>> 'shortvrb' style for 'fancyvrb'?
> 
> I think the best option would be to add the corresponding code from
> 'shortvrb' to 'fancyvrb'.  I put that on my list.

Thanks!


Werner



Re: verbatim shorthand problem

2023-08-18 Thread Arash Esbati
Werner LEMBERG  writes:

> [auctex git version around May 11th, 2023]
>
>
> If I have a document like this
>
> ```
> \documentclass{article}
>
> \usepackage{fvextra}
> \DefineShortVerb{\|}
>
> \begin{document}
> |foo|
> \end{document}
>
> %%% Local Variables:
> %%% mode: latex
> %%% TeX-master: t
> %%% LaTeX-shortvrb-chars: (?|)
> %%% End:
> ```
>
> `|foo|` is not fontified as verbatim input.  I have to add
>
> ```
> %%% eval: (TeX-run-style-hooks "shortvrb")
> ```
>
> to the local variable block to get proper fontification.  Is there a
> more elegant solution?

You could try something like this in your .tex file:

  \usepackage{shortvrb,fvextra}

It shouldn't break your .tex file and will help AUCTeX to DTRT.

> Or maybe it makes sense to always activate the (possibly adapted)
> 'shortvrb' style for 'fancyvrb'?

I think the best option would be to add the corresponding code from
'shortvrb' to 'fancyvrb'.  I put that on my list.

Best, Arash



verbatim shorthand problem

2023-08-17 Thread Werner LEMBERG


[auctex git version around May 11th, 2023]


If I have a document like this

```
\documentclass{article}

\usepackage{fvextra}
\DefineShortVerb{\|}

\begin{document}
|foo|
\end{document}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% LaTeX-shortvrb-chars: (?|)
%%% End:
```

`|foo|` is not fontified as verbatim input.  I have to add

```
%%% eval: (TeX-run-style-hooks "shortvrb")
```

to the local variable block to get proper fontification.  Is there a
more elegant solution?  Or maybe it makes sense to always activate the
(possibly adapted) 'shortvrb' style for 'fancyvrb'?


Werner