aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Kangas2023-02-12 03:27:46 +0100
committerStefan Kangas2023-02-12 03:27:46 +0100
commit08bd066149faee95fe6660d5002306a1dbc4b91b (patch)
tree6fc5a9ecbcee5b59aa377fa90f7f729a0a8c6e31 /src
parent14c97db7366435b1edbf2854f485058a9d7c6071 (diff)
parent4da398d8b57aae740f054b4d04cba72735a4044c (diff)
downloademacs-08bd066149faee95fe6660d5002306a1dbc4b91b.tar.gz
emacs-08bd066149faee95fe6660d5002306a1dbc4b91b.zip
Merge from origin/emacs-29
4da398d8b57 ; Fix typos 074008ee2d2 ; Fix doc strings in lisp/image/ directory 2d1e43436da ; Improve documentation of hash functions. 900f7e07275 ; Remove extraneous local variables from image-dired-*.el... 4f053afe8e7 bug-reference: prevent match-data clobbering (bug#61395) 10af9fbcad1 ; * admin/notes/tree-sitter/starter-guide: Typos. 9ac242ce93d ; Fix recent changes in treesit docs f5789aefc2e Rename LIMIT to DEPTH in tree-sitter functions (bug#61231) b39821fdcef ; Fix incorrect function name in treesit manual 51901736965 Add 'live' property to treesit-node-check (bug#61235) 56960a6558b Update to Transient v0.3.7-205-gb8ad0da 68a6b364d1c Fix 'rmail-summary-output' 67c6ec25590 lisp-mode: add docstring recognition for more common lisp... 417a8ed8b05 ; Improve discoverability of empty file names handling e47cf6ca15a Update to Transient v0.3.7-204-gecff8c2 b04cce02ff4 Fix Scala entry in Eglot's DB of LSP servers # Conflicts: # lisp/transient.el
Diffstat (limited to 'src')
-rw-r--r--src/fns.c17
-rw-r--r--src/treesit.c46
2 files changed, 40 insertions, 23 deletions
diff --git a/src/fns.c b/src/fns.c
index 59d5b5c0850..0af9b725c7a 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -5809,8 +5809,9 @@ secure_hash (Lisp_Object algorithm, Lisp_Object object, Lisp_Object start,
5809DEFUN ("md5", Fmd5, Smd5, 1, 5, 0, 5809DEFUN ("md5", Fmd5, Smd5, 1, 5, 0,
5810 doc: /* Return MD5 message digest of OBJECT, a buffer or string. 5810 doc: /* Return MD5 message digest of OBJECT, a buffer or string.
5811 5811
5812A message digest is a cryptographic checksum of a document, and the 5812A message digest is the string representation of the cryptographic checksum
5813algorithm to calculate it is defined in RFC 1321. 5813of a document, and the algorithm to calculate it is defined in RFC 1321.
5814The MD5 digest is 32-character long.
5814 5815
5815The two optional arguments START and END are character positions 5816The two optional arguments START and END are character positions
5816specifying for which part of OBJECT the message digest should be 5817specifying for which part of OBJECT the message digest should be
@@ -5844,12 +5845,12 @@ anything security-related. See `secure-hash' for alternatives. */)
5844DEFUN ("secure-hash", Fsecure_hash, Ssecure_hash, 2, 5, 0, 5845DEFUN ("secure-hash", Fsecure_hash, Ssecure_hash, 2, 5, 0,
5845 doc: /* Return the secure hash of OBJECT, a buffer or string. 5846 doc: /* Return the secure hash of OBJECT, a buffer or string.
5846ALGORITHM is a symbol specifying the hash to use: 5847ALGORITHM is a symbol specifying the hash to use:
5847- md5 corresponds to MD5 5848- md5 corresponds to MD5, produces a 32-character signature
5848- sha1 corresponds to SHA-1 5849- sha1 corresponds to SHA-1, produces a 40-character signature
5849- sha224 corresponds to SHA-2 (SHA-224) 5850- sha224 corresponds to SHA-2 (SHA-224), produces a 56-character signature
5850- sha256 corresponds to SHA-2 (SHA-256) 5851- sha256 corresponds to SHA-2 (SHA-256), produces a 64-character signature
5851- sha384 corresponds to SHA-2 (SHA-384) 5852- sha384 corresponds to SHA-2 (SHA-384), produces a 96-character signature
5852- sha512 corresponds to SHA-2 (SHA-512) 5853- sha512 corresponds to SHA-2 (SHA-512), produces a 128-character signature
5853 5854
5854The two optional arguments START and END are positions specifying for 5855The two optional arguments START and END are positions specifying for
5855which part of OBJECT to compute the hash. If nil or omitted, uses the 5856which part of OBJECT to compute the hash. If nil or omitted, uses the
diff --git a/src/treesit.c b/src/treesit.c
index cfa3721b5e7..cab2f0d5354 100644
--- a/src/treesit.c
+++ b/src/treesit.c
@@ -1475,6 +1475,15 @@ This symbol is the one used to create the parser. */)
1475 return XTS_PARSER (parser)->language_symbol; 1475 return XTS_PARSER (parser)->language_symbol;
1476} 1476}
1477 1477
1478/* Return true if PARSER is not deleted and its buffer is live. */
1479static bool
1480treesit_parser_live_p (Lisp_Object parser)
1481{
1482 CHECK_TS_PARSER (parser);
1483 return ((!XTS_PARSER (parser)->deleted) &&
1484 (!NILP (Fbuffer_live_p (XTS_PARSER (parser)->buffer))));
1485}
1486
1478/*** Parser API */ 1487/*** Parser API */
1479 1488
1480DEFUN ("treesit-parser-root-node", 1489DEFUN ("treesit-parser-root-node",
@@ -1908,7 +1917,8 @@ DEFUN ("treesit-node-check",
1908 Ftreesit_node_check, Streesit_node_check, 2, 2, 0, 1917 Ftreesit_node_check, Streesit_node_check, 2, 2, 0,
1909 doc: /* Return non-nil if NODE has PROPERTY, nil otherwise. 1918 doc: /* Return non-nil if NODE has PROPERTY, nil otherwise.
1910 1919
1911PROPERTY could be `named', `missing', `extra', `outdated', or `has-error'. 1920PROPERTY could be `named', `missing', `extra', `outdated',
1921`has-error', or `live'.
1912 1922
1913Named nodes correspond to named rules in the language definition, 1923Named nodes correspond to named rules in the language definition,
1914whereas "anonymous" nodes correspond to string literals in the 1924whereas "anonymous" nodes correspond to string literals in the
@@ -1924,7 +1934,10 @@ A node is "outdated" if the parser has reparsed at least once after
1924the node was created. 1934the node was created.
1925 1935
1926A node "has error" if itself is a syntax error or contains any syntax 1936A node "has error" if itself is a syntax error or contains any syntax
1927errors. */) 1937errors.
1938
1939A node is "live" if its parser is not deleted and its buffer is
1940live. */)
1928 (Lisp_Object node, Lisp_Object property) 1941 (Lisp_Object node, Lisp_Object property)
1929{ 1942{
1930 if (NILP (node)) return Qnil; 1943 if (NILP (node)) return Qnil;
@@ -1947,9 +1960,11 @@ errors. */)
1947 result = ts_node_is_extra (treesit_node); 1960 result = ts_node_is_extra (treesit_node);
1948 else if (EQ (property, Qhas_error)) 1961 else if (EQ (property, Qhas_error))
1949 result = ts_node_has_error (treesit_node); 1962 result = ts_node_has_error (treesit_node);
1963 else if (EQ (property, Qlive))
1964 result = treesit_parser_live_p (XTS_NODE (node)->parser);
1950 else 1965 else
1951 signal_error ("Expecting `named', `missing', `extra', " 1966 signal_error ("Expecting `named', `missing', `extra', "
1952 "`outdated', or `has-error', but got", 1967 "`outdated', `has-error', or `live', but got",
1953 property); 1968 property);
1954 return result ? Qt : Qnil; 1969 return result ? Qt : Qnil;
1955} 1970}
@@ -3135,13 +3150,13 @@ the way. PREDICATE is a regexp string that matches against each
3135node's type, or a function that takes a node and returns nil/non-nil. 3150node's type, or a function that takes a node and returns nil/non-nil.
3136 3151
3137By default, only traverse named nodes, but if ALL is non-nil, traverse 3152By default, only traverse named nodes, but if ALL is non-nil, traverse
3138all nodes. If BACKWARD is non-nil, traverse backwards. If LIMIT is 3153all nodes. If BACKWARD is non-nil, traverse backwards. If DEPTH is
3139non-nil, only traverse nodes up to that number of levels down in the 3154non-nil, only traverse nodes up to that number of levels down in the
3140tree. If LIMIT is nil, default to 1000. 3155tree. If DEPTH is nil, default to 1000.
3141 3156
3142Return the first matched node, or nil if none matches. */) 3157Return the first matched node, or nil if none matches. */)
3143 (Lisp_Object node, Lisp_Object predicate, Lisp_Object backward, 3158 (Lisp_Object node, Lisp_Object predicate, Lisp_Object backward,
3144 Lisp_Object all, Lisp_Object limit) 3159 Lisp_Object all, Lisp_Object depth)
3145{ 3160{
3146 CHECK_TS_NODE (node); 3161 CHECK_TS_NODE (node);
3147 CHECK_TYPE (STRINGP (predicate) || FUNCTIONP (predicate), 3162 CHECK_TYPE (STRINGP (predicate) || FUNCTIONP (predicate),
@@ -3152,10 +3167,10 @@ Return the first matched node, or nil if none matches. */)
3152 /* We use a default limit of 1000. See bug#59426 for the 3167 /* We use a default limit of 1000. See bug#59426 for the
3153 discussion. */ 3168 discussion. */
3154 ptrdiff_t the_limit = treesit_recursion_limit; 3169 ptrdiff_t the_limit = treesit_recursion_limit;
3155 if (!NILP (limit)) 3170 if (!NILP (depth))
3156 { 3171 {
3157 CHECK_FIXNUM (limit); 3172 CHECK_FIXNUM (depth);
3158 the_limit = XFIXNUM (limit); 3173 the_limit = XFIXNUM (depth);
3159 } 3174 }
3160 3175
3161 treesit_initialize (); 3176 treesit_initialize ();
@@ -3307,8 +3322,8 @@ If PROCESS-FN is non-nil, it should be a function of one argument. In
3307that case, instead of returning the matched nodes, pass each node to 3322that case, instead of returning the matched nodes, pass each node to
3308PROCESS-FN, and use its return value instead. 3323PROCESS-FN, and use its return value instead.
3309 3324
3310If non-nil, LIMIT is the number of levels to go down the tree from 3325If non-nil, DEPTH is the number of levels to go down the tree from
3311ROOT. If LIMIT is nil or omitted, it defaults to 1000. 3326ROOT. If DEPTH is nil or omitted, it defaults to 1000.
3312 3327
3313Each node in the returned tree looks like (NODE . (CHILD ...)). The 3328Each node in the returned tree looks like (NODE . (CHILD ...)). The
3314root of this tree might be nil, if ROOT doesn't match PREDICATE. 3329root of this tree might be nil, if ROOT doesn't match PREDICATE.
@@ -3319,7 +3334,7 @@ PREDICATE can also be a function that takes a node and returns
3319nil/non-nil, but it is slower and more memory consuming than using 3334nil/non-nil, but it is slower and more memory consuming than using
3320a regexp. */) 3335a regexp. */)
3321 (Lisp_Object root, Lisp_Object predicate, Lisp_Object process_fn, 3336 (Lisp_Object root, Lisp_Object predicate, Lisp_Object process_fn,
3322 Lisp_Object limit) 3337 Lisp_Object depth)
3323{ 3338{
3324 CHECK_TS_NODE (root); 3339 CHECK_TS_NODE (root);
3325 CHECK_TYPE (STRINGP (predicate) || FUNCTIONP (predicate), 3340 CHECK_TYPE (STRINGP (predicate) || FUNCTIONP (predicate),
@@ -3331,10 +3346,10 @@ a regexp. */)
3331 /* We use a default limit of 1000. See bug#59426 for the 3346 /* We use a default limit of 1000. See bug#59426 for the
3332 discussion. */ 3347 discussion. */
3333 ptrdiff_t the_limit = treesit_recursion_limit; 3348 ptrdiff_t the_limit = treesit_recursion_limit;
3334 if (!NILP (limit)) 3349 if (!NILP (depth))
3335 { 3350 {
3336 CHECK_FIXNUM (limit); 3351 CHECK_FIXNUM (depth);
3337 the_limit = XFIXNUM (limit); 3352 the_limit = XFIXNUM (depth);
3338 } 3353 }
3339 3354
3340 treesit_initialize (); 3355 treesit_initialize ();
@@ -3448,6 +3463,7 @@ syms_of_treesit (void)
3448 DEFSYM (Qextra, "extra"); 3463 DEFSYM (Qextra, "extra");
3449 DEFSYM (Qoutdated, "outdated"); 3464 DEFSYM (Qoutdated, "outdated");
3450 DEFSYM (Qhas_error, "has-error"); 3465 DEFSYM (Qhas_error, "has-error");
3466 DEFSYM (Qlive, "live");
3451 3467
3452 DEFSYM (QCanchor, ":anchor"); 3468 DEFSYM (QCanchor, ":anchor");
3453 DEFSYM (QCequal, ":equal"); 3469 DEFSYM (QCequal, ":equal");