aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Kangas2022-12-28 21:40:59 +0100
committerStefan Kangas2022-12-28 21:40:59 +0100
commitdce6791e9934d029ffae45793a5d05096346be0c (patch)
tree387d999b6d6af1d72dfc3416e49d445329139ed9 /src
parent7e98b8a0fa67f51784024fac3199d774dfa77192 (diff)
parentdb96b1282f90ee40560f81e8b715fe785badbb6e (diff)
downloademacs-dce6791e9934d029ffae45793a5d05096346be0c.tar.gz
emacs-dce6791e9934d029ffae45793a5d05096346be0c.zip
Merge from origin/emacs-29
db96b1282f9 * lisp/help.el: Use 'C-h C-q' to toggle 'help-quick' wind... 489865c21e4 ; Improve markup of long key sequences d42c2668cf3 ; * etc/NEWS: Fix wording of a recently edited entry. 7a0eaee1980 * lisp/isearch.el: Small fixes. b69bffeec05 * lisp/vc/diff-mode.el (diff-minor-mode-prefix): Replace ... 9263847ab76 ; * etc/NEWS: Move the paragraph with 'C-u RET' closer to... 62fb2dc37da * doc/emacs/display.texi (Text Scale): Improve section ab... 70480d3b6b7 * lisp/repeat.el (repeat-echo-function): Suggest 'add-fun... fd48201ffe7 * lisp/tab-line.el (tab-line-cache-key-default): More cac... b1646602602 * etc/package-keyring.gpg: Update with new key c0be51389eb ; Yet another declare-function to avoid treesit-related w... 8676bec51de ; * lisp/treesit.el (treesit--simple-imenu-1): Doc fix; w... 2ddc480f441 Warn of absent networks module in ERC 19d00fab9aa Avoid "already compiled" warning in erc-compat 2d8f7b66bcc ; Fix one more treesit byte-compilation warning. 2d0a9214863 ; Avoid treesit-related byte-compiler warnings 8503b370be1 (python--treesit-settings): Remove duplicate matcher b464e6c490b Make last change of w32 GUI dialogs conditional and rever... eedc9d79aed Fix tree-sitter typos 248c13dcfe1 Update tree-sitter major modes to use the new Imenu facility b39dc7ab27a Add tree-sitter helper functions for Imenu ba1ddea9dab Fix treesit--things-around (bug#60355) 7512b9025a1 ; * lisp/treesit.el (treesit-traverse-parent): Remove alias. 5326b041982 Improve treesit-node-top-level and treesit-parent-until 637f5b164f2 ; Add "src" to the heuristic sub-directory heuristic 8ab6df0c9fd ; * lisp/epa-ks.el (epa-ks-do-key-to-fetch): Fix 'when' u... 2b55a48d3e3 * src/w32menu.c (simple_dialog_show): Use MB_YESNOCANCEL ... 8b8b7915679 ; Improve documentation of TAB/SPC indentation 624e3822110 ; Improve doc strings of some new faces 41f12e1019b ; * lisp/elide-head.el (elide-head): Doc fix to silence c... e3b4cd0ac1d ; * lisp/htmlfontify.el (hfy-text-p): Fix whitespace. 1b4dc4691c1 Fix htmlfontify.el command injection vulnerability. 1fe4b98b4d5 Improve support for Scheme R6RS and R7RS libraries (bug#5... 2347f37f677 ; * test/src/treesit-tests.el: remove dead store (bytecom... a6d961ae2fd Add a new tree-sitter query predicate 'pred' 835a80dcc48 ; Fix tree-sitter defun tests a14821d6151 Improve gnutls-min-prime-bits docstring b14bbd108e4 Improve handling of tab-bar height. 669160d47b2 ; * nt/INSTALL.W64: More fixes and updates. 26b2ec7cb8c Simplify last change (bug#60311) 082fc6e3088 Fix 'json-available-p' on MS-Windows 6c86faec29e loaddefs-gen: Group results by absolute file name d90d7d15f2f ; Fix vindexes in parsing.texi eb268728376 Fix imenu for c-ts-mode (bug#60296) 8f68b6497ee Clean up python-ts-mode font-lock features 28f26b11a1e Add comment indent and filling to other tree-sitter major... c6b02826450 ; Remove unused function in c-ts-mode 6e52a9fcadc ; * doc/lispref/modes.texi (Parser-based Font Lock): Mino... 2bcd1e9a99d ; * doc/lispref/parsing.texi (Retrieving Nodes): Add notice. 7c7950fe006 Add maintainer stub for tree-sitter files cf327766226 ; * doc/lispref/parsing.texi (Using Parser): Remove delet... # Conflicts: # etc/NEWS # lisp/progmodes/c-ts-mode.el # lisp/progmodes/typescript-ts-mode.el # lisp/treesit.el
Diffstat (limited to 'src')
-rw-r--r--src/indent.c2
-rw-r--r--src/json.c79
-rw-r--r--src/treesit.c59
-rw-r--r--src/w32menu.c13
-rw-r--r--src/w32term.c11
-rw-r--r--src/xdisp.c8
6 files changed, 113 insertions, 59 deletions
diff --git a/src/indent.c b/src/indent.c
index 4671ccccf90..66edaff67de 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -887,6 +887,8 @@ DEFUN ("indent-to", Findent_to, Sindent_to, 1, 2, "NIndent to column: ",
887Optional second argument MINIMUM says always do at least MINIMUM spaces 887Optional second argument MINIMUM says always do at least MINIMUM spaces
888even if that goes past COLUMN; by default, MINIMUM is zero. 888even if that goes past COLUMN; by default, MINIMUM is zero.
889 889
890Whether this uses tabs or spaces depends on `indent-tabs-mode'.
891
890The return value is the column where the insertion ends. */) 892The return value is the column where the insertion ends. */)
891 (Lisp_Object column, Lisp_Object minimum) 893 (Lisp_Object column, Lisp_Object minimum)
892{ 894{
diff --git a/src/json.c b/src/json.c
index cdcc11358e6..621c7d7c15f 100644
--- a/src/json.c
+++ b/src/json.c
@@ -555,6 +555,40 @@ json_parse_args (ptrdiff_t nargs,
555 } 555 }
556} 556}
557 557
558static bool
559json_available_p (void)
560{
561#ifdef WINDOWSNT
562 if (!json_initialized)
563 {
564 Lisp_Object status;
565 json_initialized = init_json_functions ();
566 status = json_initialized ? Qt : Qnil;
567 Vlibrary_cache = Fcons (Fcons (Qjson, status), Vlibrary_cache);
568 }
569 return json_initialized;
570#else /* !WINDOWSNT */
571 return true;
572#endif
573}
574
575#ifdef WINDOWSNT
576static void
577ensure_json_available (void)
578{
579 if (!json_available_p ())
580 Fsignal (Qjson_unavailable,
581 list1 (build_unibyte_string ("jansson library not found")));
582}
583#endif
584
585DEFUN ("json--available-p", Fjson__available_p, Sjson__available_p, 0, 0, NULL,
586 doc: /* Return non-nil if libjansson is available (internal use only). */)
587 (void)
588{
589 return json_available_p () ? Qt : Qnil;
590}
591
558DEFUN ("json-serialize", Fjson_serialize, Sjson_serialize, 1, MANY, 592DEFUN ("json-serialize", Fjson_serialize, Sjson_serialize, 1, MANY,
559 NULL, 593 NULL,
560 doc: /* Return the JSON representation of OBJECT as a string. 594 doc: /* Return the JSON representation of OBJECT as a string.
@@ -587,16 +621,7 @@ usage: (json-serialize OBJECT &rest ARGS) */)
587 specpdl_ref count = SPECPDL_INDEX (); 621 specpdl_ref count = SPECPDL_INDEX ();
588 622
589#ifdef WINDOWSNT 623#ifdef WINDOWSNT
590 if (!json_initialized) 624 ensure_json_available ();
591 {
592 Lisp_Object status;
593 json_initialized = init_json_functions ();
594 status = json_initialized ? Qt : Qnil;
595 Vlibrary_cache = Fcons (Fcons (Qjson, status), Vlibrary_cache);
596 }
597 if (!json_initialized)
598 Fsignal (Qjson_unavailable,
599 list1 (build_unibyte_string ("jansson library not found")));
600#endif 625#endif
601 626
602 struct json_configuration conf = 627 struct json_configuration conf =
@@ -696,16 +721,7 @@ usage: (json-insert OBJECT &rest ARGS) */)
696 specpdl_ref count = SPECPDL_INDEX (); 721 specpdl_ref count = SPECPDL_INDEX ();
697 722
698#ifdef WINDOWSNT 723#ifdef WINDOWSNT
699 if (!json_initialized) 724 ensure_json_available ();
700 {
701 Lisp_Object status;
702 json_initialized = init_json_functions ();
703 status = json_initialized ? Qt : Qnil;
704 Vlibrary_cache = Fcons (Fcons (Qjson, status), Vlibrary_cache);
705 }
706 if (!json_initialized)
707 Fsignal (Qjson_unavailable,
708 list1 (build_unibyte_string ("jansson library not found")));
709#endif 725#endif
710 726
711 struct json_configuration conf = 727 struct json_configuration conf =
@@ -953,16 +969,7 @@ usage: (json-parse-string STRING &rest ARGS) */)
953 specpdl_ref count = SPECPDL_INDEX (); 969 specpdl_ref count = SPECPDL_INDEX ();
954 970
955#ifdef WINDOWSNT 971#ifdef WINDOWSNT
956 if (!json_initialized) 972 ensure_json_available ();
957 {
958 Lisp_Object status;
959 json_initialized = init_json_functions ();
960 status = json_initialized ? Qt : Qnil;
961 Vlibrary_cache = Fcons (Fcons (Qjson, status), Vlibrary_cache);
962 }
963 if (!json_initialized)
964 Fsignal (Qjson_unavailable,
965 list1 (build_unibyte_string ("jansson library not found")));
966#endif 973#endif
967 974
968 Lisp_Object string = args[0]; 975 Lisp_Object string = args[0];
@@ -1050,16 +1057,7 @@ usage: (json-parse-buffer &rest args) */)
1050 specpdl_ref count = SPECPDL_INDEX (); 1057 specpdl_ref count = SPECPDL_INDEX ();
1051 1058
1052#ifdef WINDOWSNT 1059#ifdef WINDOWSNT
1053 if (!json_initialized) 1060 ensure_json_available ();
1054 {
1055 Lisp_Object status;
1056 json_initialized = init_json_functions ();
1057 status = json_initialized ? Qt : Qnil;
1058 Vlibrary_cache = Fcons (Fcons (Qjson, status), Vlibrary_cache);
1059 }
1060 if (!json_initialized)
1061 Fsignal (Qjson_unavailable,
1062 list1 (build_unibyte_string ("jansson library not found")));
1063#endif 1061#endif
1064 1062
1065 struct json_configuration conf = 1063 struct json_configuration conf =
@@ -1137,6 +1135,7 @@ syms_of_json (void)
1137 DEFSYM (Qplist, "plist"); 1135 DEFSYM (Qplist, "plist");
1138 DEFSYM (Qarray, "array"); 1136 DEFSYM (Qarray, "array");
1139 1137
1138 defsubr (&Sjson__available_p);
1140 defsubr (&Sjson_serialize); 1139 defsubr (&Sjson_serialize);
1141 defsubr (&Sjson_insert); 1140 defsubr (&Sjson_insert);
1142 defsubr (&Sjson_parse_string); 1141 defsubr (&Sjson_parse_string);
diff --git a/src/treesit.c b/src/treesit.c
index ce8a2804439..813d4222f98 100644
--- a/src/treesit.c
+++ b/src/treesit.c
@@ -2,6 +2,8 @@
2 2
3Copyright (C) 2021-2022 Free Software Foundation, Inc. 3Copyright (C) 2021-2022 Free Software Foundation, Inc.
4 4
5Maintainer: Yuan Fu <casouri@gmail.com>
6
5This file is part of GNU Emacs. 7This file is part of GNU Emacs.
6 8
7GNU Emacs is free software: you can redistribute it and/or modify 9GNU Emacs is free software: you can redistribute it and/or modify
@@ -2168,6 +2170,8 @@ See Info node `(elisp)Pattern Matching' for detailed explanation. */)
2168 return build_pure_c_string ("#equal"); 2170 return build_pure_c_string ("#equal");
2169 if (EQ (pattern, QCmatch)) 2171 if (EQ (pattern, QCmatch))
2170 return build_pure_c_string ("#match"); 2172 return build_pure_c_string ("#match");
2173 if (EQ (pattern, QCpred))
2174 return build_pure_c_string ("#pred");
2171 Lisp_Object opening_delimeter 2175 Lisp_Object opening_delimeter
2172 = build_pure_c_string (VECTORP (pattern) ? "[" : "("); 2176 = build_pure_c_string (VECTORP (pattern) ? "[" : "(");
2173 Lisp_Object closing_delimiter 2177 Lisp_Object closing_delimiter
@@ -2267,10 +2271,10 @@ treesit_predicates_for_pattern (TSQuery *query, uint32_t pattern_index)
2267 return Fnreverse (result); 2271 return Fnreverse (result);
2268} 2272}
2269 2273
2270/* Translate a capture NAME (symbol) to the text of the captured node. 2274/* Translate a capture NAME (symbol) to a node.
2271 Signals treesit-query-error if such node is not captured. */ 2275 Signals treesit-query-error if such node is not captured. */
2272static Lisp_Object 2276static Lisp_Object
2273treesit_predicate_capture_name_to_text (Lisp_Object name, 2277treesit_predicate_capture_name_to_node (Lisp_Object name,
2274 struct capture_range captures) 2278 struct capture_range captures)
2275{ 2279{
2276 Lisp_Object node = Qnil; 2280 Lisp_Object node = Qnil;
@@ -2290,6 +2294,16 @@ treesit_predicate_capture_name_to_text (Lisp_Object name,
2290 name, build_pure_c_string ("A predicate can only refer" 2294 name, build_pure_c_string ("A predicate can only refer"
2291 " to captured nodes in the " 2295 " to captured nodes in the "
2292 "same pattern")); 2296 "same pattern"));
2297 return node;
2298}
2299
2300/* Translate a capture NAME (symbol) to the text of the captured node.
2301 Signals treesit-query-error if such node is not captured. */
2302static Lisp_Object
2303treesit_predicate_capture_name_to_text (Lisp_Object name,
2304 struct capture_range captures)
2305{
2306 Lisp_Object node = treesit_predicate_capture_name_to_node (name, captures);
2293 2307
2294 struct buffer *old_buffer = current_buffer; 2308 struct buffer *old_buffer = current_buffer;
2295 set_buffer_internal (XBUFFER (XTS_PARSER (XTS_NODE (node)->parser)->buffer)); 2309 set_buffer_internal (XBUFFER (XTS_PARSER (XTS_NODE (node)->parser)->buffer));
@@ -2363,13 +2377,30 @@ treesit_predicate_match (Lisp_Object args, struct capture_range captures)
2363 return false; 2377 return false;
2364} 2378}
2365 2379
2366/* About predicates: I decide to hard-code predicates in C instead of 2380/* Handles predicate (#pred FN ARG...). Return true if FN returns
2367 implementing an extensible system where predicates are translated 2381 non-nil; return false otherwise. The arity of FN must match the
2368 to Lisp functions, and new predicates can be added by extending a 2382 number of ARGs */
2369 list of functions, because I really couldn't imagine any useful 2383static bool
2370 predicates besides equal and match. If we later found out that 2384treesit_predicate_pred (Lisp_Object args, struct capture_range captures)
2371 such system is indeed useful and necessary, it can be easily 2385{
2372 added. */ 2386 if (XFIXNUM (Flength (args)) < 2)
2387 xsignal2 (Qtreesit_query_error,
2388 build_pure_c_string ("Predicate `pred' requires "
2389 "at least two arguments, "
2390 "but was only given"),
2391 Flength (args));
2392
2393 Lisp_Object fn = Fintern (XCAR (args), Qnil);
2394 Lisp_Object nodes = Qnil;
2395 Lisp_Object tail = XCDR (args);
2396 FOR_EACH_TAIL (tail)
2397 nodes = Fcons (treesit_predicate_capture_name_to_node (XCAR (tail),
2398 captures),
2399 nodes);
2400 nodes = Fnreverse (nodes);
2401
2402 return !NILP (CALLN (Fapply, fn, nodes));
2403}
2373 2404
2374/* If all predicates in PREDICATES passes, return true; otherwise 2405/* If all predicates in PREDICATES passes, return true; otherwise
2375 return false. */ 2406 return false. */
@@ -2385,14 +2416,17 @@ treesit_eval_predicates (struct capture_range captures, Lisp_Object predicates)
2385 Lisp_Object fn = XCAR (predicate); 2416 Lisp_Object fn = XCAR (predicate);
2386 Lisp_Object args = XCDR (predicate); 2417 Lisp_Object args = XCDR (predicate);
2387 if (!NILP (Fstring_equal (fn, build_pure_c_string ("equal")))) 2418 if (!NILP (Fstring_equal (fn, build_pure_c_string ("equal"))))
2388 pass = treesit_predicate_equal (args, captures); 2419 pass &= treesit_predicate_equal (args, captures);
2389 else if (!NILP (Fstring_equal (fn, build_pure_c_string ("match")))) 2420 else if (!NILP (Fstring_equal (fn, build_pure_c_string ("match"))))
2390 pass = treesit_predicate_match (args, captures); 2421 pass &= treesit_predicate_match (args, captures);
2422 else if (!NILP (Fstring_equal (fn, build_pure_c_string ("pred"))))
2423 pass &= treesit_predicate_pred (args, captures);
2391 else 2424 else
2392 xsignal3 (Qtreesit_query_error, 2425 xsignal3 (Qtreesit_query_error,
2393 build_pure_c_string ("Invalid predicate"), 2426 build_pure_c_string ("Invalid predicate"),
2394 fn, build_pure_c_string ("Currently Emacs only supports" 2427 fn, build_pure_c_string ("Currently Emacs only supports"
2395 " equal and match predicate")); 2428 " equal, match, and pred"
2429 " predicate"));
2396 } 2430 }
2397 /* If all predicates passed, add captures to result list. */ 2431 /* If all predicates passed, add captures to result list. */
2398 return pass; 2432 return pass;
@@ -3215,6 +3249,7 @@ syms_of_treesit (void)
3215 DEFSYM (QCanchor, ":anchor"); 3249 DEFSYM (QCanchor, ":anchor");
3216 DEFSYM (QCequal, ":equal"); 3250 DEFSYM (QCequal, ":equal");
3217 DEFSYM (QCmatch, ":match"); 3251 DEFSYM (QCmatch, ":match");
3252 DEFSYM (QCpred, ":pred");
3218 3253
3219 DEFSYM (Qnot_found, "not-found"); 3254 DEFSYM (Qnot_found, "not-found");
3220 DEFSYM (Qsymbol_error, "symbol-error"); 3255 DEFSYM (Qsymbol_error, "symbol-error");
diff --git a/src/w32menu.c b/src/w32menu.c
index b10239d5cc6..5f06f4c4170 100644
--- a/src/w32menu.c
+++ b/src/w32menu.c
@@ -1073,7 +1073,10 @@ is_simple_dialog (Lisp_Object contents)
1073 if (NILP (Fstring_equal (name, other))) 1073 if (NILP (Fstring_equal (name, other)))
1074 return false; 1074 return false;
1075 1075
1076 /* Check there are no more options. */ 1076 /* Check there are no more options.
1077
1078 (FIXME: Since we use MB_YESNOCANCEL, we could also consider
1079 dialogs with 3 options: Yes/No/Cancel as "simple". */
1077 options = XCDR (options); 1080 options = XCDR (options);
1078 return !(CONSP (options)); 1081 return !(CONSP (options));
1079} 1082}
@@ -1085,7 +1088,13 @@ simple_dialog_show (struct frame *f, Lisp_Object contents, Lisp_Object header)
1085 UINT type; 1088 UINT type;
1086 Lisp_Object lispy_answer = Qnil, temp = XCAR (contents); 1089 Lisp_Object lispy_answer = Qnil, temp = XCAR (contents);
1087 1090
1088 type = MB_YESNO; 1091 /* We use MB_YESNOCANCEL to allow the user the equivalent of C-g
1092 when the Yes/No question is asked vya y-or-n-p or
1093 yes-or-no-p. */
1094 if (w32_yes_no_dialog_show_cancel)
1095 type = MB_YESNOCANCEL;
1096 else
1097 type = MB_YESNO;
1089 1098
1090 /* Since we only handle Yes/No dialogs, and we already checked 1099 /* Since we only handle Yes/No dialogs, and we already checked
1091 is_simple_dialog, we don't need to worry about checking contents 1100 is_simple_dialog, we don't need to worry about checking contents
diff --git a/src/w32term.c b/src/w32term.c
index dff21489e5b..e40e4588fde 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -7696,6 +7696,7 @@ static void
7696w32_initialize (void) 7696w32_initialize (void)
7697{ 7697{
7698 HANDLE shell; 7698 HANDLE shell;
7699 BOOL caret;
7699 HRESULT (WINAPI * set_user_model) (const wchar_t * id); 7700 HRESULT (WINAPI * set_user_model) (const wchar_t * id);
7700 7701
7701 baud_rate = 19200; 7702 baud_rate = 19200;
@@ -7732,8 +7733,9 @@ w32_initialize (void)
7732 7733
7733 /* Initialize w32_use_visible_system_caret based on whether a screen 7734 /* Initialize w32_use_visible_system_caret based on whether a screen
7734 reader is in use. */ 7735 reader is in use. */
7735 if (!SystemParametersInfo (SPI_GETSCREENREADER, 0, 7736 if (SystemParametersInfo (SPI_GETSCREENREADER, 0, &caret, 0))
7736 &w32_use_visible_system_caret, 0)) 7737 w32_use_visible_system_caret = caret == TRUE;
7738 else
7737 w32_use_visible_system_caret = 0; 7739 w32_use_visible_system_caret = 0;
7738 7740
7739 any_help_event_p = 0; 7741 any_help_event_p = 0;
@@ -7923,6 +7925,11 @@ unconditionally set to nil on older systems. */);
7923 w32_use_native_image_api = 0; 7925 w32_use_native_image_api = 0;
7924#endif 7926#endif
7925 7927
7928 DEFVAR_BOOL ("w32-yes-no-dialog-show-cancel",
7929 w32_yes_no_dialog_show_cancel,
7930 doc: /* If non-nil, show Cancel button in MS-Windows GUI Yes/No dialogs. */);
7931 w32_yes_no_dialog_show_cancel = 1;
7932
7926 /* FIXME: The following variable will be (hopefully) removed 7933 /* FIXME: The following variable will be (hopefully) removed
7927 before Emacs 25.1 gets released. */ 7934 before Emacs 25.1 gets released. */
7928 7935
diff --git a/src/xdisp.c b/src/xdisp.c
index 8a32ce66235..db6dd3fab63 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -14271,12 +14271,14 @@ redisplay_tab_bar (struct frame *f)
14271 frame_default_tab_bar_height = new_height; 14271 frame_default_tab_bar_height = new_height;
14272 } 14272 }
14273 14273
14274 /* If new_height or new_nrows indicate that we need to enlarge the 14274 /* If new_height or new_nrows indicate that we need to enlarge or
14275 tab-bar window, we can return right away. */ 14275 shrink the tab-bar window, we can return right away. */
14276 if (new_nrows > f->n_tab_bar_rows 14276 if (new_nrows > f->n_tab_bar_rows
14277 || (EQ (Vauto_resize_tab_bars, Qgrow_only) 14277 || (EQ (Vauto_resize_tab_bars, Qgrow_only)
14278 && !f->minimize_tab_bar_window_p 14278 && !f->minimize_tab_bar_window_p
14279 && new_height > WINDOW_PIXEL_HEIGHT (w))) 14279 && new_height > WINDOW_PIXEL_HEIGHT (w))
14280 || (! EQ (Vauto_resize_tab_bars, Qgrow_only)
14281 && new_height < WINDOW_PIXEL_HEIGHT (w)))
14280 { 14282 {
14281 if (FRAME_TERMINAL (f)->change_tab_bar_height_hook) 14283 if (FRAME_TERMINAL (f)->change_tab_bar_height_hook)
14282 FRAME_TERMINAL (f)->change_tab_bar_height_hook (f, new_height); 14284 FRAME_TERMINAL (f)->change_tab_bar_height_hook (f, new_height);