X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Fsyntax.c;h=3388e6dd08cb1f8fa0e4ffcb3544135fea3fd85e;hb=44ea030ec31ae441e59974eb9f6b2a9404611cd8;hp=2e0dde9f9e9b5aeb68fc70b1738e65daacc5db1b;hpb=afa9772e3fcbb4e80e3e4cfd1a40b4fccc6d08b8;p=chise%2Fxemacs-chise.git.1 diff --git a/src/syntax.c b/src/syntax.c index 2e0dde9..9a1d56b 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -27,6 +27,8 @@ Boston, MA 02111-1307, USA. */ #include "lisp.h" #include "buffer.h" +#include "commands.h" +#include "insdel.h" #include "syntax.h" /* Here is a comment from Ken'ichi HANDA @@ -53,7 +55,6 @@ Sextword is a word-constituent but a word boundary may exist between two such characters. */ /* Mule 2.4 doesn't seem to have Sextword - I'm removing it -- mrb */ -/* Recovered by tomo */ Lisp_Object Qsyntax_table_p; @@ -328,17 +329,15 @@ syntax table. -#ifdef MULE -/* Return 1 if there is a word boundary between two word-constituent - characters C1 and C2 if they appear in this order, else return 0. - There is no word boundary between two word-constituent ASCII - characters. */ -#define WORD_BOUNDARY_P(c1, c2) \ - (!(CHAR_ASCII_P (c1) && CHAR_ASCII_P (c2)) \ - && word_boundary_p (c1, c2)) - -extern int word_boundary_p (Emchar c1, Emchar c2); -#endif +static int +word_constituent_p (struct buffer *buf, Bufpos pos, + struct Lisp_Char_Table *tab) +{ + enum syntaxcode code = SYNTAX_UNSAFE (tab, BUF_FETCH_CHAR (buf, pos)); + return ((words_include_escapes && + (code == Sescape || code == Scharquote)) + || (code == Sword)); +} /* Return the position across COUNT words from FROM. If that many words cannot be found before the end of the buffer, return 0. @@ -349,10 +348,6 @@ scan_words (struct buffer *buf, Bufpos from, int count) { Bufpos limit = count > 0 ? BUF_ZV (buf) : BUF_BEGV (buf); struct Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table); - Emchar ch0, ch1; - enum syntaxcode code; - - /* #### is it really worth it to hand expand both cases? JV */ while (count > 0) { QUIT; @@ -361,36 +356,15 @@ scan_words (struct buffer *buf, Bufpos from, int count) { if (from == limit) return 0; - - ch0 = BUF_FETCH_CHAR (buf, from); - code = SYNTAX_UNSAFE (mirrortab, ch0); - - if (words_include_escapes - && (code == Sescape || code == Scharquote)) + if (word_constituent_p (buf, from, mirrortab)) break; - if (code == Sword) - break; - from++; } QUIT; - while (from != limit) + while ((from != limit) && word_constituent_p (buf, from, mirrortab)) { - ch1 = BUF_FETCH_CHAR (buf, from); - code = SYNTAX_UNSAFE (mirrortab, ch1); - if (!(words_include_escapes - && (code == Sescape || code == Scharquote))) - if (code != Sword -#ifdef MULE - || WORD_BOUNDARY_P (ch0, ch1) -#endif - ) - break; -#ifdef MULE - ch0 = ch1; -#endif from++; } count--; @@ -404,35 +378,15 @@ scan_words (struct buffer *buf, Bufpos from, int count) { if (from == limit) return 0; - - ch1 = BUF_FETCH_CHAR (buf, from - 1); - code = SYNTAX_UNSAFE (mirrortab, ch1); - if (words_include_escapes - && (code == Sescape || code == Scharquote)) + if (word_constituent_p (buf, from - 1, mirrortab)) break; - if (code == Sword) - break; - from--; } QUIT; - while (from != limit) + while ((from != limit) && word_constituent_p (buf, from - 1, mirrortab)) { - ch0 = BUF_FETCH_CHAR (buf, from - 1); - code = SYNTAX_UNSAFE (mirrortab, ch0); - if (!(words_include_escapes - && (code == Sescape || code == Scharquote))) - if (code != Sword -#ifdef MULE - || WORD_BOUNDARY_P (ch0, ch1) -#endif - ) - break; -#ifdef MULE - ch1 = ch0; -#endif from--; } count++; @@ -442,12 +396,10 @@ scan_words (struct buffer *buf, Bufpos from, int count) } DEFUN ("forward-word", Fforward_word, 1, 2, "_p", /* -Move point forward COUNT words (backward if COUNT is negative). +Move point forward ARG words (backward if ARG is negative). Normally returns t. If an edge of the buffer is reached, point is left there and nil is returned. - -Optional argument BUFFER defaults to the current buffer. */ (count, buffer)) { @@ -661,7 +613,7 @@ Optional argument BUFFER defaults to the current buffer. Bufpos stop; Emchar c; enum syntaxcode code; - EMACS_INT count; + int count; struct buffer *buf = decode_buffer (buffer, 0); struct Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table); @@ -1690,18 +1642,9 @@ Non-nil means `forward-word', etc., should treat escape chars part of words. no_quit_in_re_search = 0; } -static void -define_standard_syntax (CONST char *p, enum syntaxcode syn) -{ - for (; *p; p++) - Fput_char_table (make_char (*p), make_int (syn), Vstandard_syntax_table); -} - void complex_vars_of_syntax (void) { - Emchar i; - CONST char *p; /* Set this now, so first buffer creation can refer to it. */ /* Make it nil before calling copy-syntax-table so that copy-syntax-table will know not to try to copy from garbage */ @@ -1709,35 +1652,72 @@ complex_vars_of_syntax (void) Vstandard_syntax_table = Fcopy_syntax_table (Qnil); staticpro (&Vstandard_syntax_table); - Vsyntax_designator_chars_string = make_string_nocopy (syntax_code_spec, - Smax); + Vsyntax_designator_chars_string = make_pure_string (syntax_code_spec, + Smax, Qnil, 1); staticpro (&Vsyntax_designator_chars_string); - fill_char_table (XCHAR_TABLE (Vstandard_syntax_table), make_int (Spunct)); + fill_char_table (XCHAR_TABLE (Vstandard_syntax_table), + make_int (Spunct)); + + { + Emchar i; - for (i = 0; i <= 32; i++) /* Control 0 plus SPACE */ - Fput_char_table (make_char (i), make_int (Swhitespace), + for (i = 0; i <= 32; i++) + Fput_char_table (make_char (i), make_int ((int) Swhitespace), + Vstandard_syntax_table); + for (i = 127; i <= 159; i++) + Fput_char_table (make_char (i), make_int ((int) Swhitespace), + Vstandard_syntax_table); + + for (i = 'a'; i <= 'z'; i++) + Fput_char_table (make_char (i), make_int ((int) Sword), + Vstandard_syntax_table); + for (i = 'A'; i <= 'Z'; i++) + Fput_char_table (make_char (i), make_int ((int) Sword), + Vstandard_syntax_table); + for (i = '0'; i <= '9'; i++) + Fput_char_table (make_char (i), make_int ((int) Sword), + Vstandard_syntax_table); + Fput_char_table (make_char ('$'), make_int ((int) Sword), Vstandard_syntax_table); - for (i = 127; i <= 159; i++) /* DEL plus Control 1 */ - Fput_char_table (make_char (i), make_int (Swhitespace), + Fput_char_table (make_char ('%'), make_int ((int) Sword), Vstandard_syntax_table); - define_standard_syntax ("abcdefghijklmnopqrstuvwxyz" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "0123456789" - "$%", Sword); - define_standard_syntax ("\"", Sstring); - define_standard_syntax ("\\", Sescape); - define_standard_syntax ("_-+*/&|<>=", Ssymbol); - define_standard_syntax (".,;:?!#@~^'`", Spunct); - - for (p = "()[]{}"; *p; p+=2) { - Fput_char_table (make_char (p[0]), - Fcons (make_int (Sopen), make_char (p[1])), + Fput_char_table (make_char ('('), Fcons (make_int ((int) Sopen), + make_char (')')), + Vstandard_syntax_table); + Fput_char_table (make_char (')'), Fcons (make_int ((int) Sclose), + make_char ('(')), + Vstandard_syntax_table); + Fput_char_table (make_char ('['), Fcons (make_int ((int) Sopen), + make_char (']')), Vstandard_syntax_table); - Fput_char_table (make_char (p[1]), - Fcons (make_int (Sclose), make_char (p[0])), + Fput_char_table (make_char (']'), Fcons (make_int ((int) Sclose), + make_char ('[')), Vstandard_syntax_table); + Fput_char_table (make_char ('{'), Fcons (make_int ((int) Sopen), + make_char ('}')), + Vstandard_syntax_table); + Fput_char_table (make_char ('}'), Fcons (make_int ((int) Sclose), + make_char ('{')), + Vstandard_syntax_table); + } + + Fput_char_table (make_char ('"'), make_int ((int) Sstring), + Vstandard_syntax_table); + Fput_char_table (make_char ('\\'), make_int ((int) Sescape), + Vstandard_syntax_table); + + { + CONST char *p; + for (p = "_-+*/&|<>="; *p; p++) + Fput_char_table (make_char (*p), make_int ((int) Ssymbol), + Vstandard_syntax_table); + + for (p = ".,;:?!#@~^'`"; *p; p++) + Fput_char_table (make_char (*p), make_int ((int) Spunct), + Vstandard_syntax_table); } + } }