[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Patch: Syntax and Hard Newlines
From: |
Herbert Euler |
Subject: |
RE: Patch: Syntax and Hard Newlines |
Date: |
Tue, 14 Nov 2006 19:38:31 +0800 |
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
#<buffer *Messages*>
--------------------------------------------------
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/
- Re: Patch: Syntax and Hard Newlines, (continued)
Re: Patch: Syntax and Hard Newlines, Richard Stallman, 2006/11/14
Re: Patch: Syntax and Hard Newlines, Richard Stallman, 2006/11/13
RE: Patch: Syntax and Hard Newlines, Herbert Euler, 2006/11/14
- RE: Patch: Syntax and Hard Newlines,
Herbert Euler <=
RE: Patch: Syntax and Hard Newlines, Herbert Euler, 2006/11/16
- Re: Patch: Syntax and Hard Newlines, martin rudalics, 2006/11/17
- Re: Patch: Syntax and Hard Newlines, Herbert Euler, 2006/11/16
- Re: Patch: Syntax and Hard Newlines, martin rudalics, 2006/11/17
- Re: Patch: Syntax and Hard Newlines, Herbert Euler, 2006/11/16
- Re: Patch: Syntax and Hard Newlines, martin rudalics, 2006/11/17
- Re: Patch: Syntax and Hard Newlines, Herbert Euler, 2006/11/16
- Re: Patch: Syntax and Hard Newlines, martin rudalics, 2006/11/17
- Re: Patch: Syntax and Hard Newlines, Herbert Euler, 2006/11/16