From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: pjb@informatimago.com (Pascal J. Bourguignon) Newsgroups: gmane.emacs.help Subject: Re: Moving to beginning and end of a list Date: Thu, 22 Oct 2009 18:20:03 +0200 Organization: Informatimago Message-ID: <877hun5rkc.fsf@galatea.local> References: <887f5295-4a75-408e-ad2f-ccd30f9c5694@f10g2000vbl.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1256230704 24647 80.91.229.12 (22 Oct 2009 16:58:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 22 Oct 2009 16:58:24 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Oct 22 18:58:13 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1N10zN-0007gR-10 for geh-help-gnu-emacs@m.gmane.org; Thu, 22 Oct 2009 18:58:13 +0200 Original-Received: from localhost ([127.0.0.1]:53962 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N10zM-0006Py-JF for geh-help-gnu-emacs@m.gmane.org; Thu, 22 Oct 2009 12:58:12 -0400 Original-Path: news.stanford.edu!usenet.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!news-1.dfn.de!news.dfn.de!news1.uni-leipzig.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 58 Original-X-Trace: individual.net QqQQjfHgPDMy6iIjpLXjlg3bjNeYjUCcmZlsCxG+ggLjQymyNz Cancel-Lock: sha1:YzdmOWUwZjYwMGI4MDMwZDAxMDgzMjY1NjRkNWI0ZjI5Y2FjODI0OQ== sha1:0MvSqRGK+OTciFwIlr5e8AQK1n8= Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en X-Disabled: X-No-Archive: no User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/22.3 (darwin) Original-Xref: news.stanford.edu gnu.emacs.help:174077 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:69160 Archived-At: Nordlöw 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__