comparison src/syntax.c @ 109351:c8a969d13eda

merge trunk
author Kenichi Handa <handa@etlken>
date Fri, 09 Jul 2010 15:55:27 +0900
parents 8cfee7d2955f
children 89a16701cde1
comparison
equal deleted inserted replaced
109350:c11d07f3d731 109351:c8a969d13eda
719 } 719 }
720 720
721 DEFUN ("syntax-table-p", Fsyntax_table_p, Ssyntax_table_p, 1, 1, 0, 721 DEFUN ("syntax-table-p", Fsyntax_table_p, Ssyntax_table_p, 1, 1, 0,
722 doc: /* Return t if OBJECT is a syntax table. 722 doc: /* Return t if OBJECT is a syntax table.
723 Currently, any char-table counts as a syntax table. */) 723 Currently, any char-table counts as a syntax table. */)
724 (object) 724 (Lisp_Object object)
725 Lisp_Object object;
726 { 725 {
727 if (CHAR_TABLE_P (object) 726 if (CHAR_TABLE_P (object)
728 && EQ (XCHAR_TABLE (object)->purpose, Qsyntax_table)) 727 && EQ (XCHAR_TABLE (object)->purpose, Qsyntax_table))
729 return Qt; 728 return Qt;
730 return Qnil; 729 return Qnil;
738 } 737 }
739 738
740 DEFUN ("syntax-table", Fsyntax_table, Ssyntax_table, 0, 0, 0, 739 DEFUN ("syntax-table", Fsyntax_table, Ssyntax_table, 0, 0, 0,
741 doc: /* Return the current syntax table. 740 doc: /* Return the current syntax table.
742 This is the one specified by the current buffer. */) 741 This is the one specified by the current buffer. */)
743 () 742 (void)
744 { 743 {
745 return current_buffer->syntax_table; 744 return current_buffer->syntax_table;
746 } 745 }
747 746
748 DEFUN ("standard-syntax-table", Fstandard_syntax_table, 747 DEFUN ("standard-syntax-table", Fstandard_syntax_table,
749 Sstandard_syntax_table, 0, 0, 0, 748 Sstandard_syntax_table, 0, 0, 0,
750 doc: /* Return the standard syntax table. 749 doc: /* Return the standard syntax table.
751 This is the one used for new buffers. */) 750 This is the one used for new buffers. */)
752 () 751 (void)
753 { 752 {
754 return Vstandard_syntax_table; 753 return Vstandard_syntax_table;
755 } 754 }
756 755
757 DEFUN ("copy-syntax-table", Fcopy_syntax_table, Scopy_syntax_table, 0, 1, 0, 756 DEFUN ("copy-syntax-table", Fcopy_syntax_table, Scopy_syntax_table, 0, 1, 0,
758 doc: /* Construct a new syntax table and return it. 757 doc: /* Construct a new syntax table and return it.
759 It is a copy of the TABLE, which defaults to the standard syntax table. */) 758 It is a copy of the TABLE, which defaults to the standard syntax table. */)
760 (table) 759 (Lisp_Object table)
761 Lisp_Object table;
762 { 760 {
763 Lisp_Object copy; 761 Lisp_Object copy;
764 762
765 if (!NILP (table)) 763 if (!NILP (table))
766 check_syntax_table (table); 764 check_syntax_table (table);
782 } 780 }
783 781
784 DEFUN ("set-syntax-table", Fset_syntax_table, Sset_syntax_table, 1, 1, 0, 782 DEFUN ("set-syntax-table", Fset_syntax_table, Sset_syntax_table, 1, 1, 0,
785 doc: /* Select a new syntax table for the current buffer. 783 doc: /* Select a new syntax table for the current buffer.
786 One argument, a syntax table. */) 784 One argument, a syntax table. */)
787 (table) 785 (Lisp_Object table)
788 Lisp_Object table;
789 { 786 {
790 int idx; 787 int idx;
791 check_syntax_table (table); 788 check_syntax_table (table);
792 current_buffer->syntax_table = table; 789 current_buffer->syntax_table = table;
793 /* Indicate that this buffer now has a specified syntax table. */ 790 /* Indicate that this buffer now has a specified syntax table. */
842 doc: /* Return the syntax code of CHARACTER, described by a character. 839 doc: /* Return the syntax code of CHARACTER, described by a character.
843 For example, if CHARACTER is a word constituent, the 840 For example, if CHARACTER is a word constituent, the
844 character `w' (119) is returned. 841 character `w' (119) is returned.
845 The characters that correspond to various syntax codes 842 The characters that correspond to various syntax codes
846 are listed in the documentation of `modify-syntax-entry'. */) 843 are listed in the documentation of `modify-syntax-entry'. */)
847 (character) 844 (Lisp_Object character)
848 Lisp_Object character;
849 { 845 {
850 int char_int; 846 int char_int;
851 CHECK_CHARACTER (character); 847 CHECK_CHARACTER (character);
852 char_int = XINT (character); 848 char_int = XINT (character);
853 SETUP_BUFFER_SYNTAX_TABLE (); 849 SETUP_BUFFER_SYNTAX_TABLE ();
854 return make_number (syntax_code_spec[(int) SYNTAX (char_int)]); 850 return make_number (syntax_code_spec[(int) SYNTAX (char_int)]);
855 } 851 }
856 852
857 DEFUN ("matching-paren", Fmatching_paren, Smatching_paren, 1, 1, 0, 853 DEFUN ("matching-paren", Fmatching_paren, Smatching_paren, 1, 1, 0,
858 doc: /* Return the matching parenthesis of CHARACTER, or nil if none. */) 854 doc: /* Return the matching parenthesis of CHARACTER, or nil if none. */)
859 (character) 855 (Lisp_Object character)
860 Lisp_Object character;
861 { 856 {
862 int char_int, code; 857 int char_int, code;
863 CHECK_NUMBER (character); 858 CHECK_NUMBER (character);
864 char_int = XINT (character); 859 char_int = XINT (character);
865 SETUP_BUFFER_SYNTAX_TABLE (); 860 SETUP_BUFFER_SYNTAX_TABLE ();
873 doc: /* Convert a syntax specification STRING into syntax cell form. 868 doc: /* Convert a syntax specification STRING into syntax cell form.
874 STRING should be a string as it is allowed as argument of 869 STRING should be a string as it is allowed as argument of
875 `modify-syntax-entry'. Value is the equivalent cons cell 870 `modify-syntax-entry'. Value is the equivalent cons cell
876 \(CODE . MATCHING-CHAR) that can be used as value of a `syntax-table' 871 \(CODE . MATCHING-CHAR) that can be used as value of a `syntax-table'
877 text property. */) 872 text property. */)
878 (string) 873 (Lisp_Object string)
879 Lisp_Object string;
880 { 874 {
881 register const unsigned char *p; 875 register const unsigned char *p;
882 register enum syntaxcode code; 876 register enum syntaxcode code;
883 int val; 877 int val;
884 Lisp_Object match; 878 Lisp_Object match;
985 979
986 p means CHAR is a prefix character for `backward-prefix-chars'; 980 p means CHAR is a prefix character for `backward-prefix-chars';
987 such characters are treated as whitespace when they occur 981 such characters are treated as whitespace when they occur
988 between expressions. 982 between expressions.
989 usage: (modify-syntax-entry CHAR NEWENTRY &optional SYNTAX-TABLE) */) 983 usage: (modify-syntax-entry CHAR NEWENTRY &optional SYNTAX-TABLE) */)
990 (c, newentry, syntax_table) 984 (Lisp_Object c, Lisp_Object newentry, Lisp_Object syntax_table)
991 Lisp_Object c, newentry, syntax_table;
992 { 985 {
993 if (CONSP (c)) 986 if (CONSP (c))
994 { 987 {
995 CHECK_CHARACTER_CAR (c); 988 CHECK_CHARACTER_CAR (c);
996 CHECK_CHARACTER_CDR (c); 989 CHECK_CHARACTER_CDR (c);
1019 /* Dump syntax table to buffer in human-readable format */ 1012 /* Dump syntax table to buffer in human-readable format */
1020 1013
1021 DEFUN ("internal-describe-syntax-value", Finternal_describe_syntax_value, 1014 DEFUN ("internal-describe-syntax-value", Finternal_describe_syntax_value,
1022 Sinternal_describe_syntax_value, 1, 1, 0, 1015 Sinternal_describe_syntax_value, 1, 1, 0,
1023 doc: /* Insert a description of the internal syntax description SYNTAX at point. */) 1016 doc: /* Insert a description of the internal syntax description SYNTAX at point. */)
1024 (syntax) 1017 (Lisp_Object syntax)
1025 Lisp_Object syntax;
1026 { 1018 {
1027 register enum syntaxcode code; 1019 register enum syntaxcode code;
1028 char desc, start1, start2, end1, end2, prefix, comstyle, comnested; 1020 char desc, start1, start2, end1, end2, prefix, comstyle, comnested;
1029 char str[2]; 1021 char str[2];
1030 Lisp_Object first, match_lisp, value = syntax; 1022 Lisp_Object first, match_lisp, value = syntax;
1305 doc: /* Move point forward ARG words (backward if ARG is negative). 1297 doc: /* Move point forward ARG words (backward if ARG is negative).
1306 Normally returns t. 1298 Normally returns t.
1307 If an edge of the buffer or a field boundary is reached, point is left there 1299 If an edge of the buffer or a field boundary is reached, point is left there
1308 and the function returns nil. Field boundaries are not noticed if 1300 and the function returns nil. Field boundaries are not noticed if
1309 `inhibit-field-text-motion' is non-nil. */) 1301 `inhibit-field-text-motion' is non-nil. */)
1310 (arg) 1302 (Lisp_Object arg)
1311 Lisp_Object arg;
1312 { 1303 {
1313 Lisp_Object tmp; 1304 Lisp_Object tmp;
1314 int orig_val, val; 1305 int orig_val, val;
1315 1306
1316 if (NILP (arg)) 1307 if (NILP (arg))
1341 Thus, with arg "a-zA-Z", this skips letters stopping before first nonletter. 1332 Thus, with arg "a-zA-Z", this skips letters stopping before first nonletter.
1342 With arg "^a-zA-Z", skips nonletters stopping before first letter. 1333 With arg "^a-zA-Z", skips nonletters stopping before first letter.
1343 Char classes, e.g. `[:alpha:]', are supported. 1334 Char classes, e.g. `[:alpha:]', are supported.
1344 1335
1345 Returns the distance traveled, either zero or positive. */) 1336 Returns the distance traveled, either zero or positive. */)
1346 (string, lim) 1337 (Lisp_Object string, Lisp_Object lim)
1347 Lisp_Object string, lim;
1348 { 1338 {
1349 return skip_chars (1, string, lim, 1); 1339 return skip_chars (1, string, lim, 1);
1350 } 1340 }
1351 1341
1352 DEFUN ("skip-chars-backward", Fskip_chars_backward, Sskip_chars_backward, 1, 2, 0, 1342 DEFUN ("skip-chars-backward", Fskip_chars_backward, Sskip_chars_backward, 1, 2, 0,
1353 doc: /* Move point backward, stopping after a char not in STRING, or at pos LIM. 1343 doc: /* Move point backward, stopping after a char not in STRING, or at pos LIM.
1354 See `skip-chars-forward' for details. 1344 See `skip-chars-forward' for details.
1355 Returns the distance traveled, either zero or negative. */) 1345 Returns the distance traveled, either zero or negative. */)
1356 (string, lim) 1346 (Lisp_Object string, Lisp_Object lim)
1357 Lisp_Object string, lim;
1358 { 1347 {
1359 return skip_chars (0, string, lim, 1); 1348 return skip_chars (0, string, lim, 1);
1360 } 1349 }
1361 1350
1362 DEFUN ("skip-syntax-forward", Fskip_syntax_forward, Sskip_syntax_forward, 1, 2, 0, 1351 DEFUN ("skip-syntax-forward", Fskip_syntax_forward, Sskip_syntax_forward, 1, 2, 0,
1363 doc: /* Move point forward across chars in specified syntax classes. 1352 doc: /* Move point forward across chars in specified syntax classes.
1364 SYNTAX is a string of syntax code characters. 1353 SYNTAX is a string of syntax code characters.
1365 Stop before a char whose syntax is not in SYNTAX, or at position LIM. 1354 Stop before a char whose syntax is not in SYNTAX, or at position LIM.
1366 If SYNTAX starts with ^, skip characters whose syntax is NOT in SYNTAX. 1355 If SYNTAX starts with ^, skip characters whose syntax is NOT in SYNTAX.
1367 This function returns the distance traveled, either zero or positive. */) 1356 This function returns the distance traveled, either zero or positive. */)
1368 (syntax, lim) 1357 (Lisp_Object syntax, Lisp_Object lim)
1369 Lisp_Object syntax, lim;
1370 { 1358 {
1371 return skip_syntaxes (1, syntax, lim); 1359 return skip_syntaxes (1, syntax, lim);
1372 } 1360 }
1373 1361
1374 DEFUN ("skip-syntax-backward", Fskip_syntax_backward, Sskip_syntax_backward, 1, 2, 0, 1362 DEFUN ("skip-syntax-backward", Fskip_syntax_backward, Sskip_syntax_backward, 1, 2, 0,
1375 doc: /* Move point backward across chars in specified syntax classes. 1363 doc: /* Move point backward across chars in specified syntax classes.
1376 SYNTAX is a string of syntax code characters. 1364 SYNTAX is a string of syntax code characters.
1377 Stop on reaching a char whose syntax is not in SYNTAX, or at position LIM. 1365 Stop on reaching a char whose syntax is not in SYNTAX, or at position LIM.
1378 If SYNTAX starts with ^, skip characters whose syntax is NOT in SYNTAX. 1366 If SYNTAX starts with ^, skip characters whose syntax is NOT in SYNTAX.
1379 This function returns the distance traveled, either zero or negative. */) 1367 This function returns the distance traveled, either zero or negative. */)
1380 (syntax, lim) 1368 (Lisp_Object syntax, Lisp_Object lim)
1381 Lisp_Object syntax, lim;
1382 { 1369 {
1383 return skip_syntaxes (0, syntax, lim); 1370 return skip_syntaxes (0, syntax, lim);
1384 } 1371 }
1385 1372
1386 static Lisp_Object 1373 static Lisp_Object
2191 Move forward across up to COUNT comments. If COUNT is negative, move backward. 2178 Move forward across up to COUNT comments. If COUNT is negative, move backward.
2192 Stop scanning if we find something other than a comment or whitespace. 2179 Stop scanning if we find something other than a comment or whitespace.
2193 Set point to where scanning stops. 2180 Set point to where scanning stops.
2194 If COUNT comments are found as expected, with nothing except whitespace 2181 If COUNT comments are found as expected, with nothing except whitespace
2195 between them, return t; otherwise return nil. */) 2182 between them, return t; otherwise return nil. */)
2196 (count) 2183 (Lisp_Object count)
2197 Lisp_Object count;
2198 { 2184 {
2199 register EMACS_INT from; 2185 register EMACS_INT from;
2200 EMACS_INT from_byte; 2186 EMACS_INT from_byte;
2201 register EMACS_INT stop; 2187 register EMACS_INT stop;
2202 register int c, c1; 2188 register int c, c1;
2795 Comments are ignored if `parse-sexp-ignore-comments' is non-nil. 2781 Comments are ignored if `parse-sexp-ignore-comments' is non-nil.
2796 2782
2797 If the beginning or end of (the accessible part of) the buffer is reached 2783 If the beginning or end of (the accessible part of) the buffer is reached
2798 and the depth is wrong, an error is signaled. 2784 and the depth is wrong, an error is signaled.
2799 If the depth is right but the count is not used up, nil is returned. */) 2785 If the depth is right but the count is not used up, nil is returned. */)
2800 (from, count, depth) 2786 (Lisp_Object from, Lisp_Object count, Lisp_Object depth)
2801 Lisp_Object from, count, depth;
2802 { 2787 {
2803 CHECK_NUMBER (from); 2788 CHECK_NUMBER (from);
2804 CHECK_NUMBER (count); 2789 CHECK_NUMBER (count);
2805 CHECK_NUMBER (depth); 2790 CHECK_NUMBER (depth);
2806 2791
2816 2801
2817 If the beginning or end of (the accessible part of) the buffer is reached 2802 If the beginning or end of (the accessible part of) the buffer is reached
2818 in the middle of a parenthetical grouping, an error is signaled. 2803 in the middle of a parenthetical grouping, an error is signaled.
2819 If the beginning or end is reached between groupings 2804 If the beginning or end is reached between groupings
2820 but before count is used up, nil is returned. */) 2805 but before count is used up, nil is returned. */)
2821 (from, count) 2806 (Lisp_Object from, Lisp_Object count)
2822 Lisp_Object from, count;
2823 { 2807 {
2824 CHECK_NUMBER (from); 2808 CHECK_NUMBER (from);
2825 CHECK_NUMBER (count); 2809 CHECK_NUMBER (count);
2826 2810
2827 return scan_lists (XINT (from), XINT (count), 0, 1); 2811 return scan_lists (XINT (from), XINT (count), 0, 1);
2829 2813
2830 DEFUN ("backward-prefix-chars", Fbackward_prefix_chars, Sbackward_prefix_chars, 2814 DEFUN ("backward-prefix-chars", Fbackward_prefix_chars, Sbackward_prefix_chars,
2831 0, 0, 0, 2815 0, 0, 0,
2832 doc: /* Move point backward over any number of chars with prefix syntax. 2816 doc: /* Move point backward over any number of chars with prefix syntax.
2833 This includes chars with "quote" or "prefix" syntax (' or p). */) 2817 This includes chars with "quote" or "prefix" syntax (' or p). */)
2834 () 2818 (void)
2835 { 2819 {
2836 int beg = BEGV; 2820 int beg = BEGV;
2837 int opoint = PT; 2821 int opoint = PT;
2838 int opoint_byte = PT_BYTE; 2822 int opoint_byte = PT_BYTE;
2839 int pos = PT; 2823 int pos = PT;
3253 It is used to initialize the state of the parse. Elements number 1, 2, 6 3237 It is used to initialize the state of the parse. Elements number 1, 2, 6
3254 and 8 are ignored. 3238 and 8 are ignored.
3255 Sixth arg COMMENTSTOP non-nil means stop at the start of a comment. 3239 Sixth arg COMMENTSTOP non-nil means stop at the start of a comment.
3256 If it is symbol `syntax-table', stop after the start of a comment or a 3240 If it is symbol `syntax-table', stop after the start of a comment or a
3257 string, or after end of a comment or a string. */) 3241 string, or after end of a comment or a string. */)
3258 (from, to, targetdepth, stopbefore, oldstate, commentstop) 3242 (Lisp_Object from, Lisp_Object to, Lisp_Object targetdepth, Lisp_Object stopbefore, Lisp_Object oldstate, Lisp_Object commentstop)
3259 Lisp_Object from, to, targetdepth, stopbefore, oldstate, commentstop;
3260 { 3243 {
3261 struct lisp_parse_state state; 3244 struct lisp_parse_state state;
3262 int target; 3245 int target;
3263 3246
3264 if (!NILP (targetdepth)) 3247 if (!NILP (targetdepth))