From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Herbert Euler" Newsgroups: gmane.emacs.devel Subject: RE: Patch: Syntax and Hard Newlines Date: Tue, 14 Nov 2006 19:38:31 +0800 Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; format=flowed X-Trace: sea.gmane.org 1163504402 32745 80.91.229.2 (14 Nov 2006 11:40:02 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 14 Nov 2006 11:40:02 +0000 (UTC) Cc: rms@gnu.org, monnier@iro.umontreal.ca Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Nov 14 12:39:59 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Gjwdi-0007Uw-9c for ged-emacs-devel@m.gmane.org; Tue, 14 Nov 2006 12:39:42 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Gjwdh-0003Wn-FL for ged-emacs-devel@m.gmane.org; Tue, 14 Nov 2006 06:39:41 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Gjwcl-00035G-33 for emacs-devel@gnu.org; Tue, 14 Nov 2006 06:38:43 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Gjwcj-000345-0L for emacs-devel@gnu.org; Tue, 14 Nov 2006 06:38:42 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Gjwci-000341-S2 for emacs-devel@gnu.org; Tue, 14 Nov 2006 06:38:40 -0500 Original-Received: from [65.54.246.77] (helo=bay0-omc1-s5.bay0.hotmail.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1Gjwcc-0004kn-Tw; Tue, 14 Nov 2006 06:38:38 -0500 Original-Received: from hotmail.com ([64.4.38.36]) by bay0-omc1-s5.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.1830); Tue, 14 Nov 2006 03:38:33 -0800 Original-Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Tue, 14 Nov 2006 03:38:32 -0800 Original-Received: from 64.4.38.200 by by116fd.bay116.hotmail.msn.com with HTTP; Tue, 14 Nov 2006 11:38:31 GMT X-Originating-IP: [202.165.107.100] X-Originating-Email: [herberteuler@hotmail.com] X-Sender: herberteuler@hotmail.com In-Reply-To: Original-To: herberteuler@hotmail.com, emacs-devel@gnu.org X-OriginalArrivalTime: 14 Nov 2006 11:38:32.0980 (UTC) FILETIME=[69F13540:01C707E1] 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:62295 Archived-At: Opps, I can't understand Emacs' output. I added some code in syntax.c and longlines.el: -------------------------------------------------- *** syntax.c.orignal Tue Nov 14 18:33:22 2006 --- syntax.c Tue Nov 14 18:35:47 2006 *************** forw_comment (from, from_byte, stop, nes *** 2147,2157 **** if (code == Sendcomment && SYNTAX_FLAGS_COMMENT_STYLE (syntax) == style && (SYNTAX_FLAGS_COMMENT_NESTED (syntax) ? ! (nesting > 0 && --nesting == 0) : nesting < 0)) ! /* we have encountered a comment end of the same style ! as the comment sequence which began this comment ! section */ ! break; if (code == Scomment_fence && style == ST_COMMENT_STYLE) /* we have encountered a comment end of the same style --- 2147,2164 ---- if (code == Sendcomment && SYNTAX_FLAGS_COMMENT_STYLE (syntax) == style && (SYNTAX_FLAGS_COMMENT_NESTED (syntax) ? ! (nesting > 0 && --nesting == 0) : nesting < 0)) ! { ! message ("in `forw_comment': `syntax-table' property at point %d not nil: %d", ! from_byte, ! !NILP (Fget_text_property (make_number (from_byte), ! intern ("syntax-table"), ! Qnil))); ! /* we have encountered a comment end of the same style ! as the comment sequence which began this comment ! section */ ! break; ! } if (code == Scomment_fence && style == ST_COMMENT_STYLE) /* we have encountered a comment end of the same style *************** forw_comment (from, from_byte, stop, nes *** 2206,2211 **** --- 2213,2219 ---- } *charpos_ptr = from; *bytepos_ptr = from_byte; + message ("This comment stopped at %d", from_byte); return 1; } *************** scan_sexps_forward (stateptr, from, from *** 3120,3125 **** --- 3128,3137 ---- case Scomment: if (commentstop || boundary_stop) goto done; startincomment: + message ("in `scan_sexps_forward': `syntax-table' property at point 65 not nil: %d", + !NILP (Fget_text_property (make_number (65), + intern ("syntax-table"), + Qnil))); /* The (from == BEGV) test was to enter the loop in the middle so that we find a 2-char comment ender even if we start in the middle of it. We don't want to do that if we're just at the -------------------------------------------------- *** longlines.el.orignal Mon Nov 13 10:58:17 2006 --- longlines.el Tue Nov 14 18:24:00 2006 *************** *** 243,248 **** --- 243,255 ---- (progn (insert-before-markers ?\n) (backward-char 1) (delete-char -1) + (add-text-properties (point) + (1+ (point)) + '(syntax-table (14))) + (message (format "(in `longlines-wrap-line': char at point %d is `%c (%d)', `syntax-table' property: %s)" + (point) (char-after (point)) + (char-after (point)) + (get-text-property (point) 'syntax-table))) (forward-char 1) nil) (if (longlines-merge-lines-p) -------------------------------------------------- And I prepared another file: -------------------------------------------------- $ cat a.el; echo ;; This buffer is for notes you don't want to save, and for Lisp evaluation. ;; If you want to create a file, visit that file with C-x C-f, ;; then enter the text in that file's own buffer. (progn (longlines-mode) (sleep-for 1) (switch-to-buffer "*Messages*")) $ -------------------------------------------------- Note that the position 65 in a.el is at the first line, after the word `Lisp', i.e. before the space that before the word `evaluation'. Then I recompiled Emacs, and run `./emacs -Q a.el'. I evaluated the `progn' form, and read the output in the *Messages* buffer: -------------------------------------------------- Loading /home/xgp/src/emacs/emacs/lisp/longlines.el (source)...done (in `longlines-wrap-line': char at point 65 is ` (10)', `syntax-table' property: (14)) in `scan_sexps_forward': `syntax-table' property at point 65 not nil: 1 in `forw_comment': `syntax-table' property at point 65 not nil: 1 This comment stopped at 65 # -------------------------------------------------- The syntax code 14 means "generic comment". As documented in the elisp manual, the parsing should use "generic comment", rather than "comment stop" for the newline character at point 65. Stefan's reply, Another way to fix it, local to longlines.el is to add a syntax-table property to soft-newlines so as to prevent them from being treated like an end-of-comment. seems to mean the same thing. But why "This comment stopped at 65"? Does this indicate a bug in the syntax implementation? Regards, Guanpeng Xu _________________________________________________________________ Don't just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/