]> git.bundesbrandschatzamt.de Git - emacsconfig.git/commitdiff
added goto-match-paren bound to key %
authorAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Tue, 7 Jan 2014 11:46:33 +0000 (12:46 +0100)
committerAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Tue, 7 Jan 2014 11:46:33 +0000 (12:46 +0100)
Signed-off-by: Andreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
init.el

diff --git a/init.el b/init.el
index 5ae915187d6fd5878065c4086450812d5302265b..c1da3f512104c552ed085619dcfae816cb65b64b 100644 (file)
--- a/init.el
+++ b/init.el
@@ -304,6 +304,15 @@ nil)
 (t
 (apply 'eshell-exec-visual (cons "ssh" args))))))
 
+(defun goto-match-paren (arg)
+  "Go to the matching parenthesis if on parenthesis, otherwise insert %.
+vi style of % jumping to matching brace."
+  (interactive "p")
+  (cond ((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 "%" 'goto-match-paren)
+
 ;;(move-overlay hl-line-overlay
 ;;           (line-beginning-position) (1+ (line-end-position))
 ;;           (current-buffer)))))