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: Thu, 09 Dec 2021 17:05:27 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)

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

>> Not for `\linewidth`:
>
> Maybe I wasn't clear, I meant \linewidth is available for completion of
> \hspace.

Ah, I see.

>> with `C-c C-m line<TAB>', I only get:
>>
>>   ┌────
>>   │ Click on a completion to select it.
>>   │ In this buffer, type RET to select the completion near point.
>>   │ 
>>   │ Possible completions are:
>>   │ line
>>   │ linebreak
>>   │ linethickness
>>   └────
>
> Agreed, and I also said why in my previous message.

Indeed.

>>> Can you please elaborate what exactly you mean?  I'm not sure if I get
>>> the point.
>>
>> I don't remember all the cases where I missed completion but, when I use
>> TeXstudio (TXS), I often say to myself: completion for this command is
>> available with TXS and not with AUCTeX, too bad!
>
> 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).

>> I would say AUCTeX tries to be too clever here.
>
> That's a general Emacs-thing, not only related to AUCTeX 😉

:)

>> once `graphicx` is taken into account:
>>
>> 1. \includegraphics is available with completion,
>> 2. we are asked for the options (BTW, maybe it would be helpful to
>>    immediately see the possible options, without having to TAB),
>
> There are cases where the optional argument is really optional.  I find
> it rather distracting to get see all possible options immediately.  But
> that's only me.

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).

>> 3. if we choose `width=` and start to type:
>>    1. `\line`, indeed `\linewidth` is available with TAB, but we have to
>>       type `\` which is not handy on e.g. French keyboards,
>
> 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=`.

> 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}
  └────

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`).

>>    2. `0.7\line` because we want `width=0.7\linewidth`, `\linewidth` is
>>       not available with TAB.
>
> True, but this is then by design of Emacs and completion tables.  I
> think the main problem is the amount of choices you have with:
>
>     width=\linewidth
>     width=0.7\linewidth
>     width=5cm
>
> You have to find a compromise.

IMO, `\linewidth` should always be available as completion.

>> It may happen e.g. if, afterwards, you change your mind and want to
>> change `\includegraphics[width=15cm]{...}` into
>> `\includegraphics[width=\linewidth]{...}`.
>
> Again, I'd prefer not to pollute the completion list for macros with
> non-macros like this -- this is a key/val thing.

I don't see your point here.

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).

>>> Any specific package you're missing?
>>
>> I would say, all! :) What I want to say is that I don't need a specific
>> one at the moment but anybody can miss any of them at anytime. By
>> comparison, TXS provides 1387 completion files:
>>
>>   ┌────
>>   │ https://github.com/texstudio-org/texstudio/tree/master/completion
>>   └────
>
> 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 :)

WDYT about my examples in:

  ┌────
  │ https://lists.gnu.org/archive/html/auctex/2021-12/msg00013.html
  └────

Best,
-- 
Denis



reply via email to

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