From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Request for enhancement: C-u C-M-n to move to start of _next_ list Date: Mon, 16 Feb 2004 16:13:10 +0000 (GMT) Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: sea.gmane.org 1076948241 29319 80.91.224.253 (16 Feb 2004 16:17:21 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 16 Feb 2004 16:17:21 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Mon Feb 16 17:16:59 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AslQZ-0005cI-00 for ; Mon, 16 Feb 2004 17:16:59 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1AslQZ-0007Xu-00 for ; Mon, 16 Feb 2004 17:16:59 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AslMg-0007y0-P3 for emacs-devel@quimby.gnus.org; Mon, 16 Feb 2004 11:12:58 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1AslLE-0007cq-2w for emacs-devel@gnu.org; Mon, 16 Feb 2004 11:11:28 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1AslKh-0007VF-EW for emacs-devel@gnu.org; Mon, 16 Feb 2004 11:11:26 -0500 Original-Received: from [193.149.49.134] (helo=acm.acm) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AslKf-0007UC-Q2 for emacs-devel@gnu.org; Mon, 16 Feb 2004 11:10:54 -0500 Original-Received: from localhost (root@localhost) by acm.acm (8.8.8/8.8.8) with SMTP id QAA00439 for ; Mon, 16 Feb 2004 16:13:11 GMT X-Sender: root@acm.acm Original-To: emacs-devel@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:19980 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:19980 Hi, everybody. When I'm hacking Elisp, I often want to move from the "(" of a list to the "(" of the _NEXT_ list - for example, to move through the arms of a cond form, or just simply from one form to the next in general. However, the best Emacs gives me at the moment is movement to the end of the current list. So, to go to the start of the next list, I have to (i) use the arrow keys; or (ii) go forward TWO lists with C-M-n C-M-n, then back one with C-M-p. This latter often scrolls the text maddeningly. Both alternatives drive me crazy. I suggest, therefore, that C-M-n `forward-list' be modified, so that giving a bare command prefix, C-u, causes it to move to the start of the next list. Here is a tentative pair of patches which does this: 1: To the code: 2004-02-16 Alan Mackenzie * emacs-lisp/lisp.el (forward-list): With a bare prefix argument (C-u C-M-n), go forward to the start of the _next_ list. *** lisp-1.51.el Mon Feb 16 15:00:31 2004 --- lisp-1.51.acm.el Mon Feb 16 15:27:43 2004 *************** *** 92,101 **** (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." ! (interactive "p") ! (or arg (setq arg 1)) ! (goto-char (or (scan-lists (point) arg 0) (buffer-end arg)))) (defun backward-list (&optional arg) "Move backward across one balanced group of parentheses. --- 92,115 ---- (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 (equal arg '(4)) ! (let (state ! (lim ; pos of ) which encloses point, or EOB. ! (save-excursion ! (parse-partial-sexp (point) (point-max) -1) ! (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 1)))) ! ;; 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))))) ! (setq arg (prefix-numeric-value arg)) ! (goto-char (or (scan-lists (point) arg 0) (buffer-end arg))))) (defun backward-list (&optional arg) "Move backward across one balanced group of parentheses. 2: To the manual: 2004-02-16 Alan Mackenzie * programs.texi (forward-list): With a bare prefix argument (C-u C-M-n), go forward to the start of the _next_ list. *** programs-1.79.texi Mon Feb 16 15:02:08 2004 --- programs-1.79.acm.texi Mon Feb 16 15:44:11 2004 *************** *** 755,760 **** --- 755,763 ---- @kbd{C-M-p} (@code{backward-list}) move over one (or @var{n}) parenthetical groupings, skipping blithely over any amount of text that doesn't include meaningful parentheses (symbols, strings, etc.). + If @code{forward-list} is invoked with a bare prefix (@kbd{C-u + C-M-n}), it will move to the start of the @emph{next} parenthetical + group. @kindex C-M-u @kindex C-M-d -- Alan Mackenzie (Munich, Germany)