Created
May 14, 2015 19:35
-
-
Save mrwacky42/2cdeca7107d41adcbca2 to your computer and use it in GitHub Desktop.
match-paren
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
;; Use % to match various kinds of brackets... | |
;; See: http://www.lifl.fr/~hodique/uploads/Perso/patches.el | |
(defun match-paren (arg) | |
"Go to the matching paren if on a paren; otherwise insert %." | |
(interactive "p") | |
(let ((prev-char (char-to-string (preceding-char))) | |
(next-char (char-to-string (following-char)))) | |
(cond ((string-match "[[{(<]" next-char) (forward-sexp 1)) | |
((string-match "[\]})>]" prev-char) (backward-sexp 1)) | |
(t (self-insert-command (or arg 1)))))) | |
; (global-set-key "%" 'match-paren) | |
(provide 'match-paren) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment