mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2025-02-06 20:49:33 +00:00
Add a new function syntax-class-to-char
* doc/lispref/syntax.texi (Syntax Table Internals): Document it. * src/syntax.c (Fsyntax_class_to_char): New function (bug#37452).
This commit is contained in:
parent
53e5caa1bd
commit
81fd5603ce
@ -1047,6 +1047,11 @@ Given a syntax descriptor @var{desc} (a string), this function returns
|
||||
the corresponding raw syntax descriptor.
|
||||
@end defun
|
||||
|
||||
@defun syntax-class-to-char syntax
|
||||
Given a raw syntax descriptor @var{syntax} (an integer), this function
|
||||
returns the corresponding syntax descriptor (a character).
|
||||
@end defun
|
||||
|
||||
@defun syntax-after pos
|
||||
This function returns the raw syntax descriptor for the character in
|
||||
the buffer after position @var{pos}, taking account of syntax
|
||||
|
5
etc/NEWS
5
etc/NEWS
@ -2843,6 +2843,11 @@ customize them.
|
||||
|
||||
* Lisp Changes in Emacs 28.1
|
||||
|
||||
+++
|
||||
** New function 'syntax-class-to-char'.
|
||||
This does the almost the opposite of 'string-to-syntax' -- it returns
|
||||
the syntax descriptor (a character) given a raw syntax descriptor.
|
||||
|
||||
+++
|
||||
** New function 'buffer-local-boundp'.
|
||||
This predicate says whether a symbol is bound in a specific buffer.
|
||||
|
18
src/syntax.c
18
src/syntax.c
@ -1109,6 +1109,23 @@ this is probably the wrong function to use, because it can't take
|
||||
return make_fixnum (syntax_code_spec[SYNTAX (char_int)]);
|
||||
}
|
||||
|
||||
DEFUN ("syntax-class-to-char", Fsyntax_class_to_char,
|
||||
Ssyntax_class_to_char, 1, 1, 0,
|
||||
doc: /* Return the syntax char of CLASS, described by an integer.
|
||||
For example, if SYNTAX is word constituent (the integer 2), the
|
||||
character `w' (119) is returned. */)
|
||||
(Lisp_Object syntax)
|
||||
{
|
||||
int syn;
|
||||
CHECK_FIXNUM (syntax);
|
||||
syn = XFIXNUM (syntax);
|
||||
|
||||
if (syn < 0 || syn >= sizeof syntax_code_spec)
|
||||
args_out_of_range (make_fixnum (sizeof syntax_code_spec - 1),
|
||||
syntax);
|
||||
return make_fixnum (syntax_code_spec[syn]);
|
||||
}
|
||||
|
||||
DEFUN ("matching-paren", Fmatching_paren, Smatching_paren, 1, 1, 0,
|
||||
doc: /* Return the matching parenthesis of CHARACTER, or nil if none. */)
|
||||
(Lisp_Object character)
|
||||
@ -3782,6 +3799,7 @@ In both cases, LIMIT bounds the search. */);
|
||||
defsubr (&Scopy_syntax_table);
|
||||
defsubr (&Sset_syntax_table);
|
||||
defsubr (&Schar_syntax);
|
||||
defsubr (&Ssyntax_class_to_char);
|
||||
defsubr (&Smatching_paren);
|
||||
defsubr (&Sstring_to_syntax);
|
||||
defsubr (&Smodify_syntax_entry);
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
(require 'ert)
|
||||
(require 'ert-x)
|
||||
(require 'cl-lib)
|
||||
|
||||
(ert-deftest parse-partial-sexp-continue-over-comment-marker ()
|
||||
"Continue a parse that stopped in the middle of a comment marker."
|
||||
@ -56,6 +57,16 @@
|
||||
(should (equal (parse-partial-sexp aftC pointX nil nil pps-aftC)
|
||||
ppsX)))))
|
||||
|
||||
(ert-deftest syntax-class-character-test ()
|
||||
(cl-loop for char across " .w_()'\"$\\/<>@!|"
|
||||
for i from 0
|
||||
do (should (= char (syntax-class-to-char i)))
|
||||
when (string-to-syntax (string char))
|
||||
do (should (= char (syntax-class-to-char
|
||||
(car (string-to-syntax (string char)))))))
|
||||
(should-error (syntax-class-to-char -1))
|
||||
(should-error (syntax-class-to-char 200)))
|
||||
|
||||
(ert-deftest parse-partial-sexp-paren-comments ()
|
||||
"Test syntax parsing with paren comment markers.
|
||||
Specifically, where the first character of the comment marker is
|
||||
|
Loading…
x
Reference in New Issue
Block a user