Last active
January 16, 2018 14:51
-
-
Save cbaggers/140688558091a19543758b12f908c686 to your computer and use it in GitHub Desktop.
little helpers
This file contains hidden or 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
;; You might want to paste these in your .emacs file | |
;; when over one paren it shows it's match | |
(show-paren-mode t) | |
;; C-c ) jumps to the matching paren | |
(defun goto-match-paren (arg) | |
"Go to the matching if on (){}[], similar to vi style of % " | |
(interactive "p") | |
;; first, check for "outside of bracket" positions expected by forward-sexp, etc. | |
(cond ((looking-at "[\[\(\{]") (forward-sexp)) | |
((looking-back "[\]\)\}]" 1) (backward-sexp)) | |
;; now, try to succeed from inside of a bracket | |
((looking-at "[\]\)\}]") (forward-char) (backward-sexp)) | |
((looking-back "[\[\(\{]" 1) (backward-char) (forward-sexp)) | |
(t nil))) | |
(global-set-key (kbd "\C-c )") `goto-match-paren) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment