From: Tim X <timx@nospam.dev.null>
To: help-gnu-emacs@gnu.org
Subject: Re: elisp questions for Advanced Closing brackets function
Date: Wed, 21 May 2008 19:09:33 +1000 [thread overview]
Message-ID: <87od70vx9u.fsf@lion.rapttech.com.au> (raw)
In-Reply-To: mailman.11908.1211307132.18990.help-gnu-emacs@gnu.org
TheLonelyStar <nabble@lonely-star.org> writes:
> Hi,
>
> I have funtions in my .emacs, which inserts "[]" when one types "[" (and
> same for "(" and "{").
> I also have functions which just jumps over a "]" when "]" is typed.
> I want to make this function more advanced!
> It should do the following:
> When one types "]" it looks for the next character which is NOT a
> whitespace. If it is "]", the functions just jumps after this. Otherwise it
> inserts an "]".
> I am just lerning elisp (just for this), but I am stuck.
> My Problems:
> - How do I check if the character under (point) is a whitespace?
Read the emacs lisp reference manual on syntax tables.
> - In an "if" statement, how do I put more than one expression into the else
> case? Like this:
> (if condition (do-if-case) ((do-else-case) (do-more-else-case))
You may be a little confused. The if statement only allows one
expression in the 'if' part, but you can have multiple expressions in
the else part - just put them inside a (). Note also that you should
look at progn.
Often, lisp style tends to use other conditional constructs when
multiple expressions need to be executed, such as cond. Again, reading
existing code will help you identify the more common idioms.
> - If I have a funcion like this:
> (defun adanced-closing-bracket (arg)
> ...)
> How do I compare (arg) to the character under point?
>
I'd strongly recommend you read the emacs lisp reference manual and you
may get a bit out of Robert J Chassell's Introduction to Emacs
Lisp. both are now bundled with emacs, but both can be found on the gnu
website. I would also recommend checking out the emacs wiki.
I realise you are doing much of this as a learning exercise, but I'm not
sure how much you realise you are re-inventing an already overworked
wheel.
have a look at paredit mode. also, check what features emacs already
has. In many cases all of this stuff is already there and of course,
with source code. You can look at the code an learn a lot of useful
techniques and tricks.
tim
--
tcross (at) rapttech dot com dot au
next parent reply other threads:[~2008-05-21 9:09 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.11908.1211307132.18990.help-gnu-emacs@gnu.org>
2008-05-21 9:09 ` Tim X [this message]
[not found] <mailman.11944.1211359652.18990.help-gnu-emacs@gnu.org>
2008-05-21 10:28 ` elisp questions for Advanced Closing brackets function Rupert Swarbrick
2008-05-21 10:33 ` Rupert Swarbrick
2008-05-21 18:30 ` Ralf Angeli
2008-05-21 18:40 ` Rupert Swarbrick
2008-05-21 20:14 ` Ralf Angeli
2008-05-21 8:47 Lorenzo Isella
-- strict thread matches above, loose matches on Subject: below --
2008-05-20 18:12 TheLonelyStar
2008-05-20 18:24 ` Drew Adams
2008-05-20 20:04 ` TheLonelyStar
2008-05-20 20:19 ` Drew Adams
2008-05-21 6:18 ` Pierre Lorenzon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87od70vx9u.fsf@lion.rapttech.com.au \
--to=timx@nospam.dev.null \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.