Subject: bug#23177: Inserting $ with delete-selection-mode set

From: Mosè Giordano <[email-masked]>
Date: Fri, 1 Apr 2016 00:20:28 +0200

I just added the line

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

to git version of AUCTeX
(http://git.savannah.gnu.org/gitweb/?p=auctex.git;a=commitdiff;h=da88a3eca3107372131aa26930e548c039fe1b51).
Now `delete-selection' behavior is dynamically determined by
`TeX-electric-math' and should always do the-right-thing™.  Thanks for
the suggestion.

Bye,
Mosè

2016-03-31 23:57 GMT+02:00 Mosè Giordano <[email-masked]>:
> close 23177
> tags 23177 notabug
> thanks
>
>
> Hi Roger,
>
> 2016-03-31 23:37 GMT+02:00 Roger Lipsett <[email-masked]>:
>>
>> tex.el, at line 6315, contains the code
>>
>>   ;; delsel.el, `delete-selection-mode'
>>   (put 'TeX-newline 'delete-selection t)
>>   (put 'TeX-insert-quote 'delete-selection t)
>>   (put 'TeX-insert-backslash 'delete-selection t)
>>
>> Should this also include a line for 'TeX-insert-dollar?
>
> No.  That line was there until a few years ago but was removed on
> purpose in order to provide a new feature:
> http://git.savannah.gnu.org/cgit/auctex.git/commit/tex.el?id=d59628f1ee02abccc179c463214baddb5a17bf71
>
>> The problem I'm seeing is that if I'm in TeX (or LaTeX) mode, running with delete-selection-mode t, and type a $ when a region is selected, the selected region is not killed.
>
> If `TeX-electric-math' is non-nil, when you press `$' with an active
> region, it will wrap the selection with opening and closing inline
> equation symbols.  This is a feature AUCTeX provides, like for
> parentheses in most other programming languages.  If you want to lose
> this feature and be able to delete the region when inserting a dollar,
> then these lines in your init file
>
>     (setq TeX-electric-math nil)
>     (put 'TeX-insert-dollar 'delete-selection t)
>
> should do the trick.  Note that `TeX-electric-math' defaults to nil,
> the first line shouldn't be actually needed.
>
> Bye,
> Mosè