[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Provide style file for babel support for Brazilian
From: |
Gustavo Barros |
Subject: |
Re: Provide style file for babel support for Brazilian |
Date: |
Mon, 21 Jun 2021 20:09:34 -0300 |
User-agent: |
mu4e 1.4.15; emacs 27.2 |
Hi Arash,
On Mon, 21 Jun 2021 at 15:22, Arash Esbati <arash@gnu.org> wrote:
As far as I understood, this variable only takes `t' or `nil' for any
given macro, the later does not add the braces, and the former adds
them and places point between the braces. I don't see a way to
emulate the effect `nil' has in `TeX-add-symbols' which is to add the
braces and leave point after the closing brace. Is this indeed the
case, or am I really missing something?
Consider this example:
\documentclass{article}
\usepackage[brazil]{babel}
\begin{document}
\begin{verbatim}
(setq TeX-insert-braces t)
(setq TeX-insert-braces-alist
'(("orda" . nil)))
\end{verbatim}
\ord{} \orda
\end{document}
If you eval the forms inside the verbatim environment, you'd expect
the
results shown above. You don't get them though because brazilian.el
has
these lines:
(TeX-add-symbols
'("ord" 0)
'("ro" 0)
'("orda" 0)
'("ra" 0))
`TeX-parse-macro' in return has code for this comment:
;; Do not add braces if the argument is 0 or -1.
Indeed, `TeX-add-symbols' and `TeX-insert-braces-alist' do step in each
other's toes to some degree. The case you mentioned is one, another is:
\documentclass{article}
\usepackage[brazil]{babel}
\begin{document}
\begin{verbatim}
(TeX-add-symbols
'("orda" nil))
(setq TeX-insert-braces t)
(setq TeX-insert-braces-alist
'(("orda" . t)))
\end{verbatim}
\orda{}{}
\end{document}
I admit that I discovered this behaviour also after your message. I
think we have to adjust our style file accordingly. 0 should only be
used for LaTeX preamble only macros where an empty pair of braces
after
a macros looks odd.
If that's the case, I do have a couple of further general comments.
The first is: wouldn't then a review in the same lines, and for the same
reason, be granted to the old `textcomp.el' macros (which now live in
`latex.el')? (And I admit I had rather these in mind when I insisted,
since the babel macros for Portuguese are not that important, as we had
observed previously).
The second, and this is really just a suggestion/idea, I think it would
be interesting if `TeX-insert-braces-alist' could also control point
position relative to the braces after the macro is inserted. As far as
I can tell, it should not be complicated. Whenever the braces are
inserted (at least when they are inserted by the grace of
`TeX-insert-braces-alist') this happens in `TeX-parse-macro', and the
point position between the braces is handled by the final
`(backward-char)'. It should be trivial to condition that last step to
a particular non-nil value in `TeX-insert-braces-alist'
(e.g. `'point-out'). Of course, this effect is currently also
achievable from `TeX-add-symbols', but that would be more convenient at
the user level, and would also make it smoother to emphasize
`TeX-insert-braces(-alist)' as the main interface for this purpose.
You can try to apply this patch and play with it:
diff --git a/style/brazilian.el b/style/brazilian.el
index 5124e660..c1ae8022 100644
--- a/style/brazilian.el
+++ b/style/brazilian.el
@@ -61,10 +61,10 @@
(setq TeX-quote-language nil))
(setq LaTeX-babel-hyphen-language "brazilian")
(TeX-add-symbols
- '("ord" 0)
- '("ro" 0)
- '("orda" 0)
- '("ra" 0))
+ "ord"
+ "ro"
+ "orda"
+ "ra")
;; Fontification
(when (and (eq TeX-install-font-lock 'font-latex-setup)
(featurep 'font-latex))
or use the updated file attached.
Thank you very much. I confess I'd prefer the `nil', but I presume
there is a reason for this particular value to be used as seldom as it
is. And I am happy with this, since the braces do get inserted, which
is the important here. (I haven't seen the commit there, I suppose you
haven't done it yet, but when you have the chance, please do recall of
`portuguese.el' too).
Thanks again!
Best regards,
Gustavo.