bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#4030: forward-sexp parses character literal ?; as comment


From: martin rudalics
Subject: bug#4030: forward-sexp parses character literal ?; as comment
Date: Fri, 07 Aug 2009 15:01:27 +0200
User-agent: Thunderbird 2.0.0.21 (Windows/20090302)

>> We could try to mark any `?;' or `?"' sequences appropriately when
>> fontifying though.
>
> We could/should/will improve the syntax parsing to handle those
> things properly.  But it's a non-trivial amount of work, especially
> since every major mode has similar issues but needs different
> extra functionality.

But fontification is mode-specific.  So it would be sufficient to look
for ?s that are not within strings or comments and followed by a
semicolon, paren or double-quote and mark that appropriately (obviously
the parser is derailed at that time but it still might help people spot
the bug).

>>> I'll also point out that an "Unbalanced parentheses" error from deep
>>> inside Customize is not a very helpful error message (especially as it
>>> does not indicate in which buffer the unbalanced parentheses were
>>> found); but perhaps Customize should be adapted to cope if forward-sexp
>>> cannot easily be fixed.
>> Getting good diagnostics after a parsing error is hard.
>
> Agreed, but that doesn't mean we shouldn't intend to do better: the
> current behavior (signalling an internal error to the user) is a bug
> that needs to be fixed.

If the problem comes from the unprotected

      (save-excursion (forward-sexp (buffer-size)))) ; Test for scan errors.

call in `custom-save-delete' we could simply wrap it as in the patch
below.  But do we really have to scan the buffer in the first place?

martin

*** cus-edit.el.~1.364.~        2009-07-27 08:09:05.997162900 +0200
--- cus-edit.el 2009-08-07 14:49:22.890625000 +0200
***************
*** 4341,4347 ****
    ;; Skip all whitespace and comments.
    (while (forward-comment 1))
    (or (eobp)
!       (save-excursion (forward-sexp (buffer-size)))) ; Test for scan errors.
    (let (first)
      (catch 'found
        (while t ;; We exit this loop only via throw.
--- 4341,4349 ----
    ;; Skip all whitespace and comments.
    (while (forward-comment 1))
    (or (eobp)
!       (condition-case nil
!         (save-excursion (forward-sexp (buffer-size))) ; Test for scan errors.
!       (scan-error (error "Scan error, watch out for ... "))))
    (let (first)
      (catch 'found
        (while t ;; We exit this loop only via throw.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]