[gnu.emacs.bug] c-m-f skipping comments

straz@MEDIA-LAB.MEDIA.MIT.EDU (Steve Strassmann) (07/15/89)

mic@theory.lcs.mit.edu kindly answered my previous message, telling me about
(setq parse-sexp-ignore-comments t). But as he points out, it only seems
to work for comments that don't end in newline, so it's broken for lisp.

I'm using gnuemacs 18.54.1 to edit code in emacs-lisp and lisp modes.
When parse-sexp-ignore-comments is nil, c-m-f and c-m-b are dumb about
lines containing comments.  When parse-sexp-ignore-comments is t, many
things are broken, including backward-sexp (c-m-b), blinking matching
parens, and eval-last-sexp (c-x c-e). 

Again, please cc any replies to me, since I'm not on this list.

jrose@SUN.COM (John Rose) (07/15/89)

   Date: Fri, 14 Jul 89 16:08:18 PDT
   From: Jeff Peck <peck@denali>

   John, didn't you fix this for GNU a year ago?

Yes, I fixed it while at Thinking Machines in spring of '88, and sent
the diffs to rms or bug-gnu-emacs; I forget which.  I believe hackers
at TMC still have it running.

The fixed sexp scanner handles correctly all these cases:
	"semi in string: ;"
	"semi in string: ;" ; comment
	"semi in string: ;" ; comment; more comment
	"semi in string: ;" ; comment "not a string"
	"semi in string: ;" ; comment "not a string; more comment"

It only gets confused if there's a closing quote following a semicolon
on the same line, and the opening quote is not on the same line:
	"start string
	 second line; erroneously scanned as comment"
Workarounds for this problem include \-quoting the semicolon
(just like you need to quote a "(" in the first column)
and introducing another newline before the closing quote.

Unfortunately, the fix is to the C part of Emacs.  This means it has to
make it into the release if any large number of people are going to
benefit from it.

						-- John

   ------- Forwarded Message

   Date: Fri, 14 Jul 89 17:07:20 EDT
   From: Steve Strassmann <straz@media-lab.media.mit.edu>
   Message-Id: <8907142107.AA20834@media-lab>
   To: bug-gnu-emacs@prep.ai.mit.edu
   Subject: c-m-f skipping comments


   mic@theory.lcs.mit.edu kindly answered my previous message, telling me about
   (setq parse-sexp-ignore-comments t). But as he points out, it only seems
   to work for comments that don't end in newline, so it's broken for lisp.

   I'm using gnuemacs 18.54.1 to edit code in emacs-lisp and lisp modes.
   When parse-sexp-ignore-comments is nil, c-m-f and c-m-b are dumb about
   lines containing comments.  When parse-sexp-ignore-comments is t, many
   things are broken, including backward-sexp (c-m-b), blinking matching
   parens, and eval-last-sexp (c-x c-e). 

   Again, please cc any replies to me, since I'm not on this list.

   ------- End of Forwarded Message