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: syntax-propertize-function vs indentation lexer Date: Thu, 30 May 2013 10:02:59 -0400 Message-ID: References: <85mwrdbypv.fsf@member.fsf.org> <85bo7sbzhh.fsf@member.fsf.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1369922676 11850 80.91.229.3 (30 May 2013 14:04:36 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 30 May 2013 14:04:36 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stephen Leake Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu May 30 16:04:35 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Ui3Sw-0003cZ-Ec for ged-emacs-devel@m.gmane.org; Thu, 30 May 2013 16:04:30 +0200 Original-Received: from localhost ([::1]:60485 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ui3Sw-0006xy-0q for ged-emacs-devel@m.gmane.org; Thu, 30 May 2013 10:04:30 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:42095) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ui3So-0006xc-2V for emacs-devel@gnu.org; Thu, 30 May 2013 10:04:27 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ui3Sj-0006bz-Ad for emacs-devel@gnu.org; Thu, 30 May 2013 10:04:21 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.182]:54257) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ui3Sj-0006a9-5y for emacs-devel@gnu.org; Thu, 30 May 2013 10:04:17 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av8EABK/CFFFpYtM/2dsb2JhbABEuzWDWRdzgh4BAQQBViMFCws0EhQYDSSIHgbBLZEKA6R6gV6DEw X-IPAS-Result: Av8EABK/CFFFpYtM/2dsb2JhbABEuzWDWRdzgh4BAQQBViMFCws0EhQYDSSIHgbBLZEKA6R6gV6DEw X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="15188001" Original-Received: from 69-165-139-76.dsl.teksavvy.com (HELO pastel.home) ([69.165.139.76]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 30 May 2013 10:02:55 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id D2D9967B05; Thu, 30 May 2013 10:02:59 -0400 (EDT) In-Reply-To: <85bo7sbzhh.fsf@member.fsf.org> (Stephen Leake's message of "Thu, 30 May 2013 05:15:06 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.182 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:159923 Archived-At: > The doc string for syntax-propertize-function only mentions > font-lock, not indentation etc; it should say "most syntax uses", or > better, list all the places it is called. Oops, indeed it singles out font-lock. I just installed the patch below which should address this problem. > The later; I'm parsing the entire buffer with an LALR parser in > ada-mode, and whenever it changes, Sounds expensive. How does it cope with large buffers? > and caching the results for use by indent. So far it's quite fast. How much time does it take to open a 1MB file? > So I need to call > (syntax-propertize (point-max)) > in ada-mode I wouldn't put it in ada-mode, no. Instead, I'd put it closer to the code that actually needs those properties to be applied. E.g. I'd either put it in the LALR parser code (if that code needs the syntax properties) or in the indentation code. Note that calling syntax-propertize repeatedly is cheap: if the region has already been handled, it returns almost instantly since it begins with (when (and syntax-propertize-function (< syntax-propertize--done pos)) Also I probably wouldn't put (syntax-propertize (point-max)), but instead use (syntax-propertize end) where `end' is the end of the region being currently LALR-parsed or being considered by the indentation code. > (syntax-ppss-flush-cache begin) > (syntax-propertize end) > in the after-change hook. You might want to put the syntax-ppss-flush-cache there (although syntax.el should already take care of that, normally), but the syntax-propertize doesn't belong there either (since it belong to the code that actually uses those properties, i.e. either the parser or the indentation). Stefan === modified file 'lisp/emacs-lisp/syntax.el' --- lisp/emacs-lisp/syntax.el 2013-04-22 14:11:37 +0000 +++ lisp/emacs-lisp/syntax.el 2013-05-30 13:55:38 +0000 @@ -56,12 +56,13 @@ ;; syntax-ppss-flush-cache since that would not only flush the cache but also ;; reset syntax-propertize--done which should not be done in this case). "Mode-specific function to apply `syntax-table' text properties. -The value of this variable is a function to be called by Font -Lock mode, prior to performing syntactic fontification on a -stretch of text. It is given two arguments, START and END: the -start and end of the text to be fontified. Major modes can -specify a custom function to apply `syntax-table' properties to -override the default syntax table in special cases. +It is the work horse of `syntax-propertize', which is called by things like +Font-Lock and indentation. + +It is given two arguments, START and END: the start and end of the text to +which `syntax-table' might need to be applied. Major modes can use this to +override the buffer's syntax table for special syntactic constructs that +cannot be handled just by the buffer's syntax-table. The specified function may call `syntax-ppss' on any position before END, but it should not call `syntax-ppss-flush-cache',