From 3df1fef1b583aa40dd61de1043c018c52329d1f0 Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Sat, 29 May 2010 23:30:40 -0700 Subject: [PATCH] bind select-enclosing-pair to Meta-B and noted some deficiencies --- emacs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/emacs b/emacs index e2545b0..02c1a74 100644 --- a/emacs +++ b/emacs @@ -345,6 +345,9 @@ ;; wrap a region with an HTML/XML tag (global-set-key "<" 'tagify-region-or-insert-self) +;; Select the enclosed parens/brackets/braces +(global-set-key "\M-B" 'select-enclosing-pair) + ;; nice OS X keyboard behaviors that save my pinky too (global-unset-key "\C-_") (global-unset-key "\C-x\C-f") @@ -429,7 +432,11 @@ If N is non-nil switch to the nth next window." "Pairs of characters to look for when marking an enclosed region." '((?( ?)) (?[ ?]) (?{ ?}) (?< ?>))) -;; Well, it's ugly as sin but it does the job. +;; Well, it's ugly as sin but it works in simple cases. Needs a +;; smarter algorithm to work in more situations. One example that +;; doesn't work with this algo: (something "<" 'other-stuff) +;; +;; FIXME there's at least one off-by-one error with the ignore-count (defun select-enclosing-pair (&optional n pairs) "Select text between the innermost pair of characters given in PAIRS, defaults are: (), [], {}, <>."