* Moving to beginning and end of a list
@ 2009-10-22 14:51 Nordlöw
2009-10-22 16:20 ` Pascal J. Bourguignon
0 siblings, 1 reply; 2+ messages in thread
From: Nordlöw @ 2009-10-22 14:51 UTC (permalink / raw)
To: help-gnu-emacs
I have found these two functions very useful especially when do lisp
hacking and designing clever macros:
(defun move-beginning-of-list ()
"Move to beginning of list, before first element."
(interactive)
(while (ignore-errors (backward-sexp) t)))
(global-set-key [(meta shift ?a)] 'move-beginning-of-list)
(defun move-end-of-list ()
"Move to end of list, after first element."
(interactive)
(while (ignore-errors (forward-sexp) t)))
(global-set-key [(meta shift ?e)] 'move-end-of-list)
Does Emacs contain something similar by default.
/Nordlöw
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Moving to beginning and end of a list
2009-10-22 14:51 Moving to beginning and end of a list Nordlöw
@ 2009-10-22 16:20 ` Pascal J. Bourguignon
0 siblings, 0 replies; 2+ messages in thread
From: Pascal J. Bourguignon @ 2009-10-22 16:20 UTC (permalink / raw)
To: help-gnu-emacs
Nordlöw <per.nordlow@gmail.com> writes:
> I have found these two functions very useful especially when do lisp
> hacking and designing clever macros:
>
> (defun move-beginning-of-list ()
> "Move to beginning of list, before first element."
> (interactive)
> (while (ignore-errors (backward-sexp) t)))
> (global-set-key [(meta shift ?a)] 'move-beginning-of-list)
>
> (defun move-end-of-list ()
> "Move to end of list, after first element."
> (interactive)
> (while (ignore-errors (forward-sexp) t)))
> (global-set-key [(meta shift ?e)] 'move-end-of-list)
>
> Does Emacs contain something similar by default.
AFAIK, no.
There is a nice minor mode to edit sexps: paredit
but it doesn't contain these features.
http://mumble.net/~campbell/emacs/
Slime contains a _function_ slime-beginning-of-list, that could be
wrapped in a command, but no slime-end-of-list.
Notice that to keep consistency with emacs lisp beginning-of-line,
end-of-line, beginning-of-buffer, end-of-buffer, etc, you should name
them beginning-of-list and end-of-list.
Similarly, emacs lisp contains functions that would allow to implement
them more easily (and possibly, more generally):
(defun beginning-of-list ()
"Move to beginning of list, before first element."
(interactive)
(up-list)
(beginning-of-sexp)
(down-list))
(defun end-of-list ()
"Move to end of list, after last element."
(interactive)
(up-list)
(down-list -1))
It might be a good idea to propose inclusion of these functions to
paredit.
--
__Pascal Bourguignon__
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-10-22 16:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-22 14:51 Moving to beginning and end of a list Nordlöw
2009-10-22 16:20 ` Pascal J. Bourguignon
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).