emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Request for enhancement: C-u C-M-n to move to start of _next_ list


From: Alan Mackenzie
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)

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  <address@hidden>

        * 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  <address@hidden>

        * 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)






reply via email to

[Prev in Thread] Current Thread [Next in Thread]