Skip to content

Instantly share code, notes, and snippets.

@choroba
Created August 29, 2018 21:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save choroba/d8fcb4aa9013becceae5a3877bc47860 to your computer and use it in GitHub Desktop.
Save choroba/d8fcb4aa9013becceae5a3877bc47860 to your computer and use it in GitHub Desktop.
Emacs lisp: quote region
(defun quote-region (from to char)
"Surround region in quotes or brackets"
(interactive "r\ncChar:")
(let ((to (+ to 1))
(chars (case char
(?\( (list "(" ")"))
(?\[ (list "[" "]"))
(?\{ (list "{" "}"))
(?\< (list "<" ">"))
(t (list char char)))))
(save-excursion
(goto-char from)
(insert (first chars))
(goto-char to)
(insert (second chars)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment