2017-07-22 TeX-parse-macro

In one of my earlier posts I promised to show how to prevent AUCTeX from putting braces after a command inserted with TeX-insert-macro.

The point is, you shouldn’t be really using TeX-insert-macro at all. It is an interactive function doing things you wouldn’t want to do in an Elisp program, like running TeX-after-insert-macro-hook (or maybe you would? I’m not sure…). Anyway, while admittedly it is suited to be run non-interactively (it contains a (when (interactive-p) ...) clause), here’s a slightly better idea: use the TeX-parse-macro function. It takes two arguments: a string (macro name, without the leading backslash) and a list describing its arguments. See its docstring to learn what are the possibilities; for my case, saying (TeX-parse-macro "pause" '(0)) worked very well. (The '(0) says that there should be no braces after \pause; it is in the list, because each element of that list corresponds to an argument (in the TeX sense) of \pause. Try something like e.g. (TeX-parse-macro "usepackage" '([t] nil)) for a foretaste of what is possible.)

CategoryEnglish, CategoryBlog, CategoryEmacs, CategoryTeX, CategoryLaTeX