From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#8218: 23.2; scan-sexps sees inconsistent syntax Date: Thu, 10 Mar 2011 20:49:30 -0500 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1299809229 8896 80.91.229.12 (11 Mar 2011 02:07:09 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 11 Mar 2011 02:07:09 +0000 (UTC) Cc: 8218-done@debbugs.gnu.org To: Dima Kogan Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Mar 11 03:07:05 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Pxrku-0007Tw-0B for geb-bug-gnu-emacs@m.gmane.org; Fri, 11 Mar 2011 03:07:04 +0100 Original-Received: from localhost ([127.0.0.1]:47062 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pxrkt-0005jQ-Bn for geb-bug-gnu-emacs@m.gmane.org; Thu, 10 Mar 2011 21:07:03 -0500 Original-Received: from [140.186.70.92] (port=33270 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pxrkn-0005jG-LQ for bug-gnu-emacs@gnu.org; Thu, 10 Mar 2011 21:06:58 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pxrkm-0003QG-Cy for bug-gnu-emacs@gnu.org; Thu, 10 Mar 2011 21:06:57 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:53818) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pxrkm-0003QC-9w for bug-gnu-emacs@gnu.org; Thu, 10 Mar 2011 21:06:56 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1PxrUR-0003GX-IH for bug-gnu-emacs@gnu.org; Thu, 10 Mar 2011 20:50:03 -0500 Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Fri, 11 Mar 2011 01:50:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 8218 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Mail-Followup-To: 8218@debbugs.gnu.org, monnier@iro.umontreal.ca Original-Received: via spool by 8218-done@debbugs.gnu.org id=D8218.129980817812519 (code D ref 8218); Fri, 11 Mar 2011 01:50:03 +0000 Original-Received: (at 8218-done) by debbugs.gnu.org; 11 Mar 2011 01:49:38 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PxrU2-0003Fs-FH for submit@debbugs.gnu.org; Thu, 10 Mar 2011 20:49:38 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.183] helo=ironport2-out.pppoe.ca) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PxrU0-0003Fc-5Z for 8218-done@debbugs.gnu.org; Thu, 10 Mar 2011 20:49:36 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEAOMNeU3O+IG+/2dsb2JhbACmNHjBT4ViBIUkkAmDQg X-IronPort-AV: E=Sophos;i="4.62,299,1297054800"; d="scan'208";a="95609542" Original-Received: from 206-248-129-190.dsl.teksavvy.com (HELO ceviche.home) ([206.248.129.190]) by ironport2-out.pppoe.ca with ESMTP/TLS/ADH-AES256-SHA; 10 Mar 2011 20:49:30 -0500 Original-Received: by ceviche.home (Postfix, from userid 20848) id 3683A66135; Thu, 10 Mar 2011 20:49:30 -0500 (EST) In-Reply-To: (Dima Kogan's message of "Thu, 10 Mar 2011 01:23:03 -0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Thu, 10 Mar 2011 20:50:03 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:44898 Archived-At: > I am seeing (scan-sexps) show inconsistent behavior depending on WHEN it > is evaluated. If the attached sample file is opened, the point placed at > the first '{', and (scan-sexps (point) 1) evaluated, the returned > position is at times of the first '}' (wrong) and at other times of the > second '}' (right). If the evaluation is done right when the file is > opened, I observe the wrong behavior. This is reliably triggered with > $ emacs -Q /tmp/tst3.pm --eval '(goto-char (scan-sexps 5 1))' > Any subsequent evaluation of the same form in that buffer produces the > correct behavior. If I turn off font-lock-mode, I consistently get > incorrect behavior. This has wide ramifications with occasional > incorrect indentation and hide-show operation, for instance. This is not a bug in syntax.c: the syntax of Perl is too complex for the simple syntax-table mechanism, so it needs to use the escape hatch, i.e. the `syntax-table' property. This property is added to particular parts of the text via font-lock-syntactic-keywords (in Emacs-23) and via syntax-propertize (in Emacs-24). So in Emacs-23, you will only get the right answer if font-lock is enabled and has processed the relevant parts of the buffer. In Emacs-24, it can work right even if font-lock is disabled, but you still need to make sure the relevant parts of the buffer have been processed. For that, you should call (syntax-propertize POS) where POS is the upper bound of the chunk of text you're interested. Stefan