# HG changeset patch # User Augie Fackler # Date 1247164326 18000 # Node ID 34b698771af992b1cbc5de6792cd87acc6853c74 # Parent 15bcc3e0afebbeeadc5fd516a0889012493e6776 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?) diff --git a/.elisp/settings/50.localfuncs.el b/.elisp/settings/50.localfuncs.el --- a/.elisp/settings/50.localfuncs.el +++ b/.elisp/settings/50.localfuncs.el @@ -74,3 +74,41 @@ Delimiters are paired characters: ()[]<>«»“”‘’「」, including \"\"." (set-mark b1) ) ) + +;; Most of this was extracted from show-paren-function in paren.el from an emacs 23 nightly +;; Also, it seems like this really ought to be builtin, but I can't find it. +(defun bounce-to-other-paren () + (interactive) + (let ((oldpos (point)) + (dir (cond ((eq (syntax-class (syntax-after (1- (point)))) 5) -1) + ((eq (syntax-class (syntax-after (point))) 4) 1))) + pos mismatch face) + ;; + ;; Find the other end of the sexp. + (when dir + (save-excursion + (save-restriction + ;; Determine the range within which to look for a match. + (when blink-matching-paren-distance + (narrow-to-region + (max (point-min) (- (point) blink-matching-paren-distance)) + (min (point-max) (+ (point) blink-matching-paren-distance)))) + ;; Scan across one sexp within that range. + ;; Errors or nil mean there is a mismatch. + (condition-case () + (setq pos (scan-sexps (point) dir)) + (error (setq pos t mismatch t))) + ;; Move back the other way and verify we get back to the + ;; starting point. If not, these two parens don't really match. + ;; Maybe the one at point is escaped and doesn't really count. + (when (integerp pos) + (unless (condition-case () + (eq (point) (scan-sexps pos (- dir))) + (error nil)) + (setq pos nil))) + ))) + ;; Highlight the other end of the sexp, or unhighlight if none. + (if (and pos (integerp pos)) + (goto-char pos) + (message "No matching other paren found.") + ))) diff --git a/.elisp/settings/50.preferences.el b/.elisp/settings/50.preferences.el --- a/.elisp/settings/50.preferences.el +++ b/.elisp/settings/50.preferences.el @@ -51,3 +51,4 @@ (setq uniquify-ignore-buffers-re "^\\*") (setq hg-outgoing-repository "") (setq hg-incoming-repository "") +(setq mac-pass-command-to-system nil) ; so that Cmd+H won't activate Hide Current App and Cmd+Shift+q won't logout user. diff --git a/.elisp/settings/90.keybindings.el b/.elisp/settings/90.keybindings.el --- a/.elisp/settings/90.keybindings.el +++ b/.elisp/settings/90.keybindings.el @@ -11,7 +11,10 @@ (global-set-key "\C-h" 'backward-delete-char-untabify) ; M-t is what I want for the textmate file finding (global-set-key [(meta t)] 'textmate-goto-file) +; M-p for bouncing to the matching paren +(global-set-key [(meta p)] 'bounce-to-other-paren) (global-set-key [(meta control f)] 'textmate-find-in-project-type) +(global-set-key [(meta shift f)] 'textmate-find-in-project) (global-set-key [(meta m)] 'iconify-or-deiconify-frame) (global-set-key [(control backspace)] 'kill-word)