emacs-devel
[Top][All Lists]
Advanced

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

Musings: Supposed places of safety, guaranteed by parse-partial-sexp are


From: Alan Mackenzie
Subject: Musings: Supposed places of safety, guaranteed by parse-partial-sexp are not safe.
Date: Sat, 3 Dec 2011 23:23:01 +0000
User-agent: Mutt/1.5.21 (2010-09-15)

Hi, Emacs.

There's a problem with parse-partial-sexp.  If one scans to the middle
of a comment opener  /*
                      ^
                      |
, parse-partial-sexp gives no indication that we might be half inside a
comment.  In particular, checking (nth 3 state) and (nth 4 state) is
insufficient to know that one is at a "safe place".

parse-partial-sexp does, however, notify the caller when it is just
after a backquote, a somewhat analogous situation.

No doubt there is some record of this state hidden away in (nth 9
state).

I think it would be a good idea to provide a function to test for this
"half comment" state, somewhat like `syntax-ppss-toplevel-pos'.  This
new defun could be called something like
`syntax-ppss-comment-half-opener' and calling it would return nil
usually, but ?/ in these circumstances.

What do other people think?

-- 
Alan Mackenzie (Nuremberg, Germany).



reply via email to

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