[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: a bit help with elisp bit
From: |
Ehud Karni |
Subject: |
Re: a bit help with elisp bit |
Date: |
Mon, 23 Jan 2006 17:45:10 +0200 |
On Mon, 23 Jan 2006 13:18:15 +0200, Eli Segal wrote:
>
> I found this really great tip,
> where the cursor on a paren, you press "%" and it goes to
> the matching one.
> but I want to change it, that when my point is one place
> after the closing bracket % will work
> how do I change it ?
> still trying to grasp this lisp
You might find the following code useful:
(defun goto-matching-paren ()
"Jump to matching parenthesis (forward or backward) for ()[]{}.
For \" & ' go forward if character before is space, else backward.
If point is on space - search forward, if on non space - search backward"
(interactive)
(let ((ch (char-after (point)))
(forl '( ?\( ?\[ ?\{ ? ?\n ?\t )))
(if (or (memq ch forl)
(and (= ch ?\")
(= (char-after (1- (point))) ? )))
(progn
(forward-sexp 1)
(backward-char 1))
(progn
(forward-char 1)
(backward-sexp 1)))))
Also, you may want to use the `show-paren-mode` by adding:
(require 'paren)
(show-paren-mode 1)
to your .emacs .
Ehud.
--
Ehud Karni Tel: +972-3-7966-561 /"\
Mivtach - Simon Fax: +972-3-7966-667 \ / ASCII Ribbon Campaign
Insurance agencies (USA) voice mail and X Against HTML Mail
http://www.mvs.co.il FAX: 1-815-5509341 / \
GnuPG: 98EA398D <http://www.keyserver.net/> Better Safe Than Sorry