aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2023-04-25 09:57:23 -0400
committerEli Zaretskii2023-04-25 09:57:23 -0400
commit095ec506d03b76155b399fd7b23554279b2cfee0 (patch)
tree19d842d92c57cf863e69858bb85e0c1c311c4308 /src
parentf55ac7a74510d68f02d17a034571350f9876017f (diff)
parent524e161a536c1c803f453f286430ba1a4e36694e (diff)
downloademacs-095ec506d03b76155b399fd7b23554279b2cfee0.tar.gz
emacs-095ec506d03b76155b399fd7b23554279b2cfee0.zip
Merge from origin/emacs-29
524e161a536 Followup to addition of TUTORIAL.fa 76f50df1539 Add Farsi/Persian translation of the tutorial 8eacfaea6d8 Add Mongolian language environments fe8efbb8f75 Document the 'end-session' event on MS-Windows d80f959bede Update to Org 9.6.4-9-g8eb209 98c6cfcbe4a Don't support versioned grammar libraries on MS-Windows 8f71c1546df Accept versioned tree-sitter language grammar files 99add09d5e1 tab-bar-new-tab: inhibit side-window checks 087e8181947 * etc/NEWS: Fix outline level. (Bug#63042) d7f38558c4c ; Improve font selection for Traditional Mongolian 965c5e0231c Fix rendering of Traditional Mongolian script 9a0f10b5f88 Fix line-number-at-pos when POSITION is out of narrowing 4e0f4292aaf ; * etc/tutorials/TUTORIAL: Fix punctuation. dec2ac0c657 Fix exiting Emacs after saving a tutorial # Conflicts: # etc/NEWS
Diffstat (limited to 'src')
-rw-r--r--src/fns.c35
-rw-r--r--src/treesit.c24
2 files changed, 45 insertions, 14 deletions
diff --git a/src/fns.c b/src/fns.c
index 02388fa60ed..bb6efdda655 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -6141,29 +6141,40 @@ second optional argument ABSOLUTE is non-nil, the value counts the lines
6141from the absolute start of the buffer, disregarding the narrowing. */) 6141from the absolute start of the buffer, disregarding the narrowing. */)
6142 (register Lisp_Object position, Lisp_Object absolute) 6142 (register Lisp_Object position, Lisp_Object absolute)
6143{ 6143{
6144 ptrdiff_t pos, start = BEGV_BYTE; 6144 ptrdiff_t pos_byte, start_byte = BEGV_BYTE;
6145 6145
6146 if (MARKERP (position)) 6146 if (MARKERP (position))
6147 pos = marker_position (position); 6147 {
6148 /* We don't trust the byte position if the marker's buffer is
6149 not the current buffer. */
6150 if (XMARKER (position)->buffer != current_buffer)
6151 pos_byte = CHAR_TO_BYTE (marker_position (position));
6152 else
6153 pos_byte = marker_byte_position (position);
6154 }
6148 else if (NILP (position)) 6155 else if (NILP (position))
6149 pos = PT; 6156 pos_byte = PT_BYTE;
6150 else 6157 else
6151 { 6158 {
6152 CHECK_FIXNUM (position); 6159 CHECK_FIXNUM (position);
6153 pos = XFIXNUM (position); 6160 ptrdiff_t pos = XFIXNUM (position);
6161 /* Check that POSITION is valid. */
6162 if (pos < BEG || pos > Z)
6163 args_out_of_range_3 (position, make_int (BEG), make_int (Z));
6164 pos_byte = CHAR_TO_BYTE (pos);
6154 } 6165 }
6155 6166
6156 if (!NILP (absolute)) 6167 if (!NILP (absolute))
6157 start = BEG_BYTE; 6168 start_byte = BEG_BYTE;
6169 else if (NILP (absolute))
6170 pos_byte = clip_to_bounds (BEGV_BYTE, pos_byte, ZV_BYTE);
6158 6171
6159 /* Check that POSITION is in the accessible range of the buffer, or, 6172 /* Check that POSITION is valid. */
6160 if we're reporting absolute positions, in the buffer. */ 6173 if (pos_byte < BEG_BYTE || pos_byte > Z_BYTE)
6161 if (NILP (absolute) && (pos < BEGV || pos > ZV)) 6174 args_out_of_range_3 (make_int (BYTE_TO_CHAR (pos_byte)),
6162 args_out_of_range_3 (make_int (pos), make_int (BEGV), make_int (ZV)); 6175 make_int (BEG), make_int (Z));
6163 else if (!NILP (absolute) && (pos < 1 || pos > Z))
6164 args_out_of_range_3 (make_int (pos), make_int (1), make_int (Z));
6165 6176
6166 return make_int (count_lines (start, CHAR_TO_BYTE (pos)) + 1); 6177 return make_int (count_lines (start_byte, pos_byte) + 1);
6167} 6178}
6168 6179
6169 6180
diff --git a/src/treesit.c b/src/treesit.c
index cbcc688571b..ef272fb8871 100644
--- a/src/treesit.c
+++ b/src/treesit.c
@@ -404,6 +404,9 @@ init_treesit_functions (void)
404 404
405static Lisp_Object Vtreesit_str_libtree_sitter; 405static Lisp_Object Vtreesit_str_libtree_sitter;
406static Lisp_Object Vtreesit_str_tree_sitter; 406static Lisp_Object Vtreesit_str_tree_sitter;
407#ifndef WINDOWSNT
408static Lisp_Object Vtreesit_str_dot_0;
409#endif
407static Lisp_Object Vtreesit_str_dot; 410static Lisp_Object Vtreesit_str_dot;
408static Lisp_Object Vtreesit_str_question_mark; 411static Lisp_Object Vtreesit_str_question_mark;
409static Lisp_Object Vtreesit_str_star; 412static Lisp_Object Vtreesit_str_star;
@@ -543,8 +546,21 @@ treesit_load_language_push_for_each_suffix (Lisp_Object lib_base_name,
543 suffixes = Vdynamic_library_suffixes; 546 suffixes = Vdynamic_library_suffixes;
544 547
545 FOR_EACH_TAIL (suffixes) 548 FOR_EACH_TAIL (suffixes)
546 *path_candidates = Fcons (concat2 (lib_base_name, XCAR (suffixes)), 549 {
547 *path_candidates); 550 Lisp_Object candidate1 = concat2 (lib_base_name, XCAR (suffixes));
551#ifndef WINDOWSNT
552 /* On Posix hosts, support libraries named with ABI version
553 numbers. In the foreseeable future we only need to support
554 version 0.0. For more details, see
555 https://lists.gnu.org/archive/html/emacs-devel/2023-04/msg00386.html. */
556 Lisp_Object candidate2 = concat2 (candidate1, Vtreesit_str_dot_0);
557 Lisp_Object candidate3 = concat2 (candidate2, Vtreesit_str_dot_0);
558
559 *path_candidates = Fcons (candidate3, *path_candidates);
560 *path_candidates = Fcons (candidate2, *path_candidates);
561#endif
562 *path_candidates = Fcons (candidate1, *path_candidates);
563 }
548} 564}
549 565
550/* Load the dynamic library of LANGUAGE_SYMBOL and return the pointer 566/* Load the dynamic library of LANGUAGE_SYMBOL and return the pointer
@@ -3948,6 +3964,10 @@ the symbol of that THING. For example, (or block sexp). */);
3948 Vtreesit_str_libtree_sitter = build_pure_c_string ("libtree-sitter-"); 3964 Vtreesit_str_libtree_sitter = build_pure_c_string ("libtree-sitter-");
3949 staticpro (&Vtreesit_str_tree_sitter); 3965 staticpro (&Vtreesit_str_tree_sitter);
3950 Vtreesit_str_tree_sitter = build_pure_c_string ("tree-sitter-"); 3966 Vtreesit_str_tree_sitter = build_pure_c_string ("tree-sitter-");
3967#ifndef WINDOWSNT
3968 staticpro (&Vtreesit_str_dot_0);
3969 Vtreesit_str_dot_0 = build_pure_c_string (".0");
3970#endif
3951 staticpro (&Vtreesit_str_dot); 3971 staticpro (&Vtreesit_str_dot);
3952 Vtreesit_str_dot = build_pure_c_string ("."); 3972 Vtreesit_str_dot = build_pure_c_string (".");
3953 staticpro (&Vtreesit_str_question_mark); 3973 staticpro (&Vtreesit_str_question_mark);