aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuan Fu2022-10-17 14:12:24 -0700
committerYuan Fu2022-10-17 14:12:24 -0700
commite8df6c311fcf59bf23d31b9db2bb8fec9d78fbe7 (patch)
tree3338ca7cfd0957063bca0b26fb2da8c791436566
parent0be9a639fca70c278d1b79fcea5d6beebdf7799c (diff)
downloademacs-e8df6c311fcf59bf23d31b9db2bb8fec9d78fbe7.tar.gz
emacs-e8df6c311fcf59bf23d31b9db2bb8fec9d78fbe7.zip
Simplify error reported by loading tree-sitter language definition
Before: Error: Cannot load language definition: "javascript", ("/home/jostein/.emacs.d/tree-sitter/libtree-sitter-javascript: cannot open shared object file: No such file or directory" "/home/jostein/.emacs.d/tree-sitter/libtree-sitter-javascript.so: cannot open shared object file: No such file or directory" "libtree-sitter-javascript: cannot open shared object file: No such file or directory" "libtree-sitter-javascript.so: cannot open shared object file: No such file or directory") After: (treesit-load-language-error not-found ("libtree-sitter-z.so" "libtree-sitter-z.dylib") "No such file or directory") * src/treesit.c (treesit_load_language): Add base_candidates, remove error_list, report base_candidates rather than error_list.
-rw-r--r--src/treesit.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/treesit.c b/src/treesit.c
index 90a1249ba8d..036411865d3 100644
--- a/src/treesit.c
+++ b/src/treesit.c
@@ -512,6 +512,8 @@ treesit_load_language (Lisp_Object language_symbol,
512 /* First push just the filenames to the candidate list, which will 512 /* First push just the filenames to the candidate list, which will
513 make dynlib_open look under standard system load paths. */ 513 make dynlib_open look under standard system load paths. */
514 treesit_load_language_push_for_each_suffix (lib_base_name, &path_candidates); 514 treesit_load_language_push_for_each_suffix (lib_base_name, &path_candidates);
515 /* This is used for reporting errors (i.e., just filenames). */
516 Lisp_Object base_candidates = path_candidates;
515 /* Then push ~/.emacs.d/tree-sitter paths. */ 517 /* Then push ~/.emacs.d/tree-sitter paths. */
516 Lisp_Object lib_name = 518 Lisp_Object lib_name =
517 Fexpand_file_name (concat2 (build_string ("tree-sitter/"), lib_base_name), 519 Fexpand_file_name (concat2 (build_string ("tree-sitter/"), lib_base_name),
@@ -531,7 +533,6 @@ treesit_load_language (Lisp_Object language_symbol,
531 fail. */ 533 fail. */
532 dynlib_handle_ptr handle; 534 dynlib_handle_ptr handle;
533 char const *error; 535 char const *error;
534 Lisp_Object error_list = Qnil;
535 for (Lisp_Object tail = path_candidates; 536 for (Lisp_Object tail = path_candidates;
536 !NILP (tail); tail = XCDR (tail)) 537 !NILP (tail); tail = XCDR (tail))
537 { 538 {
@@ -541,13 +542,12 @@ treesit_load_language (Lisp_Object language_symbol,
541 error = dynlib_error (); 542 error = dynlib_error ();
542 if (error == NULL) 543 if (error == NULL)
543 break; 544 break;
544 else
545 error_list = Fcons (build_string (error), error_list);
546 } 545 }
547 if (error != NULL) 546 if (error != NULL)
548 { 547 {
549 *signal_symbol = Qtreesit_load_language_error; 548 *signal_symbol = Qtreesit_load_language_error;
550 *signal_data = Fcons (Qnot_found, Fnreverse (error_list)); 549 *signal_data = list3 (Qnot_found, base_candidates,
550 build_string ("No such file or directory"));
551 return NULL; 551 return NULL;
552 } 552 }
553 553