Skip to content

Instantly share code, notes, and snippets.

@aborn
Last active January 1, 2016 15:37
Show Gist options
  • Save aborn/f8e6f87592dad70d1865 to your computer and use it in GitHub Desktop.
Save aborn/f8e6f87592dad70d1865 to your computer and use it in GitHub Desktop.
;; 查找匹配的括号
(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