forward-sexp parses character literal ?; as comment

Bug #405498 reported by jtappin on 2009-07-27
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
GNU Emacs
Fix Released
Unknown
emacs25 (Ubuntu)
Undecided
Unassigned

Bug Description

Binary package hint: emacs

In the *scratch* buffer if you write (insert ?;) you can evaluate this Lisp code and it behaves as intended (inserts a semicolon in the current buffer) but doing M-x forward-sexp just before the expression results in an "Unbalanced parentheses" error.

--- (Somewhat edited) original bug description follows ---

When you start Emacs by dragging a file to its icon or selecting "Open with" in Konqueror or Firefox, the startup message includes an option to dismiss the startup screen, with a checkbox to inhibit it from being shown again when Emacs is invoked anew.

If I select the "Never show it again" button, before clicking on "Dismiss the startup screen", I get the following error:

forward-sexp: Scan error: "Unbalanced parentheses", 6391, 9919

This was traced to an .emacs file which Customize attempts to parse and update, but fails because it contained a literal ?; in one of the expressions.

Version:
GNU Emacs 22.2.1 (x86_64-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
Kubuntu, Jaunty for x86-64

era (era) wrote :

I'm afraid I don't see how to reproduce this with emacs22. What do you see and what did you do when you started Emacs in order to see this?

More to the point, if you can reproduce this every time you run Emacs, do you think you could do the following, please? Run Emacs with the following:

bash$ emacs --eval '(setq debug-on-error t)'

... and then do whatever you do in order to get the error message. The contents of the resulting *Backtrace* buffer show which function was invoked and how; save that to a temporary file, and attach that file here. Thanks in advance.

I'm marking this bug as "Incomplete" to mark that we are waiting for clarifications from the person who reported the bug, but of course, anybody else who is able to supply the missing information is free to do so, and revert the Status back to "New".

Changed in emacs22 (Ubuntu):
status: New → Incomplete

The problem does not occur when emacs is opened without a file, nor
when it is called from the command line, in these cases, it just comes
up with a single buffer shown (*Scratch* or the file).

It does occur whenever I click on a file whose type is bound to emacs,
or select "open with > emacs22 (X11)" in konqueror, or if I drag the
file onto the emacs icon on the KDE panel. In these cases, emacs
starts with a split screen, the file in the upper half, and a welcome
page in the buffer *GNU emacs* in the lower half.

By eval'ing '(setq debug-on-error t)' in the scratch buffer, I did get
the backtrace:

Debugger entered--Lisp error: (scan-error "Unbalanced parentheses" 6391 9919)
  scan-sexps(103 9918)
  forward-sexp(9918)
  custom-save-delete(custom-set-variables)
  custom-save-variables()
  custom-save-all()
  (progn (customize-set-variable (quote inhibit-startup-screen) t)
(customize-mark-to-save (quote inhibit-startup-screen))
(custom-save-all))
  (if startup-screen-inhibit-startup-screen (progn
(customize-set-variable ... t) (customize-mark-to-save ...)
(custom-save-all)))
  (when startup-screen-inhibit-startup-screen (customize-set-variable
(quote inhibit-startup-screen) t) (customize-mark-to-save (quote
inhibit-startup-screen)) (custom-save-all))
  (lambda (button) (when startup-screen-inhibit-startup-screen
(customize-set-variable ... t) (customize-mark-to-save ...)
(custom-save-all)) (let (...) (and w ... ...)) (kill-buffer "*GNU
Emacs*"))(#<overlay from 737 to 764 in *GNU Emacs*>)
  push-button(752 t)
  push-button((mouse-2 (#<window 7 on *Backtrace*> 752 (108 . 287)
563149 nil 752 (15 . 16) nil (4 . 7) (9 . 18))))
  call-interactively(push-button)

Thanks for the repro steps. I still do not get the error message, but I do see the "Dismiss this startup screen [ ] Never show it again." text at the end of the *GNU Emacs* buffer. (For testing, I picked the application/zip attachment from http://sprott.physics.wisc.edu/viewtest.htm and selected "Open with > /usr/bin/emacs" in the Download dialog in Firefox.)

Is this somehow specific to KDE? Does it matter whether you use the keyboard or the mouse to select the "Dismiss this startup screen" link? Do you have anything in your .emacs file which could be causing this? (Can you create a shell script which runs emacs -q, and select that as the application to open the file with? That would cause it to not read your .emacs file.)

#!/bin/sh
exec /usr/bin/emacs -q "$@"

In fact, the error message sort of suggests that you might have an error in your .emacs file. If it doesn't contain anything sensitive, do you think you could attach it here?

Note that the initialization file could have a different location, depending on your setup etc. In emacs22 the file can also be ~/.emacs.d/init.el; see http://www.gnu.org/software/emacs/manual/html_node/emacs/Init-File.html for the full scoop.

Leaving this bug report as "Status: Incomplete" still.

  • .emacs Edit (9.7 KiB, text/plain; charset=US-ASCII; name=".emacs")

On 02/08/2009, era <email address hidden> wrote:

> Is this somehow specific to KDE? Does it matter whether you use the
> keyboard or the mouse to select the "Dismiss this startup screen" link?
> Do you have anything in your .emacs file which could be causing this?
> (Can you create a shell script which runs emacs -q, and select that as
> the application to open the file with? That would cause it to not read
> your .emacs file.)
>
> #!/bin/sh
> exec /usr/bin/emacs -q "$@"

I've only tried the mouse, and I've not used anything other than KDE.
When I use the script, then there is only the "dismiss this startup
screen" but no "never show it again" button.

> In fact, the error message sort of suggests that you might have an error
> in your .emacs file. If it doesn't contain anything sensitive, do you
> think you could attach it here?

Done.
From the date stamp on it (July 04) I think it may well be the default
.emacs from Debian Sarge (which had emacs 21.4.1).

With this .emacs file I am able to reproduce the error. The error message implicates the tex-mode-hook stanza which begins on line 195 of the .emacs file. Apparently forward-sexp cannot cope with the character literal for a literal semicolon character, which I think is a bug if Emacs doesn't otherwise choke on it. Changing the line

                        (modify-syntax-entry ?; "w")

to

                        (modify-syntax-entry ?\; "w")

allows forward-sexp to parse the sexp correctly.

I don't think Debian ever shipped with a default .emacs file but I could be wrong.

Changed in emacs22 (Ubuntu):
status: Incomplete → Confirmed
summary: - emacs22 (X11) "don't show startup screen again" fails
+ forward-sexp parses character literal ?; as comment

I can confirm that inserting the backslash before the semicolon as
suggested works for me.

era (era) on 2009-08-03
description: updated
era (era) wrote :

Successfully reproduced the forward-sexp error with a recent emacs-snapshot (20090730-1~intrepid1 corresponding to GNU Emacs 23.1.50.1; to my best understanding more or less an official Emacs 23)

era (era) wrote :
Changed in emacs:
status: Unknown → Fix Released
era (era) wrote :

Upstream seems to be leaning towards "character literals really should have a backslash if they contain tricky characters" but has not (yet?) closed the bug as invalid / wontfix.

FWIW the Bug Watch Updater has incorrectly marked the upstream bug as Fix Released. This seems to be a recurring problem with Emacs bugs; see LP bug #343469

era (era) wrote :

Upstream is now (finally!) closed as Wontfix, but the rationale is that other code paths have been updated to provide a useful warning (if I am reading this correctly). Updating Package: from emacs22 (sic) to emacs25 and setting status to Fix committed.

affects: emacs22 (Ubuntu) → emacs25 (Ubuntu)
Changed in emacs25 (Ubuntu):
status: Confirmed → Fix Committed
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.