all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#3416: down-list
@ 2009-05-29 13:13 Andreas Roehler
  2009-05-29 14:49 ` martin rudalics
  0 siblings, 1 reply; 7+ messages in thread
From: Andreas Roehler @ 2009-05-29 13:13 UTC (permalink / raw)
  To: emacs-pretest-bug


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





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#3416: down-list
  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
  0 siblings, 1 reply; 7+ messages in thread
From: martin rudalics @ 2009-05-29 14:49 UTC (permalink / raw)
  To: Andreas Roehler, 3416

 > 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





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#3416: down-list
  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:13     ` Stefan Monnier
  0 siblings, 2 replies; 7+ messages in thread
From: Andreas Röhler @ 2009-05-29 16:50 UTC (permalink / raw)
  To: martin rudalics; +Cc: 3416

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






^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#3416: down-list
  2009-05-29 16:50   ` Andreas Röhler
@ 2009-05-29 17:10     ` martin rudalics
  2009-05-29 18:04       ` Andreas Röhler
  2009-05-29 18:13     ` Stefan Monnier
  1 sibling, 1 reply; 7+ messages in thread
From: martin rudalics @ 2009-05-29 17:10 UTC (permalink / raw)
  To: Andreas Röhler; +Cc: 3416

 > 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





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#3416: down-list
  2009-05-29 17:10     ` martin rudalics
@ 2009-05-29 18:04       ` Andreas Röhler
  0 siblings, 0 replies; 7+ messages in thread
From: Andreas Röhler @ 2009-05-29 18:04 UTC (permalink / raw)
  To: martin rudalics; +Cc: 3416

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






^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#3416: down-list
  2009-05-29 16:50   ` Andreas Röhler
  2009-05-29 17:10     ` martin rudalics
@ 2009-05-29 18:13     ` Stefan Monnier
  2009-05-29 20:20       ` Andreas Röhler
  1 sibling, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2009-05-29 18:13 UTC (permalink / raw)
  To: Andreas Röhler; +Cc: 3416

> 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





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#3416: down-list
  2009-05-29 18:13     ` Stefan Monnier
@ 2009-05-29 20:20       ` Andreas Röhler
  0 siblings, 0 replies; 7+ messages in thread
From: Andreas Röhler @ 2009-05-29 20:20 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 3416

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








^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-05-29 20:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2009-05-29 18:13     ` Stefan Monnier
2009-05-29 20:20       ` Andreas Röhler

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.