GNU bug report logs - #3416
down-list

Previous Next

Package: emacs;

Reported by: Andreas Roehler <andreas.roehler <at> online.de>

Date: Fri, 29 May 2009 13:20:04 UTC

Severity: wishlist

Merged with 5588

Fixed in version 29.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 3416 in the body.
You can then email your comments to 3416 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#3416; Package emacs. (Fri, 29 May 2009 13:20:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Andreas Roehler <andreas.roehler <at> online.de>:
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Fri, 29 May 2009 13:20:05 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Andreas Roehler <andreas.roehler <at> online.de>
To: emacs-pretest-bug <at> gnu.org
Subject: down-list
Date: Fri, 29 May 2009 15:13:15 +0200
Subject: 23.0.94; down-list

With python-modes

['ggle', ['upriv.html', 'search',]]
___|________________________

Cursor at second `g'.
M-x down-list fails with message:

down-list: Scan error: "Unbalanced parentheses", 440, 443
down-list: Scan error: "Unbalanced parentheses", 81, 87

Cause seems a bug in `scan-list' IMHO, does not
occur with XEmacs, where lisp-code is identic.

The following inserted line makes it gone

(while (/= arg 0)
+++ (when (not (looking-at "\\s("))(skip-syntax-forward "^\\s(")) +++
    (goto-char (or (scan-lists (point) inc -1) (buffer-end arg)))

Thanks

Andreas Röhler

In GNU Emacs 23.0.94.1 (i686-pc-linux-gnu, GTK+ Version 2.12.0)
 of 2009-05-25
Windowing system distributor `The X.Org Foundation', version 11.0.70200000
Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: de_DE.UTF-8
  value of $XMODIFIERS: @im=local
  locale-coding-system: utf-8-unix
  default-enable-multibyte-characters: t

Major mode: Python

Minor modes in effect:
  tooltip-mode: t
  tool-bar-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  global-auto-composition-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <right> C-M-d <left>
<left> <left> <left> <left> C-M-s C-M-d <left> C-M-d
<left> <left> C-M-d <left> <left> C-M-d C-M-d <left>
<left> <left> <left> <left> C-M-d <left> <left> C-M-d
<left> <left> C-M-d <left> <left> <left> <left> <left>
<left> <left> C-M-d <left> <left> <left> <right> C-M-d
C-M-d <left> <left> <left> <left> <left> <left> <left>
<left> <left> <left> <right> C-M-d C-x C-f <M-backspace>
e m <tab> <return> M-> <up> C-h f d o w n - l i s t
<return> C-x p C-x o <return> <right> <right> <right>
<right> <right> <right> <right> <right> <right> <right>
<right> <right> <right> <right> <right> <right> <right>
<right> <right> <right> <right> <right> <right> <right>
<right> <right> <right> <right> <right> <right> <right>
<right> <right> <right> <right> <right> <right> <right>
<right> <right> <right> <right> <right> <right> <right>
<right> <right> <right> <right> <right> <right> <right>
<right> <right> <right> <return> C-x C-w C-g <help-echo>
M-+ <down> C-x C-f <up> e l . <backspace> <backspace>
i l . e l <return> <right> <right> <right> <right>
<right> C-M-d <left> <left> <left> C-M-d <left> <left>
<left> <left> <left> <left> <left> <left> <left> C-M-d
C-x C-f <M-backspace> p y t h o <tab> e p y - p <backspace>
<backspace> . p y <return> y e s <return> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <right>
<right> <right> C-M-d <left> <left> C-M-d <up> <up>
<up> <up> <up> <up> <up> <up> <up> C-a C-k C-k C-k
C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k
<down> <down> C-k C-k <up> <up> <right> <right> <right>
C-M-d M-x r e p o r t - e m a c s - b u g <return>

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
down-list: Scan error: "Unbalanced parentheses", 238, 243 [6 times]
down-list: Scan error: "Containing expression ends prematurely", 240, 241
Mark set
Type C-x 1 to delete the help window.
help-follow: No cross-reference here
uncompressing lisp.el.gz...done
Quit
down-list: Scan error: "Unbalanced parentheses", 440, 443
down-list: Scan error: "Unbalanced parentheses", 81, 87



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#3416; Package emacs. (Fri, 29 May 2009 14:55:10 GMT) Full text and rfc822 format available.

Acknowledgement sent to martin rudalics <rudalics <at> gmx.at>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Fri, 29 May 2009 14:55:10 GMT) Full text and rfc822 format available.

Message #10 received at 3416 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: martin rudalics <rudalics <at> gmx.at>
To: Andreas Roehler <andreas.roehler <at> online.de>,
        3416 <at> debbugs.gnu.org
Subject: Re: bug#3416: down-list
Date: Fri, 29 May 2009 16:49:11 +0200
> With python-modes
>
> ['ggle', ['upriv.html', 'search',]]
> ___|________________________
>
> Cursor at second `g'.
> M-x down-list fails with message:
>
> down-list: Scan error: "Unbalanced parentheses", 440, 443
> down-list: Scan error: "Unbalanced parentheses", 81, 87

From the doc-string of `down-list':

     This command assumes point is not in a string or comment.

martin



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#3416; Package emacs. (Fri, 29 May 2009 16:55:07 GMT) Full text and rfc822 format available.

Acknowledgement sent to Andreas Röhler <andreas.roehler <at> easy-emacs.de>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Fri, 29 May 2009 16:55:07 GMT) Full text and rfc822 format available.

Message #15 received at 3416 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
To: martin rudalics <rudalics <at> gmx.at>
Cc: 3416 <at> debbugs.gnu.org
Subject: Re: bug#3416: down-list
Date: Fri, 29 May 2009 18:50:29 +0200
martin rudalics wrote:
> > With python-modes
> >
> > ['ggle', ['upriv.html', 'search',]]
> > ___|________________________
> >
> > Cursor at second `g'.
> > M-x down-list fails with message:
> >
> > down-list: Scan error: "Unbalanced parentheses", 440, 443
> > down-list: Scan error: "Unbalanced parentheses", 81, 87
>
> From the doc-string of `down-list':
>
>      This command assumes point is not in a string or comment.
>
> martin
>
>
>
>
Hi,

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.

Regards

Andreas Röhler




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#3416; Package emacs. (Fri, 29 May 2009 17:15:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to martin rudalics <rudalics <at> gmx.at>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Fri, 29 May 2009 17:15:03 GMT) Full text and rfc822 format available.

Message #20 received at 3416 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: martin rudalics <rudalics <at> gmx.at>
To: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
Cc: 3416 <at> debbugs.gnu.org
Subject: Re: bug#3416: down-list
Date: Fri, 29 May 2009 19:10:39 +0200
> 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 appropriately.
That approach has been suggested a number of times but so far no one has
implemented it.

martin



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#3416; Package emacs. (Fri, 29 May 2009 18:10:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Andreas Röhler <andreas.roehler <at> easy-emacs.de>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Fri, 29 May 2009 18:10:04 GMT) Full text and rfc822 format available.

Message #25 received at 3416 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
To: martin rudalics <rudalics <at> gmx.at>
Cc: 3416 <at> debbugs.gnu.org
Subject: Re: bug#3416: down-list
Date: Fri, 29 May 2009 20:04:48 +0200
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




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#3416; Package emacs. (Fri, 29 May 2009 18:20:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stefan Monnier <monnier <at> IRO.UMontreal.CA>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Fri, 29 May 2009 18:20:04 GMT) Full text and rfc822 format available.

Message #30 received at 3416 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
Cc: 3416 <at> debbugs.gnu.org, martin rudalics <rudalics <at> gmx.at>
Subject: Re: bug#3416: down-list
Date: Fri, 29 May 2009 14:13:45 -0400
> 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.

Agreed.  As it stands `down-list' does what it is documented to do, but
it is not always the best thing to do.  Same holds for `forward-sexp'
and several other friends.

I think these need to be split into functions (that keep the current
name and behavior) and commands (with new names), where the commands can
then be modified to be more clever about guessing the start state
(presumably using syntax-ppss) and doing something useful with it.


        Stefan



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#3416; Package emacs. (Fri, 29 May 2009 20:25:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Andreas Röhler <andreas.roehler <at> easy-emacs.de>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Fri, 29 May 2009 20:25:05 GMT) Full text and rfc822 format available.

Message #35 received at 3416 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: 3416 <at> debbugs.gnu.org, martin rudalics <rudalics <at> gmx.at>
Subject: Re: bug#3416: down-list
Date: Fri, 29 May 2009 22:20:50 +0200
Stefan Monnier 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.
>>     
>
> Agreed.  As it stands `down-list' does what it is documented to do, but
> it is not always the best thing to do.  Same holds for `forward-sexp'
> and several other friends.
>
> I think these need to be split into functions (that keep the current
> name and behavior) and commands (with new names), where the commands can
> then be modified to be more clever about guessing the start state
> (presumably using syntax-ppss) and doing something useful with it.
>
>
>         Stefan
>
>   
IMHO `down-list'  it simply may work as the name says. Limitation
mentioned in doku may
be removed.

Behavior of  `forward-sexp' is erratic for me, so I didn't use it.
Probably it pays to reflect what it should do.

Thanks all

Andreas






Severity set to `wishlist' from `normal' Request was from Glenn Morris <rgm <at> gnu.org> to control <at> emacsbugs.donarmstrong.com. (Fri, 19 Jun 2009 18:50:06 GMT) Full text and rfc822 format available.

Forcibly Merged 3416 5588. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Thu, 18 Feb 2010 00:45:07 GMT) Full text and rfc822 format available.

bug marked as fixed in version 29.1, send any further explanations to 5588 <at> debbugs.gnu.org and "Tobias C. Rittweiler" <tcr <at> freebits.de> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Fri, 06 May 2022 19:14:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 04 Jun 2022 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 298 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.