GNU bug report logs -
#3416
down-list
Previous Next
Full log
Message #25 received at 3416 <at> emacsbugs.donarmstrong.com (full text, mbox):
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 <at> 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 <at> 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
This bug report was last modified 3 years and 12 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.