all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
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)	[thread overview]
Message-ID: <Pine.LNX.3.96.1040216160037.332A-100000@acm.acm> (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)

             reply	other threads:[~2004-02-16 16:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-16 16:13 Alan Mackenzie [this message]
2004-02-17 12:37 ` Request for enhancement: C-u C-M-n to move to start of _next_ list Thien-Thi Nguyen
2004-02-17 17:27 ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.3.96.1040216160037.332A-100000@acm.acm \
    --to=acm@muc.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.