1

I am using smartparens with AucTeX and it works great. I wanted to map a keystroke for the dollar sign, so I did it as follows -

(global-set-key (kbd "s-m") (lambda () (interactive) (insert "$")))

But if I enter a dollar sign using the above keystroke, I no longer get a matching dollar sign as opposed to if enter a dollar sign the normal way (shift+4).

I'm not sure I understand why this happens. If anyone could point to the right place in the documentation so I can work out a fix, it'd be much appreciated.

2
  • @Drew You are correct. It is bound to (TeX-insert-dollar &optional ARG) that takes an optional argument. I think I can just bind my keystroke to this function and it should work. Thanks!
    – Rahul
    Commented Feb 17, 2020 at 18:47
  • @Drew I did add the answer but I can only accept it in 2 days. I'll make sure to do so then. Okay I have removed the tag smartparens
    – Rahul
    Commented Feb 17, 2020 at 19:00

1 Answer 1

1

The issue was the dollar-sign key was bound to command TeX-insert-dollar, which can take an optional argument indicating the number of dollar signs to print.

This is why mapping the same key to inserting the character $ did not work.

To make it work, I just bound the key to a command that invokes TeX-insert-dollar, passing 2 as the argument, and all works fine.

(global-set-key (kbd "s-m")  
                (lambda () 
                        (interactive) 
                        (TeX-insert-dollar 2) 
                        (backward-char 1)))
1
  • @Drew is it fine now ?
    – Rahul
    Commented Feb 17, 2020 at 20:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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