I'd like to avoid being asked how much vertical space I want to insert at the end of a row in tables and have C-c C-j
behave like C-u C-c C-j
.
1 Answer
As you've already mentioned in your comment, you can disable query for optional arguments during completion globally with:
(setq TeX-insert-macro-default-style 'mandatory-args-only)
For your special use case and since you want to redefine an AUCTeX function, I suggest another approach: Write an AUCTeX style file which does the redefinition of two responsible functions like this:
;;; tab-no-opt.el --- AUCTeX style for redefining 2 AUCTeX core functions
(defun LaTeX-item-array (&optional suppress)
"Insert line break macro on the last line and suitable number of &'s.
For array and tabular environments. Temporarily bind
`TeX-insert-macro-default-style' to mandatory-args-only when
inserting \"\\\\\".
If SUPPRESS is non-nil, do not insert line break macro."
(unless suppress
(save-excursion
(end-of-line 0)
(just-one-space)
(let ((TeX-insert-macro-default-style 'mandatory-args-only))
(TeX-insert-macro "\\"))))
(LaTeX-insert-ampersands
LaTeX-array-skipping-regexp 'LaTeX-array-count-columns))
(defun LaTeX-item-tabular* (&optional suppress)
"Insert line break macro on the last line and suitable number of &'s.
For tabular* environment only. Temporarily bind
`TeX-insert-macro-default-style' to mandatory-args-only when
inserting \"\\\\\".
If SUPPRESS is non-nil, do not insert line break macro."
(unless suppress
(save-excursion
(end-of-line 0)
(just-one-space)
(let ((TeX-insert-macro-default-style 'mandatory-args-only))
(TeX-insert-macro "\\"))))
(LaTeX-insert-ampersands
LaTeX-tabular*-skipping-regexp 'LaTeX-array-count-columns))
;;; tab-no-opt.el ends here
The only change is that the variable TeX-insert-macro-default-style
is temporarily let
-bound to the symbol mandatory-args-only
for inserting the control symbol \\
.
Set the variable TeX-auto-private
to a directory of your choice, save the code above as tab-no-opt.el
there and restart Emacs.
Next, write a dummy LaTeX package tab-no-opt.sty
like this and save it your texmf-local
directory where LaTeX can find it:
\ProvidesPackage{tab-no-opt}
[2017/05/25 v0.0 Dummy package for AUCTeX redefinitions]
\relax
\endinput
Finally, in the preamble of your working .tex file, do C-c C-m usepackage RET tab-no-opt RET and AUCTeX should load the style file above and you should be done. I recommend you put this line in your init file
(setq TeX-parse-self t)
if you want AUCTeX to load the style each time you open your .tex file. You should now be able to compile your file and get the desired result within Emacs.
LaTeX-item-tabular*
from doing it.(setq TeX-insert-macro-default-style 'mandatory-args-only)
andLaTeX-default-position nil
but I'm still open to suggestions.