Didier Verna <did...@didierverna.net> writes: Hi Didier,
> I'm not sure this is a bug, because I'm not sure TeX-insert-braces can > actually be used as a hook (it would probably break when enclosed within > square brackets). Indeed, `TeX-insert-braces' is not meant to be used inside a hook. Those functions have by convention a name like `TeX-arg-...'. > However, I'm supposed to be allowed to define my own hook, so here it > is: > > (defun LaTeX-fixme-active-region (optional) > (TeX-argument-insert (if (TeX-active-mark) > (prog1 (buffer-substring (point) (mark)) > (delete-region (point) (mark)) > (deactivate-mark)) > "") > optional)) > > > Now defining my macro as follows: > > (TeX-add-symbols `("foo" t LaTeX-fixme-active-region)) > > will entail the same behavior as with TeX-insert-braces, so I'm enclined > to call that a bug (saving the excursion won't change anything BTW). > > Any comment appreciated, thanks! The way I understand the code the behavior you describe is by design: AUCTeX puts the region in the first argument when it parses t. You can check the function `TeX-parse-argument' in tex.el, line 3523, ((eq arg t) ...) So you have to write your own function, but avoid the t in the style hook. You can set the exit-mark in you function to get the same effect as with t, e.g.: (defun LaTeX-fixme-arg (optional) (insert TeX-grop) (set-marker exit-mark (point)) (insert TeX-grcl) (TeX-argument-insert (prog1 (buffer-substring (point) (mark)) (delete-region (point) (mark)) (TeX-deactivate-mark)) optional)) (TeX-add-style-hook "fixme" (lambda () (TeX-add-symbols '("foo" (TeX-arg-conditional (TeX-active-mark) (LaTeX-fixme-arg) (t nil))))) LaTeX-dialect) HTH. Best, Arash _______________________________________________ bug-auctex mailing list bug-auctex@gnu.org https://lists.gnu.org/mailman/listinfo/bug-auctex