auctex-devel
[Top][All Lists]
Advanced

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

Re: [AUCTeX-devel] Improve LaTeX macro definition argument prompts


From: Mosè Giordano
Subject: Re: [AUCTeX-devel] Improve LaTeX macro definition argument prompts
Date: Wed, 16 Mar 2016 10:26:52 +0100

Hi Matt,

2016-03-15 23:24 GMT+01:00 Matthew Leach <address@hidden>:
> Mosè Giordano <address@hidden> writes:
>
>> Hi Matt,
>
> Hi Mosè,
>
> Many thanks for the feedback.
>
>> 2016-03-15 21:16 GMT+01:00 Matthew Leach <address@hidden>:
>>> Hi all,
>>>
>>> When inserting a \newcommand macro with AUCTeX, I've found a couple of
>>> small annoyances and have attached a patch to try and mitigate them.
>>>
>>> First, the user is prompted for the number of arguments that a macro
>>> should take.  If a '0' entered at the prompt, then '[0]' is added at the
>>> point.  However, when no input is provided and the user just presses RET
>>> at the prompt, nothing is inserted.  I'm not sure if there is semantic
>>> difference between
>>>
>>> \newcommand{\foo}[0]{Foobar}
>>>
>>> and
>>>
>>> \newcommand{\foo}{Foobar}
>>>
>>> so this may be a stylistic preference for the user.  I think we should
>>> be consistent, though.
>>
>> I've never noticed such problem, probably because I never enter "0" as
>> number of arguments, I just press RET.  AUCTeX does the right thing by
>> not prompting for the next optional argument only with the default
>> settings.
>
> I'm sure it's a problem that people will run into very infrequently, as
> you say, most people will probably just hit RET and not encounter any
> issues :-).  Initially I thought that it was quite an invasive patch for
> such a trivial error but I'm hoping to add some checking on the 'Number
> of arguments' parameter the user returns and ensure that it's a valid
> number; this patch sets up the foundation for that behavior.
>
>> The behavior of `TeX-insert-macro' is controlled by
>> `TeX-insert-macro-default-style'.  By default, after an empty optional
>> argument AUCTeX doesn't prompt for further optional arguments, but if
>> one sets it to `show-all-optional-args' he/she will be always prompted
>> for the default value of the possible optional arguments with the
>> current implementation.  For this reason I think your patch addresses
>> a real problem, even though `TeX-insert-macro-default-style' probably
>> isn't one of the most known options.
>>
>> To be honest this is the first time I see
>>
>>     \newcommand{\foo}[0]{Foobar}
>>
>> I've always seen and used the version without optional arguments when
>> the new macro has no argument.  This is probably the reason why I
>> never enter "0" at the "Number of arguments" prompt.
>
> Agreed, I've never seen a \newcommand written as such.  Like yourself, I
> always use the version that doesn't contain the optional parameter which
> was the main motivation for the patch :-).
>
>>> Secondly, if a '0' is passed at the prompt of the Number of arguments,
>>> we are still prompted for the default value of the first argument.  I
>>> think this is an error as there is no first argument to have a default
>>> value.
>>
>> Your patch actually swaps the nuisance: now the useless prompt occurs
>> when `no-args' is an empty string ;-)
>
> Oops - I thought I'd tested that.  I must have missed that one, sorry!
>
>> A comment regarding the name of this variable: "no-args" to me means
>> "no arguments".  It took me a few seconds to figure out that "no"
>> stands for "number", I think that using "no" as a shorthand for
>> something different from "no" is at least misleading.  But I'm not a
>> native English speaker, :-)
>
> That's a great point, I sometimes use silly abbreviations and should be
> more verbose when it comes to code :-). I've substituted that for
> "arg-count" now, would that be OK?
>
>>> The attached patch creates two new TeX-arg-* functions.
>>> TeX-arg-define-macro-arguments replaces "Number of arguments" in
>>> TeX-add-symbols for the macro definition LaTeX commands.  This function
>>> will prompt the the number of arguments and check the return value and
>>> if it is equal to "0" or there is no input, nothing is inserted.  If
>>> anything else is inserted the user is prompted for the default value for
>>> the first argument, as before.
>>
>> As I said before, the patch is well-grounded, but please consider my
>> suggestion(s) above.
>
> Please find attached a V2 of the patch which takes into account your
> suggestions.

Installed, thanks!

Bye,
Mosè



reply via email to

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