emacs-devel
[Top][All Lists]
Advanced

[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: Mon, 13 Nov 2006 13:52:56 +0800

Sorry but in the patch format:

Index: syntax.c
===================================================================
RCS file: /sources/emacs/emacs/src/syntax.c,v
retrieving revision 1.166.4.20
diff -u -p -r1.166.4.20 syntax.c
--- syntax.c    20 Sep 2006 06:04:11 -0000      1.166.4.20
+++ syntax.c    13 Nov 2006 05:51:53 -0000
@@ -2124,9 +2124,17 @@ forw_comment (from, from_byte, stop, nes
  register int c, c1;
  register enum syntaxcode code;
  register int syntax;
+  register int skip_soft_newlines;

  if (nesting <= 0) nesting = -1;

+  /* If `use-hard-newlines' is t, only newlines with the `hard'
+     property set to t are real newlines.  Other newlines are soft and
+     should be skipped. */
+  skip_soft_newlines = !NILP (Fsymbol_value
+                              (intern
+                               ("use-hard-newlines")));
+
  /* Enter the loop in the middle so that we find
     a 2-char comment ender if we start in the middle of it.  */
  syntax = prev_syntax;
@@ -2143,6 +2151,16 @@ forw_comment (from, from_byte, stop, nes
       }
      c = FETCH_CHAR_AS_MULTIBYTE (from_byte);
      syntax = SYNTAX_WITH_FLAGS (c);
+      if (skip_soft_newlines
+          && c == '\n'
+          && NILP (Fget_text_property (make_number (from_byte),
+                                       intern ("hard"),
+                                       Qnil)))
+        {
+          INC_BOTH (from, from_byte);
+          UPDATE_SYNTAX_TABLE_FORWARD (from);
+          continue;
+        }
      code = syntax & 0xff;
      if (code == Sendcomment
         && SYNTAX_FLAGS_COMMENT_STYLE (syntax) == style


From: "Herbert Euler" <address@hidden>
To: address@hidden
Subject: Patch: Syntax and Hard Newlines
Date: Mon, 13 Nov 2006 13:24:59 +0800

Emacs provides a hard newline mode.  If you type M-x use-hard-newlines
RET, you turn on the hard newline mode.  In this mode, all newlines in
a buffer are re-scanned and marked as either a ``hard'' one or a
``soft'' one.  The behavior of commands inserting a newline character
is also altered: `newline' and `open-line' will add the text property
`hard' (value set to t) to newlines that they insert.

As documented in the doc string of the command `use-hard-newlines',
newlines not marked hard are internal to paragraphs.  However,
currently the syntax feature does not work well with this.  For
example, if you turn on long-lines mode with M-x longlines-mode RET in
the *scratch* buffer, you will see the word `evaluation' in the first
line is wrapped into the second line, but not recognized as a part of
the comment.

To fix this, we can let the function `forw_comment' in syntax.c skip
the soft newlines when possible.  Below is the patch.

Regards,
Guanpeng Xu

Index: syntax.c
===================================================================
RCS file: /sources/emacs/emacs/src/syntax.c,v
retrieving revision 1.166.4.20
diff -r1.166.4.20 syntax.c
2126a2127
  register int skip_soft_newlines;
2129a2131,2137
  /* If `use-hard-newlines' is t, only newlines with the `hard'
     property set to t are real newlines.  Other newlines are soft and
     should be skipped. */
  skip_soft_newlines = !NILP (Fsymbol_value
                              (intern
                               ("use-hard-newlines")));

2145a2154,2163
      if (skip_soft_newlines
          && c == '\n'
          && NILP (Fget_text_property (make_number (from_byte),
                                       intern ("hard"),
                                       Qnil)))
        {
          INC_BOTH (from, from_byte);
          UPDATE_SYNTAX_TABLE_FORWARD (from);
          continue;
        }

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/



_______________________________________________
Emacs-devel mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/emacs-devel

_________________________________________________________________
Don't just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]