Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add "`" as autopair paired delimiter in markdown-mode?

Tags:

emacs

elisp

I've tried adding this code to the markdown-mode-hook

(push '(?` . ?`) (getf autopair-extra-pairs :everywhere))

The documentation of autopair-extra-pairs explains:

Note that this does not work for single characters, e.x. characters you want to behave as quotes. See the docs/source comments for more details.

Which suggests the above would not work (and it didn't). But I was unable to figure out what would work after browsing the code for a bit.

I've also tried to muck around with the syntax table:

(modify-syntax-entry ?` "$" markdown-mode-syntax-table)

Which didn't help either.

like image 607
event_jr Avatar asked Oct 08 '22 10:10

event_jr


1 Answers

I couldn't work this out either. However, if you're running Emacs 24, you use electric-pair-mode instead. Modifying the syntax table like this worked for me:

(add-hook 'markdown-mode-hook
          #'(lambda ()
              (modify-syntax-entry ?` "\"")))

Edit: As Joao Tavora points out, this seems to work in autopair, so perhaps this is all that's needed:

I was able to get this to work by modifying the syntax table, but using 'string quote' (") instead of 'paired delimiter' ("$"):

(modify-syntax-entry ?` "\"" markdown-mode-syntax-table)
like image 138
Luke Girvin Avatar answered Oct 12 '22 11:10

Luke Girvin