[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Moving to beginning and end of a list
From: |
Pascal J. Bourguignon |
Subject: |
Re: Moving to beginning and end of a list |
Date: |
Thu, 22 Oct 2009 18:20:03 +0200 |
User-agent: |
Gnus/5.1008 (Gnus v5.10.8) Emacs/22.3 (darwin) |
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__