[comp.emacs] Paren balancing

ram-ashwin@YALE.ARPA (Ashwin Ram) (04/22/87)

Here's a nice variation on the paren balancing feature.  If the cursor is
already sitting on a right paren, the cursor will just flash back to the
matching open paren without inserting another paren, otherwise it'll insert a
matching right paren and then flash back to the matching open paren.  This is
often nicer than the default, which always inserts another paren.

(setq blink-paren-hook
      '(lambda ()
          (if (and (not (eobp))
                   (char-equal (char-after (point)) last-input-char))
              (delete-char 1))
          (blink-matching-open)))

Alternatively:

(setq blink-paren-hook
      '(lambda ()
          (if (looking-at (char-to-string last-input-char))
              (delete-char 1))
          (blink-matching-open)))

I'm not sure which is more efficient; any clues?

-- Ashwin Ram --

ARPA:    Ram-Ashwin@yale
UUCP:    {decvax,linus,seismo}!yale!Ram-Ashwin
BITNET:  Ram@yalecs