6

Using Aquamacs 3.2 on Mac OSX Yosemite. I run with delete-selection-mode set, and it mostly works as advertised. However, if I'm in TeX mode (AucTeX), make a selection, and then type $, the selection is cleared and the $ appended. So for example if I select foobar in xyzfoobarxyz and type $, I get xyzfoobar$xyz instead of the desired xyz$xyz. Is this known/documented behavior, or a bug? If it's a bug, is it an AucTeX or an Aquamacs issue (or an Emacs issue)?

Edit: In response to Tobias' comment below, C-h k $ returns

$ runs the command TeX-insert-dollar, which is an interactive compiled Lisp function in `tex.el'.

It is bound to $.

(TeX-insert-dollar &optional ARG)

Insert dollar sign.

If current math mode was not entered with a dollar, refuse to insert one. Show matching dollar sign if this dollar sign ends the TeX math mode and 'blink-matching-paren' is non-nil. When outside math mode, the behavior is controlled by the variable 'TeX-electric-math'.

With raw ^U prefix, insert exactly one dollar sign. With optional ARG, insert that many dollar signs.

And, the function delete-selection-mode is defined in delsel.el.

I'm far from LISP-literate. Perhaps the TeX-insert-dollar function does not take the delete selection mode into account (either by design or by omission)?

  • 3
    Probably $ runs some special command in AucTeX, and that command isn't marked to as an insertion command, see delsel.el commentary – npostavs Mar 30 '16 at 15:08
  • 2
    According to @npostavs's comment, try this (put 'TeX-insert-dollar 'delete-selection t) – xuchunyang Mar 30 '16 at 15:18
  • 1
    What is the value of TeX-electric-mode? – Harald Hanche-Olsen Mar 31 '16 at 21:29
  • 1
    @npostavs TeX-insert-dollar wasn't missed, it's so by design because for the features it provides the function needs to keep alive the current selection – giordano Mar 31 '16 at 21:38
  • 1
    Actually TeX-insert-dollar had in the past the delete-selection property, but it was removed in order to provide the feature mentioned above: git.savannah.gnu.org/cgit/auctex.git/commit/… – giordano Mar 31 '16 at 21:44
5

AUCTeX provides the feature to wrap opening and closing inline equation markers around active region on pressing $, when TeX-electric-math is non-nil (and this isn't the default). In order to have this, the delete-selection property had to be removed. Actually, its behavior can be dynamically determined by a function, so that

(put 'TeX-insert-dollar 'delete-selection (lambda () (null TeX-electric-math)))

enables or disables it depending on the value of TeX-electric-math. Thanks to this discussion, the above line is now present also in development version of AUCTeX.

  • 1
    Would that all software were this well supported. – rogerl Mar 31 '16 at 23:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.