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: Denis Bitouzé
Subject: Re: Some LaTeX commands, such as \boldsymbol and \hspace, can't be completed in AUCTeX.
Date: Wed, 15 Dec 2021 22:31:41 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)

Hi Arash,

sorry for the late answer.

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

> Denis Bitouzé <denis.bitouze@univ-littoral.fr> writes:
>
>> Le 09/12/21 à 12h44, Arash Esbati a écrit :
>>
>>> You can always drop a line to auctex-devel asking for an addition.  Or
>>> even better provide code for the missing package/command.  I think for
>>> most of packages out there providing only user macros it's not hard to
>>> write AUCTeX styles.
>>
>> Agree, but tedious. That's why I proposed to benefit from the `.cwl`
>> completion files of TXS: it's also probably not so hard to provide
>> a converter (maybe I will have a look when I'll have some spare time).
>
> 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.

>> Agree but, in case of `\includegraphics`, I would say the `width` or
>> `height` options are mandatory ;) It is indeed usual to want the
>> included graphic to not be at its natural dimensions (and, often, the
>> user doesn't know these dimensions).
>
> Agreed, but \includegraphics is indeed more an exception.

In that case, could it be treated differently?

>>> Why do start to type after 'width='.  Just hit TAB and the backslash is
>>> inserted in the minibuffer and you can go on with 'l TAB'.
>>
>> Ah, OK but that's not easy to figure out. IMO, if `width` is chosen and
>> obtained by completion, it should completed into `width=`.
>
> True, but then again this is by design that you give Emacs a hint about
> your selection -- you could take the completion 'width' and extend it to
> 'widthfoo'.

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

>>> While we're at it, does TXS has something like `C-c C-m' or does it
>>> inline completion like company for Emacs where you start typing and get
>>> a drop-down list to select of?  I admit I've never used anything else
>>> than (X)Emacs so I don't know.
>>
>> It provides inline completion, which is IMO much easier to use. For
>> instance about `\includegraphics`, if you type `\includeg`, the
>> following appears in the TXS' completion window:
>>
>>   ┌────
>>   │ \includegraphics{imagefile}
>>   │ \includegraphics[keyvals]{imagefile}
>>   │ \includegraphics*{imagefile}
>>   │ \includegraphics*[keyvals]{imagefile}
>>   └────
>
> 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).

>> If you choose the second entry, `keyvals` is immediately selected and if
>> you type `w`, you're immediately prompted with `width=` in the
>> completion window ; if you accept it (RET), `width=` is written (with
>> the cursor just after `=`) and you're immediately prompted with:
>>
>>   ┌────
>>   │ \linewidth
>>   │ \textheight
>>   └────
>>
>> (OK, last option is a bit odd for a width) in the completion window ; at
>> this stage, either you choose one of the propositions or you start to
>> type something else (e.g. `15cm`).
>
> I see, this can be useful.  Maybe we should extend the completion at
> point in AUCTeX, I'm not familiar with it, though.

Would be /very/ nice! :)

>> Another interesting feature provided by TXS is wizards. For instance for
>> the floating figures, a pop up window appears with all what the user might
>> want for such floats:
>>
>>   ┌────
>>   │
>> https://htmlpreview.github.io/?https://github.com/texstudio-org/texstudio/master/utilities/manual/usermanual_en.html#SECTION110a
>>   └────
>>
>> From this point of view, `C-c C-e fig TAB RET` is much less rich but,
>> more generally, with all done in the minibuffer by AUCTeX, the user
>> doesn't have an general overview of the different fields it has to fill
>> and, to a certain extent, fills them blindly (`C-c C-e minipage RET` is
>> a typical example): by contrast, in the TXS wizard, he can look at each
>> field at his own rhythm.
>>
>> I know pop up windows such as the TXS ones is not the way Emacs is
>> working, but such a feature might be approximated with something à la
>> yasnippet with placeholders (some of these placeholders providing
>> completions).
>
> I thinks nowadays people use the table features in org-mode and then
> export them.

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.

>>> That's one impressive number.  But again, dropping a line to
>>> auctex-devel requesting a package or better providing code directly is
>>> the best way to increase the number styles provided by AUCTeX.
>>
>> Better to write a converter from `.cwl` to AUCTeX completion files :)
>
> See above :-)
>
>> WDYT about my examples in:
>>
>>   ┌────
>>   │ https://lists.gnu.org/archive/html/auctex/2021-12/msg00013.html
>>   └────
>
> Sorry, I don't get that?  What do you mean?  AUCTeX can also parse
>
>     \newcommand{\congru}[2][x]{#1\equiv #2\,\modulo}
>
> and offer completion with C-c C-m congru RET, or am I missing something?

Indeed, I always forget that the file has to be reload 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.

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

Best.
-- 
Denis



reply via email to

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