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: Was [... Apply `comment-depth' text properties when calling `back_comment'.] Date: Thu, 10 Mar 2016 18:10:58 -0500 Message-ID: References: <20160309141930.GC3948@acm.fritz.box> <20160309193758.GH3948@acm.fritz.box> <20160310130156.GA4831@acm.fritz.box> <20160310152949.GB4831@acm.fritz.box> <20160310172539.GC4831@acm.fritz.box> <20160310190824.GD4831@acm.fritz.box> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1457651483 24150 80.91.229.3 (10 Mar 2016 23:11:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 10 Mar 2016 23:11:23 +0000 (UTC) Cc: emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Mar 11 00:11:14 2016 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 1ae9jY-0002C6-TE for ged-emacs-devel@m.gmane.org; Fri, 11 Mar 2016 00:11:09 +0100 Original-Received: from localhost ([::1]:51694 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ae9jX-0006z3-Vo for ged-emacs-devel@m.gmane.org; Thu, 10 Mar 2016 18:11:07 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40322) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ae9jU-0006yp-AE for emacs-devel@gnu.org; Thu, 10 Mar 2016 18:11:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ae9jQ-0001Lr-5Z for emacs-devel@gnu.org; Thu, 10 Mar 2016 18:11:04 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:7603) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ae9jQ-0001Lj-0q for emacs-devel@gnu.org; Thu, 10 Mar 2016 18:11:00 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0CbDQA731xV/0a6+M5cgxCEAsYTgk0EAgKBPDwRAQEBAQEBAYEKQQWDXQEBAwFWIwULCw4mBwsUGA0kiDcIzyMBAQEHAQEBAR6LOoUFB4QtBYwwnkuIRIFFI4FmJBwVgVsggngBAQE X-IPAS-Result: A0CbDQA731xV/0a6+M5cgxCEAsYTgk0EAgKBPDwRAQEBAQEBAYEKQQWDXQEBAwFWIwULCw4mBwsUGA0kiDcIzyMBAQEHAQEBAR6LOoUFB4QtBYwwnkuIRIFFI4FmJBwVgVsggngBAQE X-IronPort-AV: E=Sophos;i="5.13,465,1427774400"; d="scan'208";a="195906558" Original-Received: from 206-248-186-70.dsl.teksavvy.com (HELO fmsmemgm.homelinux.net) ([206.248.186.70]) by ironport2-out.teksavvy.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 10 Mar 2016 18:10:58 -0500 Original-Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 60913AE323; Thu, 10 Mar 2016 18:10:58 -0500 (EST) In-Reply-To: <20160310190824.GD4831@acm.fritz.box> (Alan Mackenzie's message of "Thu, 10 Mar 2016 19:08:24 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.181 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:201435 Archived-At: > Visit xdisp.c. Run the following function. It breaks: > (defun test-break-0 () > (interactive) > (goto-char (point-min)) > (or (forward-comment 2) > (error "(forward-comment 2) failed")) > (or (forward-comment -2) > (error "(forward-comment -2) failed")) > (message "(forward-comment -2) succeeded")) Ah, sorry, the patch indeed is incomplete in that it doesn't make Emacs ignore open-paren-in-column-0-is-defun-start. So you can fix the above problem with (setq open-paren-in-column-0-is-defun-start nil) or replace my previous patch with this one below, which is almost identical to the previous one, tho a bit cleaner and with a fix to make comment-use-syntax-ppss override open-paren-in-column-0-is-defun-start, as it should. Stefan diff --git a/src/syntax.c b/src/syntax.c index 249d0d5..f2268da 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -597,6 +597,26 @@ find_defun_start (ptrdiff_t pos, ptrdiff_t pos_byte) && MODIFF == find_start_modiff) return find_start_value; + if (!NILP (Vcomment_use_syntax_ppss)) + { + EMACS_INT modiffs = CHARS_MODIFF; + Lisp_Object ppss = call1 (Qsyntax_ppss, make_number (pos)); + if (modiffs != CHARS_MODIFF) + error ("syntax-ppss modified the buffer!"); + TEMP_SET_PT_BOTH (opoint, opoint_byte); + Lisp_Object boc = Fnth (make_number (8), ppss); + if (NUMBERP (boc)) + { + find_start_value = XINT (boc); + find_start_value_byte = CHAR_TO_BYTE (find_start_value); + } + else + { + find_start_value = pos; + find_start_value_byte = pos_byte; + } + goto found; + } if (!open_paren_in_column_0_is_defun_start) { find_start_value = BEGV; @@ -864,6 +884,7 @@ back_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, case Sopen: /* Assume a defun-start point is outside of strings. */ if (open_paren_in_column_0_is_defun_start + && NILP (Vcomment_use_syntax_ppss)) && (from == stop || (temp_byte = dec_bytepos (from_byte), FETCH_CHAR (temp_byte) == '\n'))) @@ -3647,6 +3668,11 @@ void syms_of_syntax (void) { DEFSYM (Qsyntax_table_p, "syntax-table-p"); + DEFSYM (Qsyntax_ppss, "syntax-ppss-for-syntax.c"); + DEFVAR_LISP ("comment-use-syntax-ppss", + Vcomment_use_syntax_ppss, + doc: /* Non-nil means `forward-comment' can use `syntax-ppss' internally. */); + Vcomment_use_syntax_ppss = Qt; staticpro (&Vsyntax_code_object);