3

I am running Emacs and writing on the scratch-buffer. This is my config file. After executing describe-mode, this is the list of minor modes running:

Enabled minor modes: Auto-Composition Auto-Compression Auto-Encryption
Blink-Cursor Column-Number Delete-Selection Display-Line-Numbers
Doom-Modeline Eldoc Electric-Indent File-Name-Shadow Font-Lock
Global-Display-Line-Numbers Global-Eldoc Global-Font-Lock
Global-Git-Commit Global-Wakatime Ivy-Prescient Ivy-Rich Line-Number
Magit-Auto-Revert Override-Global Paredit Rainbow-Delimiters
Shell-Dirtrack Show-Paren Transient-Mark Wakatime Which-Key

This the problem demonstrated as a gif. When I try to insert backslash before quotes, something weird happens after I press C-f (to move the cursor forward). I happen to be stuck and it is not possible to leave, except for deleting everything:

enter image description here

How solve it?

Obs.: Currently, I have a hack. Basically, I execute command query-replace, pick " character and then choose as a replacement \". But I feel there must be a better way.

1
  • 2
    What happens if you press C-f again? What mode is the buffer in? What minor modes are enabled? What does C-h c C-f say? What happens if you do C-b instead or some other control sequence? The only way I can reproduce the behavior in my *scratch* buffer (which is in lisp-interaction mode with a bunch of minor modes enabled) is if I press C-q before I press C-f.
    – NickD
    Commented Mar 18, 2022 at 18:08

1 Answer 1

6

This is a feature of paredit. If you look at the minibuffer (the line at the bottom of your Emacs window) when you press \, you'll see you're being prompted for "Character to escape:". The next character you enter will be inserted with a backslash in front of it.

This happens because you're using paredit, and paredit provides features for managing parentheses, quotes, and backslashes for you. If you want to enter a new quote symbol with a backslash in front of it, you press \, then ", and then paredit enters it for you. If you want to add a \ in front of a character that's already on the screen, you need to use the quoted-insert command: C-q \.

There are links to more documentation, and a very nice demo on youtube, at the Emacs Wiki.

If you want a more conventional interface, you need to remove paredit. It can definitely be a bit confusing to get used to, but a lot of people find it quite useful.

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.