Skip to content

Instantly share code, notes, and snippets.

@ShingoFukuyama
Last active January 1, 2016 00:39
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 ShingoFukuyama/8067617 to your computer and use it in GitHub Desktop.
Save ShingoFukuyama/8067617 to your computer and use it in GitHub Desktop.
emacs mykie.el[https://github.com/yuutayamada/mykie-el] sample1 Wrap regioned area with parentheses, brackets, quote or whatever.
(require 'mykie)
(defun my-wrap-region (&optional $open $close)
(interactive)
(when mark-active
(let (($beg (region-beginning))
($end (region-end)))
(deactivate-mark)
(goto-char $end)
(insert $close)
(goto-char $beg)
(insert $open))))
(mykie:set-keys 'with-self-key
"(" :region&C-u '(my-wrap-region "(" ")")
"[" :region&C-u '(my-wrap-region "[" "]")
"{" :region&C-u '(my-wrap-region "{" "}")
"<" :region&C-u '(my-wrap-region "<" ">")
"'" :region&C-u '(my-wrap-region "'" "'")
"\"" :region&C-u '(my-wrap-region "\"" "\""))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment