From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Problems with syntax-ppss Date: Mon, 07 Apr 2008 10:57:08 -0400 Message-ID: References: <20080404172627.GB4804@muc.de> <47F69A4F.1050405@gmx.at> <20080405144642.GA3095@muc.de> <20080406140731.GA4084@muc.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1207580658 6741 80.91.229.12 (7 Apr 2008 15:04:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 7 Apr 2008 15:04:18 +0000 (UTC) Cc: martin rudalics , emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Apr 07 17:04:50 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Jisti-0001u1-Jn for ged-emacs-devel@m.gmane.org; Mon, 07 Apr 2008 17:04:38 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jist5-0004B6-AF for ged-emacs-devel@m.gmane.org; Mon, 07 Apr 2008 11:03:59 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Jissy-00045r-Ki for emacs-devel@gnu.org; Mon, 07 Apr 2008 11:03:52 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Jisst-0003yK-A0 for emacs-devel@gnu.org; Mon, 07 Apr 2008 11:03:52 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jisst-0003y6-0d for emacs-devel@gnu.org; Mon, 07 Apr 2008 11:03:47 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.182]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Jisss-0004lh-E7 for emacs-devel@gnu.org; Mon, 07 Apr 2008 11:03:46 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApgFADbV+UdMCpOw/2dsb2JhbACBXKhM X-IronPort-AV: E=Sophos;i="4.25,617,1199682000"; d="scan'208";a="18067533" Original-Received: from smtp.pppoe.ca (HELO smtp.teksavvy.com) ([65.39.196.238]) by ironport2-out.teksavvy.com with ESMTP; 07 Apr 2008 11:03:33 -0400 Original-Received: from ceviche.home ([76.10.147.176]) by smtp.teksavvy.com (Internet Mail Server v1.0) with ESMTP id NTK04434 for ; Mon, 07 Apr 2008 11:03:34 -0400 Original-Received: by ceviche.home (Postfix, from userid 20848) id DE2CDB46F1; Mon, 7 Apr 2008 10:57:08 -0400 (EDT) In-Reply-To: <20080406140731.GA4084@muc.de> (Alan Mackenzie's message of "Sun, 6 Apr 2008 14:07:31 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. 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:94572 Archived-At: >> > Will calling s-ppss on a narrowed buffer corrupt the cache at all, >> > for example? >> Yes it can. Similarly the cache does not keep track of the >> syntax-table so if you switch syntax-table between calls you may get >> unexpected results. > That's also not good. > Would it not be a good idea to (i) redefine syntax-ppss as calculating > the syntax from BOB (as opposed to (point-min)); That's already what it does, when it can. Maybe it could be improved as follows: signal an error if it needs to recompute from (point-min) and (point-min) is not the beginning of the buffer, unless the caller sets a `syntax-ppss-narrowed-is-ok' variable (for use in modes like Info and Rmail). Maybe that variable should be shared with font-lock-dont-widen. > (ii) have several caches, each associated with a particular syntax > table (how many modes are going to use more than 2 or, perhaps, 3?); This may incur a significant cost. I much prefer to let the caller decide when a change of syntax-table requires flushing the cache. Another approach might be to introduce a `syntax-ppss-syntax-table'. > (iii) put a `save-match-data' round the function? This is a definite "no": it is much better to let the caller do it in the very few cases where it's needed, than to pay the cost needlessly for all the other cases. Stefan