ShingoFukuyama
12/21/2013 - 10:20 AM

emacs mykie.el[https://github.com/yuutayamada/mykie-el] sample1 Wrap regioned area with parentheses, brackets, quote or whatever.

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 "\"" "\""))