I've came across this comment in an evil-surround issue, which stated this code:
;; use non-spaced pairs when surrounding with an opening brace
(evil-add-to-alist
'evil-surround-pairs-alist
?\( '("(" . ")")
?\[ '("[" . "]")
?\{ '("{" . "}")
?\) '("( " . " )")
?\] '("[ " . " ]")
?\} '("{ " . " }"))
And it actually works. but what are those strange ?\ symbols? What are they doing? What do they mean?
evil-surround-pairs-alistvariable with string (e.g."(") leads instead of integer (e.g.?\() leads? Why didn't he just use the string format? – ninrod Feb 02 '17 at 17:06eq(so(eq ?a ?a)evaluates tot), whereas string equality is slower to evaluate. In effect, an alist with character keys can useassq, but one with string keys needs the slowerassoc. Whether or not you'd ever notice the speed difference depends on a) the list length, and b) how often you run the function. It's also likely that he's querying the characters around point withchar-beforeandchar-after, and wants to skip conversion. – Dan Feb 02 '17 at 17:10?\can be used for any character, not just special characters. So you can (but you need not) use?\ginstead of?g. – Drew Feb 02 '17 at 18:20?ais the character representation of lowercase "a" while?\ais the character representation ofC-g, and?trepresents lowercase "t" and?\trepresents thetabcharacter. So both(eq ?a ?\a)and(eq ?t ?\t)evaluate tonil. However, it does work for some other characters:(eq ?z ?\z)evaluates tot. – Dan Feb 02 '17 at 18:57\a,\b,\t,\n,\v,\r,\e,\s,\\, and\d. The relevant manual page is (elisp)Basic Char Syntax. – Drew Feb 02 '17 at 19:05