Created
August 29, 2018 21:59
-
-
Save choroba/d8fcb4aa9013becceae5a3877bc47860 to your computer and use it in GitHub Desktop.
Emacs lisp: quote region
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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