Article View: gnu.emacs.bug
Article #87265[19.27] font-lock.el work-around for parse-partial-sexp bug
From: Kevin Broadey
Date: Fri, 07 Oct 1994 11:57
Date: Fri, 07 Oct 1994 11:57
67 lines
3155 bytes
3155 bytes
I recently reported that parse-partial-sexp returns the wrong result
when it restarts a parse (using a saved STATE value) when the previous
parse ended after the first character of a 2-character comment-end
sequence. I discovered this because font-lock wasn't fontifying the
string in this simple program:-
----------------------------------------------------------------------
int main (int argc, char *argv[])
{
/***************/
printf ("Hello world\n");
}
----------------------------------------------------------------------
Here is a patch for font-lock.el that works around this problem. I've
done this because I don't fancy working out a fix for parse-partial-sexp!
--
Kevin
*** font-lock.el.sav Fri Sep 30 14:22:40 1994
--- font-lock.el Fri Oct 7 11:14:12 1994
***************
*** 194,200 ****
;; Verify the state at that place
;; so we don't get fooled by \" or \;.
(setq state (parse-partial-sexp prev (point)
! nil nil state)))
(let ((here (point)))
(if (or (nth 4 state) (nth 7 state))
;; We found a real comment start.
--- 194,200 ----
;; Verify the state at that place
;; so we don't get fooled by \" or \;.
(setq state (parse-partial-sexp prev (point)
! nil nil prevstate)))
(let ((here (point)))
(if (or (nth 4 state) (nth 7 state))
;; We found a real comment start.
***************
*** 210,216 ****
(skip-chars-backward " \t"))
(error (goto-char end))))
(put-text-property beg (point) 'face font-lock-comment-face)
! (setq state (parse-partial-sexp here (point) nil nil state)))
(if (nth 3 state)
(let ((beg (match-beginning 0)))
(while (and (re-search-forward "\\s\"" end 'move)
--- 210,223 ----
(skip-chars-backward " \t"))
(error (goto-char end))))
(put-text-property beg (point) 'face font-lock-comment-face)
! ;; Find the state at end of the comment. Parse from `prev'
! ;; (which is before the comment start) rather than `here'
! ;; (which is inside the comment) because parse-partial-sexp
! ;; gives the wrong result if `here' is between the characters
! ;; of a 2-character comment-end sequence (such as "*/" in a
! ;; c-mode buffer). KMB
! (setq state (parse-partial-sexp prev (point) nil nil
! prevstate)))
(if (nth 3 state)
(let ((beg (match-beginning 0)))
(while (and (re-search-forward "\\s\"" end 'move)
Technical Details
Message-ID:
<9410071020.AA18673@bartley>Path:
arc1-ca.pugleaf.net!bga.com!news.sprintlink.net!howland.reston.ans.net!math.ohio-state.edu!cis.ohio-state.edu!bartley.demon.co.uk!KevinBShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fb2f1,4b0403893295a625,start X-Google-Attributes: gidfb2f1,public X-Google-ArrivalTime: 1994-10-07 21:29:21 PST Path: arc1-ca.pugleaf.net!bga.com!news.sprintlink.net!howland.reston.ans.net!math.ohio-state.edu!cis.ohio-state.edu!bartley.demon.co.uk!KevinB From: KevinB@bartley.demon.co.uk (Kevin Broadey) Newsgroups: gnu.emacs.bug Subject: [19.27] font-lock.el work-around for parse-partial-sexp bug Date: 7 Oct 1994 07:57:00 -0400 Organization: GNUs Not Usenet Lines: 67 Sender: daemon@cis.ohio-state.edu Approved: bug-gnu-emacs@prep.ai.mit.edu Distribution: gnu Message-ID: <9410071020.AA18673@bartley>