* Request for enhancement: C-u C-M-n to move to start of _next_ list
@ 2004-02-16 16:13 Alan Mackenzie
2004-02-17 12:37 ` Thien-Thi Nguyen
2004-02-17 17:27 ` Richard Stallman
0 siblings, 2 replies; 3+ messages in thread
From: Alan Mackenzie @ 2004-02-16 16:13 UTC (permalink / raw)
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 <acm@muc.de>
* 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 <acm@muc.de>
* 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)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Request for enhancement: C-u C-M-n to move to start of _next_ list
2004-02-16 16:13 Request for enhancement: C-u C-M-n to move to start of _next_ list Alan Mackenzie
@ 2004-02-17 12:37 ` Thien-Thi Nguyen
2004-02-17 17:27 ` Richard Stallman
1 sibling, 0 replies; 3+ messages in thread
From: Thien-Thi Nguyen @ 2004-02-17 12:37 UTC (permalink / raw)
Cc: emacs-devel
Alan Mackenzie <acm@muc.de> writes:
+ 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.
this conflicts w/ the current meaning of C-u prefix for
`forward-list'. here's another more congruent approach:
(defun forward-list/comment (&optional arg)
(interactive "p")
(forward-list arg)
(forward-comment 1))
thi
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Request for enhancement: C-u C-M-n to move to start of _next_ list
2004-02-16 16:13 Request for enhancement: C-u C-M-n to move to start of _next_ list Alan Mackenzie
2004-02-17 12:37 ` Thien-Thi Nguyen
@ 2004-02-17 17:27 ` Richard Stallman
1 sibling, 0 replies; 3+ messages in thread
From: Richard Stallman @ 2004-02-17 17:27 UTC (permalink / raw)
Cc: emacs-devel
I think this is too strained--I would rather not install it.
Thanks anyway, though.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-02-17 17:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-16 16:13 Request for enhancement: C-u C-M-n to move to start of _next_ list Alan Mackenzie
2004-02-17 12:37 ` Thien-Thi Nguyen
2004-02-17 17:27 ` Richard Stallman
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).