From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.devel Subject: syntax-ppss-flush-cache Date: Thu, 20 Oct 2005 10:50:27 +0200 Message-ID: <43575A53.5080207@gmx.at> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1129802382 5287 80.91.229.2 (20 Oct 2005 09:59:42 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 20 Oct 2005 09:59:42 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Oct 20 11:59:41 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1ESXCh-0004zs-HZ for ged-emacs-devel@m.gmane.org; Thu, 20 Oct 2005 11:59:19 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ESXCg-0001Jv-VK for ged-emacs-devel@m.gmane.org; Thu, 20 Oct 2005 05:59:19 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1ESWC6-0003zL-Qv for emacs-devel@gnu.org; Thu, 20 Oct 2005 04:54:39 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1ESWC1-0003yP-LM for emacs-devel@gnu.org; Thu, 20 Oct 2005 04:54:35 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ESWBz-0003xg-5w for emacs-devel@gnu.org; Thu, 20 Oct 2005 04:54:31 -0400 Original-Received: from [213.165.64.20] (helo=mail.gmx.net) by monty-python.gnu.org with smtp (Exim 4.34) id 1ESWBz-0002SM-8O for emacs-devel@gnu.org; Thu, 20 Oct 2005 04:54:31 -0400 Original-Received: (qmail invoked by alias); 20 Oct 2005 08:54:28 -0000 Original-Received: from N783P021.adsl.highway.telekom.at (EHLO [62.47.41.213]) [62.47.41.213] by mail.gmx.net (mp018) with SMTP; 20 Oct 2005 10:54:28 +0200 X-Authenticated: #14592706 User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: de-DE, de, en-us, en Original-To: emacs-devel X-Y-GMX-Trusted: 0 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:44391 Archived-At: Consider the following stretch of elisp code: (defvar foo "string .. ............. ............." ( "doc .. ......... ......... ..........") Suppose I change some text on the line below "doc. `syntax-ppss' using `syntax-begin-function' will record something like (1 X ... (X)) where X is the position of the left paren preceding "doc. `parse-partial-sexp' run from point-min would produce a value like (2 X ... (.. X)) instead. Assume `syntax-ppss' stores the recorded state in `syntax-ppss-last'. I next delete the paren preceding "doc. `syntax-ppss-flush-cache' will now set the car of `syntax-ppss-last' to nil since BEG is not less than (car (nth 10 syntax-ppss-last)) equalling X. After this `syntax-ppss' will execute ((and (not old-pos) old-ppss (setq pt-min (or (car (nth 9 old-ppss)) ... setting `pt-min' to X. In the sequel `syntax-ppss' for any position following X may produce a value as if the paren were still there. Replacing (if (< beg (or (car (nth 10 syntax-ppss-last)) by (if (<= beg (or (car (nth 10 syntax-ppss-last)) in `syntax-ppss-flush-cache' resolves this for me. I'm not sure whether (while (and syntax-ppss-cache (> (caar syntax-ppss-cache) beg)) should become (while (and syntax-ppss-cache (>= (caar syntax-ppss-cache) beg)) as well. A related question: Shouldn't (nth 2 syntax-ppss-last) become (nth 3 syntax-ppss-last) in `syntax-ppss-flush-cache'? After all (nth 2 syntax-ppss-last) can be non-nil iff (car (nth 10 ...) is non-nil. With other words, if and when this gets evaluated it always returns nil. On the other hand you need a valid third field of `syntax-ppss-last' with (setq pt-min (or (car (nth 9 old-ppss)) (nth 8 old-ppss) (nth 2 old-ppss))) in `syntax-ppss' provided the ninth and tenth fields are nil.