* a bit help with elisp bit
@ 2006-01-23 11:18 Eli Segal
2006-01-23 15:45 ` Ehud Karni
0 siblings, 1 reply; 2+ messages in thread
From: Eli Segal @ 2006-01-23 11:18 UTC (permalink / raw)
hey all,
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
thanx
------ the code --------------
(global-set-key "%" 'match-paren)
(defun match-paren (arg)
"Go to the matching paren if on a paren; otherwise insert %."
(interactive "p")
(cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
((looking-at "\\s\)") (forward-char 1) (backward-list 1))
(t (self-insert-command (or arg 1)))))
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: a bit help with elisp bit
2006-01-23 11:18 a bit help with elisp bit Eli Segal
@ 2006-01-23 15:45 ` Ehud Karni
0 siblings, 0 replies; 2+ messages in thread
From: Ehud Karni @ 2006-01-23 15:45 UTC (permalink / raw)
Cc: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-01-23 15:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-23 11:18 a bit help with elisp bit Eli Segal
2006-01-23 15:45 ` Ehud Karni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).