0

My general question: is there a way to get AUCTeX to prompt me automatically for an optional argument of a command when I invoke it with TeX-insert-macro (i.e. C-cRET)? (like it does when you invoke, for instance, \newcommand)

My specific question: is there a way to get AUCTeX to prompt me automatically for an optional overlay specification when I invoke the \alert command with TeX-insert-macro (i.e. C-cRETalertRET)?

Thanks in advance.

1

2 Answers 2

2

I asked the AUCTeX mailing list, and Mosè Giordano kindly provided the following answer:

You have to manually patch the file style/beamer.el in your AUCTeX installation. Replace the line

'("alert" 1)

with

'("alert" TeX-arg-beamer-overlay-spec 1)

Remember to byte-recompile the file with M-x byte-recompile-file RET RET.

1
  • I wonder if there is a more robust way to do this, one that would not require me to recompile /style/beamer.el everytime I update AUCTeX Sep 24, 2018 at 1:58
1

Try to add one of the following commands (depending on your needs) to your .emacs file:

  1. (setq TeX-insert-macro-default-style 'show-optional-args)
  2. (setq TeX-insert-macro-default-style 'show-all-optional-args)

the difference between the two is as described in Auctex documentation:

User Option: TeX-insert-macro-default-style Specifies whether 'TeX-insert-macro' will ask for all optional arguments. If set to the symbol 'show-optional-args', 'TeX-insert-macro' asks for optional arguments of TeX marcos, unless the previous optional argument has been rejected. If set to 'show-all-optional-args', 'TeX-insert-macro' asks for all optional arguments. 'mandatory-args-only', 'TeX-insert-macro' asks only for mandatory arguments.

Although this suggestion may not be applicable to beamer macros as noted by @ArashEsbati however it may answer the first part of the question that is:

Is there a way to get AUCTeX to prompt me automatically for an optional argument of a command when I invoke it with TeX-insert-macro (i.e. C-c RET)? (like it does when you invoke, for instance, \newcommand)

3
  • Thanks Hafid. Unfortunately, this did not work for me. Sep 24, 2018 at 1:56
  • 1
    With your code, Emacs will throw an error at startup since it looks for a variable show-optional-args which is not defined. As described in the manual, you need symbols. Hence, you need (setq TeX-insert-macro-default-style 'show-optional-args) (note the '). Even quoted, I'm afraid that your suggestion will not work since the functionTeX-arg-beamer-overlay-spec is defined in a way that it doesn't respect the settings in your answer. Sep 28, 2018 at 16:16
  • Thank's to @ArashEsbati for his relevant remarks especially about quoting the symbols show-optional-args and show-all-optional-args. So I reedit my answer accordingly. Sep 29, 2018 at 21:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .