From: "Andreas Röhler" <andreas.roehler@easy-emacs.de>
To: martin rudalics <rudalics@gmx.at>
Cc: 3416@emacsbugs.donarmstrong.com
Subject: bug#3416: down-list
Date: Fri, 29 May 2009 20:04:48 +0200 [thread overview]
Message-ID: <4A2023C0.4050700@easy-emacs.de> (raw)
In-Reply-To: <4A20170F.5030909@gmx.at>
martin rudalics wrote:
> > you are right. Nonetheless, as strings are common
> > elements of lists, not just in Python, its such an
> > inconvenience, it qualifies as bug in my eyes.
> >
> > If you don't want to dig into scan-list, that trivial
> > line I've sent is enough to cure it.
>
> IIUC you want to skip anything but a left paren before starting the
> scan. This means you might skip the start of a comment or string and
> end up before the first left paren within that comment or string.
>
> The only right way to do that is to parse the syntax until point first
> and handle the case where you are in a comment or string
OK, but checking for string seems enough, as we are inside a list.
> appropriately.
> That approach has been suggested a number of times but so far no one has
> implemented it.
>
> martin
>
Very bad, as going down a list is a very basic task for any editor.
This should work:
(defun down-list (&optional arg)
"Move forward down one level of parentheses.
With ARG, do this that many times.
A negative argument means move backward but still go down a level.
This command assumes point is not in a string or comment."
(interactive "^p")
(or arg (setq arg 1))
(let ((inc (if (> arg 0) 1 -1)))
(while (/= arg 0)
;; 2009-05-29 a.roehler@web.de changed section start
(while (or (not (looking-at "\\s(")) (and (looking-at
"\\s(")(in-string-p)))
(forward-char 1)
(skip-syntax-forward "^\\s("))
;; 2009-05-29 a.roehler@web.de changed section end
(goto-char (or (scan-lists (point) inc -1) (buffer-end arg)))
(setq arg (- arg inc)))))
(defun in-string-p (&optional pos)
(let ((orig (or pos (point))))
(save-excursion
(save-restriction
(widen)
(beginning-of-defun)
(numberp (nth 3 (parse-partial-sexp (point) orig)))))))
Grüße
Andreas
next prev parent reply other threads:[~2009-05-29 18:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-29 13:13 bug#3416: down-list Andreas Roehler
2009-05-29 14:49 ` martin rudalics
2009-05-29 16:50 ` Andreas Röhler
2009-05-29 17:10 ` martin rudalics
2009-05-29 18:04 ` Andreas Röhler [this message]
2009-05-29 18:13 ` Stefan Monnier
2009-05-29 20:20 ` Andreas Röhler
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=4A2023C0.4050700@easy-emacs.de \
--to=andreas.roehler@easy-emacs.de \
--cc=3416@emacsbugs.donarmstrong.com \
--cc=rudalics@gmx.at \
/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.