From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.help Subject: Elisp: How do I move to the start of the next list? Date: Wed, 1 Oct 2003 19:18:42 +0000 Organization: muc.de e.V. -- private internet access Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1065048378 30442 80.91.224.253 (1 Oct 2003 22:46:18 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 1 Oct 2003 22:46:18 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Oct 02 00:46:16 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1A4pjc-0001Yd-00 for ; Thu, 02 Oct 2003 00:46:16 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1A4muW-00014M-J5 for geh-help-gnu-emacs@m.gmane.org; Wed, 01 Oct 2003 15:45:20 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!bloom-beacon.mit.edu!npeer.de.kpn-eurorings.net!newsfeed.stueberl.de!news.space.net!news.muc.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 60 Original-NNTP-Posting-Host: acm.muc.de Original-X-Trace: marvin.muc.de 1065037004 85752 193.149.49.134 (1 Oct 2003 19:36:44 GMT) Original-X-Complaints-To: news-admin@muc.de Original-NNTP-Posting-Date: 1 Oct 2003 19:36:44 GMT User-Agent: tin/1.4.5-20010409 ("One More Nightmare") (UNIX) (Linux/2.0.35 (i686)) Original-Xref: shelby.stanford.edu gnu.emacs.help:117002 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:12931 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:12931 Frequently in an Elisp program, I'd like to move point to the start of the next list. For example, say point is here: starting point | v (cond ((eq action 'space) (+ col value)) ;; comment ((eq action 'column) ^ | desired target point I'd like a command which would move it forward to the desired target point. Something like what C-M-n does. However, C-M-n `forward-list' doesn't do quite what I want. It moves to the end of the current list, rather than the start of the next list. I frequently find myself doing C-M-n twice followed by C-M-p, or C-M-n followed by manually moving point to the start of the next list, which has been irritating me more and more AND MORE AND MORE .... to the point WHERE I JUST CAN'T STAND IT, AND I'M _SCREAMING_ EVERY TIME I WANT TO DO THIS. So, before I beg the busy people on the Emacs core team to upgrade forward-list to something like the following, so that C-u C-M-n will do what I want: (defun forward-list (&optional arg) "Move forward across one balanced group of parentheses. With ARG, do it that many times. Negative arg -N means move backward across N groups of parentheses. With bare C-u prefix, move forward to the start of the next list." (interactive "P") (if (consp arg) (let (state (lim ; pos of closing ) of current expression. (save-excursion (setq state (parse-partial-sexp (point) (point-max) -1)) ; (if (nth 2 state) (nth 2 state) (point-max))))) (point)))) ;; If we're already at a list, scan over it. (if (looking-at "\\s(") (goto-char (or (scan-lists (point) 1 0) (buffer-end arg)))) ;; Advance point to the next (, if it's not already at one. Do not go ;; outside the enclosing list. (setq state (parse-partial-sexp (point) lim 1)) (goto-char (or (nth 1 state) (1- (point))))) (goto-char (or (scan-lists (point) (prefix-numeric-value arg) 0) (buffer-end arg))))) , is there any convenient way in the current Emacs already which moves to the start of the next list? -- Alan Mackenzie (Munich, Germany) Email: aacm@muuc.dee; to decode, wherever there is a repeated letter (like "aa"), remove half of them (leaving, say, "a").