comparison .elisp/settings/50.localfuncs.el @ 126:34b698771af9

emacs keybinding fixes * Stop passing any keys through to the Mac layer * M-shift-f is now textmate-find-in-project * M-p bounces to matching paren (includes new elisp function to do that, is there a built in one?)
author Augie Fackler <durin42@gmail.com>
date Thu, 09 Jul 2009 13:32:06 -0500
parents 15bcc3e0afeb
children e30655eb7050
comparison
equal deleted inserted replaced
125:15bcc3e0afeb 126:34b698771af9
72 (skip-chars-forward "^<>)”}]」»\"’") 72 (skip-chars-forward "^<>)”}]」»\"’")
73 (setq b2 (point)) 73 (setq b2 (point))
74 (set-mark b1) 74 (set-mark b1)
75 ) 75 )
76 ) 76 )
77
78 ;; Most of this was extracted from show-paren-function in paren.el from an emacs 23 nightly
79 ;; Also, it seems like this really ought to be builtin, but I can't find it.
80 (defun bounce-to-other-paren ()
81 (interactive)
82 (let ((oldpos (point))
83 (dir (cond ((eq (syntax-class (syntax-after (1- (point)))) 5) -1)
84 ((eq (syntax-class (syntax-after (point))) 4) 1)))
85 pos mismatch face)
86 ;;
87 ;; Find the other end of the sexp.
88 (when dir
89 (save-excursion
90 (save-restriction
91 ;; Determine the range within which to look for a match.
92 (when blink-matching-paren-distance
93 (narrow-to-region
94 (max (point-min) (- (point) blink-matching-paren-distance))
95 (min (point-max) (+ (point) blink-matching-paren-distance))))
96 ;; Scan across one sexp within that range.
97 ;; Errors or nil mean there is a mismatch.
98 (condition-case ()
99 (setq pos (scan-sexps (point) dir))
100 (error (setq pos t mismatch t)))
101 ;; Move back the other way and verify we get back to the
102 ;; starting point. If not, these two parens don't really match.
103 ;; Maybe the one at point is escaped and doesn't really count.
104 (when (integerp pos)
105 (unless (condition-case ()
106 (eq (point) (scan-sexps pos (- dir)))
107 (error nil))
108 (setq pos nil)))
109 )))
110 ;; Highlight the other end of the sexp, or unhighlight if none.
111 (if (and pos (integerp pos))
112 (goto-char pos)
113 (message "No matching other paren found.")
114 )))