[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: |
Sat, 18 Dec 2021 16:46:52 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) |
Le 16/12/21 à 22h58, Arash Esbati a écrit :
>>> 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.
Too bad!
>> 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.
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))
Nice: already completion in point but limited. For instance: `\includeg`
completed in only `\includegraphics`
> Reg. completion à la company: There is company-auctex, have you tried
> it?[2]
Better but not as handy as TXS.
For instance: `\includeg` completed in `\includegraphics|[]{}` (where
`|` stands for the cursor position) whereas one could expect
`\includegraphics[•]{•}` where • are dummy placeholders, or better:
`\includegraphics[keyvals]{image file} ` where `keyvals` and `image
file` are non dummy placeholders.
Moreover, from `\includegraphics|[]{}`, moving the cursor in the
optional argument doesn't offer any completion.
> One other solution which looks promising to me is digestif[3].
Interesting. But not as handy as TXS.
For instance: `\includeg` completed in `\includegraphics|*[key-value
list]{filename}` (where `|` stands for the cursor position) but
`key-value list` and `filename` aren't placeholders.
Moreover, from `\includegraphics|*[key-value list]{filename}`, moving
the cursor in the optional argument doesn't offer any completion.
>> ┌────
>> │
>> 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.
More than during my last try (I don't understand what happened). But:
- the user doesn't have an overview of what he will be asked,
- no label,
- he has to start a new process for `\includegraphics`.
> I can't tell if something like this is doable with Emacs.
At least something à la yasnippet would be helpfull. E.g., asking for
`figure` would insert:
\begin{figure}[⟨float position⟩]
\centering
\includegraphics[⟨key-value list⟩]{⟨filename⟩}
\caption{⟨caption⟩}
\label{⟨label⟩}
\end{figure}
where all the ⟨...⟩ are placeholders:
- easy to jump from one the the previous or next one,
- entirely selected once reached,
- with relevant completion when replaced.
>> 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.
Indeed: much better but I always forget this keystroke. What would be
nice is that would be automatically done behind the scene as done by
TXS.
>> 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.
See above.
>>> 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.
Still nothing with a new test :$
>> - with TXS, `\be + TAB` is completed into `\begin{` and, then, we have
>> completion for all the known environments, including `MyVerbatim`
>> (but nothing more).
>
> Thanks.
You're welcome!
> 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.
Would be very, very nice! :)
Best.
--
Denis
- Re: Some LaTeX commands, such as \boldsymbol and \hspace, can't be completed in AUCTeX., (continued)
- Re: Some LaTeX commands, such as \boldsymbol and \hspace, can't be completed in AUCTeX., Denis Bitouzé, 2021/12/08
- Re: Some LaTeX commands, such as \boldsymbol and \hspace, can't be completed in AUCTeX., Arash Esbati, 2021/12/08
- Re: Some LaTeX commands, such as \boldsymbol and \hspace, can't be completed in AUCTeX., Denis Bitouzé, 2021/12/08
- Re: Some LaTeX commands, such as \boldsymbol and \hspace, can't be completed in AUCTeX., Jean-Jacques Rétorré, 2021/12/08
- Re: Some LaTeX commands, such as \boldsymbol and \hspace, can't be completed in AUCTeX., Denis Bitouzé, 2021/12/08
- Re: Some LaTeX commands, such as \boldsymbol and \hspace, can't be completed in AUCTeX., Arash Esbati, 2021/12/09
- Re: Some LaTeX commands, such as \boldsymbol and \hspace, can't be completed in AUCTeX., Denis Bitouzé, 2021/12/09
- Re: Some LaTeX commands, such as \boldsymbol and \hspace, can't be completed in AUCTeX., Arash Esbati, 2021/12/09
- Re: Some LaTeX commands, such as \boldsymbol and \hspace, can't be completed in AUCTeX., Denis Bitouzé, 2021/12/15
- Re: Some LaTeX commands, such as \boldsymbol and \hspace, can't be completed in AUCTeX., Arash Esbati, 2021/12/16
- Re: Some LaTeX commands, such as \boldsymbol and \hspace, can't be completed in AUCTeX.,
Denis Bitouzé <=
- Re: Some LaTeX commands, such as \boldsymbol and \hspace, can't be completed in AUCTeX., Mandar Mitra, 2021/12/18
- Re: Some LaTeX commands, such as \boldsymbol and \hspace, can't be completed in AUCTeX., Denis Bitouzé, 2021/12/18
Re: Some LaTeX commands, such as \boldsymbol and \hspace, can't be completed in AUCTeX., Jean-Jacques Rétorré, 2021/12/08
- Re: Some LaTeX commands, such as \boldsymbol and \hspace, can't be completed in AUCTeX., Hongyi Zhao, 2021/12/08
- Re: Some LaTeX commands, such as \boldsymbol and \hspace, can't be completed in AUCTeX., Hongyi Zhao, 2021/12/08
- Re: Some LaTeX commands, such as \boldsymbol and \hspace, can't be completed in AUCTeX., Jean-Jacques Rétorré, 2021/12/08
- Re: Some LaTeX commands, such as \boldsymbol and \hspace, can't be completed in AUCTeX., Arash Esbati, 2021/12/08
- Re: Some LaTeX commands, such as \boldsymbol and \hspace, can't be completed in AUCTeX., Hongyi Zhao, 2021/12/08
- Re: Some LaTeX commands, such as \boldsymbol and \hspace, can't be completed in AUCTeX., Hongyi Zhao, 2021/12/08
- Re: Some LaTeX commands, such as \boldsymbol and \hspace, can't be completed in AUCTeX., Hongyi Zhao, 2021/12/08