Last active
January 1, 2016 15:37
-
-
Save aborn/f8e6f87592dad70d1865 to your computer and use it in GitHub Desktop.
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 match-paren (arg) | |
"Go to the matching paren if on a paren; otherwise insert %. | |
If position just right in middle of (), only insert %." | |
(interactive "p") | |
(cond | |
((and (char-equal (char-after) ?\)) | |
(char-equal (char-before) ?\()) (self-insert-command (or arg 1))) | |
((looking-at "\\s\(") (forward-list 1) (backward-char 1)) | |
((looking-at "\\s\)") (forward-char 1) (backward-list 1)) | |
(t (self-insert-command (or arg 1))))) | |
(global-set-key "%" 'match-paren) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment