[OS X Emacs] parens matching

"M. Tamer Özsu" tozsu at sympatico.ca
Thu Jan 15 20:43:59 EST 2009


Thank you much Ian; I appreciate your response.

==Tamer

On Thu 15-Jan-09, at 12:57 PM, Ian Eure wrote:

> On Jan 14, 2009, at 8:23 PM, M. Tamer Özsu wrote:
>
>> I am trying the new Aquamacs 1.6 -- it is very nice. I wonder if  
>> there is a way to get parens matching (and quote matching, etc,  
>> etc). I have "AutoPairs" system preference installed, but it does  
>> not work properly, when I type {, it inserts {}}, highlights the  
>> first {} in aqua color and then puts the cursor right after that.  
>> When I turn off AutoPairs for Aquamacs, then no pairing occurs.
>>
>> Any suggestions would be very much appreciated.
>>
> You want (insert-pair). The default setup gives you a pair of  
> parenthesis when you hit M-(.
>
> You can see the known pairs with:
> (mapcar (lambda (pair) (mapcar (lambda (char) (char-to-string char))  
> pair))
>        insert-pair-alist)
>
> I use this code to add some additional useful pairs:
>
> (mapc (lambda (pair) (add-to-list 'insert-pair-alist pair))
>      '((?“ ?”) (?‘ ?’) (?+ ?+) (?. ?.)))
>
>
> Then bind:
>
> (mapc (lambda (key) (define-key (current-global-map) key 'insert- 
> pair))
>      '("\M-'" "\M-\"" [?\M-“] [?\M-‘] "\M-[" "\M-+" "\C-c`" "\C-c{"  
> "\C-c."))
>
> Giving you M-“ M-‘ M-' M-[ M-+ C-c ` C-c { C-c . to insert pairs.
>
> I prefer explicitly asking for pairs rather than having them  
> inserted for me. But if you want that behavior (in Emacs, it's  
> called "electric" behavior), you could change that to:
>
> (mapcar (lambda (pair)
>          (define-key (current-global-map) (char-to-string (car pair))
>            'insert-pair)) insert-pair-alist)
>
> And this will map the opening character of every pair in insert-pair- 
> alist to (insert-pair), which will insert the pair for you. If you  
> don't want to insert a pair, you'd need to type e.g. C-q (
>
> - Ian_____________________________________________________________
> MacOSX-Emacs mailing list
> MacOSX-Emacs at email.esm.psu.edu
> http://email.esm.psu.edu/mailman/listinfo/macosx-emacs
> List Archives: http://dir.gmane.org/gmane.emacs.macintosh.osx




More information about the MacOSX-Emacs mailing list