auctex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Some LaTeX commands, such as \boldsymbol and \hspace, can't be compl


From: Arash Esbati
Subject: Re: Some LaTeX commands, such as \boldsymbol and \hspace, can't be completed in AUCTeX.
Date: Thu, 16 Dec 2021 22:58:59 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50

Denis Bitouzé <denis.bitouze@univ-littoral.fr> writes:

> Le 09/12/21 à 18h41, Arash Esbati a écrit :

> sorry for the late answer.

No problem.

>> Highly welcome.  There will be a question reg. licence, but we can be
>> worried about that later.
>
> OK. I'll contact this guy in few weeks.

Thanks.

>> Agreed, but \includegraphics is indeed more an exception.
>
> In that case, could it be treated differently?

I don't see how this can be achieved the way currently
`LaTeX-arg-graphicx-includegraphics-key-val'[1] and the workhorse
`TeX-read-key-val' are implemented.

> IMO, `width=` should be the default completion and, in the rare cases
> when the `=` is not wanted, it is easy to erase it.

See above.

>> Ok, understood, so more like company.  For me, the way AUCTeX handles
>> the completion was always great because I didn't need to hit the
>> backslash which is hard to reach on a German keyboard.  I thought it is
>> the same issue on French layout?
>
> Indeed, same issue. But what could be nice for `C-c C-m' would be to
> type for us in the buffer (not the minibuffer) this damned backslash and
> then, as soon as characters are typed, to provide a completion (à la
> company).

You can define a keystroke of your choice for backslash.  Not tested,
but maybe something like this:

    (defun my-backslash ()
      (interactive)
      (insert "\\"))

    (with-eval-after-load "latex"
      (define-key LaTeX-mode-map (kbd "C-c b") #'my-backslash))

Reg. completion à la company: There is company-auctex, have you tried
it?[2]

One other solution which looks promising to me is digestif[3].

>   ┌────
>
> https://htmlpreview.github.io/?https://github.com/texstudio-org/texstudio/master/utilities/manual/usermanual_en.html#SECTION110a
>   └────
> Sorry, the link above isn't accurate enough. What I wanted to point out
> is not tables, but the screenshot about floating figures in section
> ``2.10.1 Inserting a picture using a "wizard"'',. By contrast, what is
> provided in the minibuffer by `C-c C-e fig TAB` is much less rich.

Ah, I see.  Well, it seems to me that the wizard does all Emacs does
through minibuffer query.  I can't tell if something like this is doable
with Emacs.

> Indeed, I always forget that the file has to be reload

What do you mean by reload?  It should be sufficient to hit C-c C-n to
reparse the file.

> in order such macros are taken into account (no such a pain in TXS).
>
> What is missing compared to TXS is the placeholders: such placeholders
> are:
>
> - highlighted: boxed, the selected one having a colored background,
> - quite explicit in case of existing completion file and, in case of
>   user macros such as the previous one, not so few explicit, here
>   \congru[opt. arg1]{arg2}
> - easy to reach: there are shortcuts to jump between them.

Yupp, the company-style completion.  Have a look at the gif on digestif
site, I think it does what you're looking for.

>> Out of curiosity: Can TXS also parse new environments defined with
>> fancyvrb package?  I mean something like this:
>>
>>     \documentclass{article}
>>     \usepackage{fancyvrb}
>>     \DefineVerbatimEnvironment{MyVerbatim}{Verbatim}{%
>>       gobble=2,numbers=left,numbersep=2mm,
>>       frame=lines,framerule=0.8mm}
>>     \begin{document}
>>     Try `C-c C-e MyVerbatim RET Optional fancyvrb keyvals RET'?
>>     \end{document}
>
> Well:
>
> - with AUCTeX, even after the file being reload, no completion for
>   `MyVerbatim` and the 1st RET inserts only the environment with the
>   cursor inside: no "Optional", etc.

When I put the code above in a .tex file, load it and hit C-c C-n, I see
the following entries when looking at the variable
`LaTeX-environment-list':

 ("MyVerbatim" LaTeX-env-args
  [TeX-arg-key-val
   (LaTeX-fancyvrb-key-val-options)]
  LaTeX-fancyvrb-env-reflabel-key-val)
 ("MyVerbatim*" LaTeX-env-args
  [TeX-arg-key-val
   (LaTeX-fancyvrb-key-val-options)]
  LaTeX-fancyvrb-env-reflabel-key-val)

I.e., I get completion for optional arguments etc.

> - with TXS, `\be + TAB` is completed into `\begin{` and, then, we have
>   completion for all the known environments, including `MyVerbatim`
>   (but nothing more).

Thanks.

After all, I think we should start thinking about the direction AUCTeX
should go in future.  It is a mature product, and adding styles for
LaTeX packages is always a good thing, but that's only part of the
answer.  Maybe company support is a first step.

Best, Arash

Footnotes:
[1]  http://git.savannah.gnu.org/cgit/auctex.git/tree/style/graphicx.el#n85

[2]  https://github.com/alexeyr/company-auctex

[3]  https://github.com/astoff/digestif




reply via email to

[Prev in Thread] Current Thread [Next in Thread]