emacs lisp: escape quotes

small elisp programing tip.

elisp has the toothpick syndrom. When you use elisp to process
html, all the "quote" characters needs to be escaped. (worse if you
have backslash (e.g. Windows style path) and need to process it with
emacs regex.)

Here's a quick function i've been using for a couple of years:

(defun escape-quotes-region (start end)
  (interactive "r")
  "Replace \" by \\\"."
  (replace-pairs-region start end '(["\"" "\\\""])))

(defun unescape-quotes-region (start end)
  (interactive "r")
  "Replace \\\" by \"."
  (replace-pairs-region start end '(["\\\"" "\""])))

You can assign a key to them.

This calls replace-pairs-region. Which i have defined. See if you can code that. I'll post my code tomorrow.

Popular posts from this blog

11 Years of Writing About Emacs

does md5 creates more randomness?

Google Code shutting down, future of ErgoEmacs