diff options
author | Eli Zaretskii <eliz@gnu.org> | 2023-04-25 09:57:23 -0400 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2023-04-25 09:57:23 -0400 |
commit | 095ec506d03b76155b399fd7b23554279b2cfee0 (patch) | |
tree | 19d842d92c57cf863e69858bb85e0c1c311c4308 /src | |
parent | f55ac7a74510d68f02d17a034571350f9876017f (diff) | |
parent | 524e161a536c1c803f453f286430ba1a4e36694e (diff) | |
download | emacs-095ec506d03b76155b399fd7b23554279b2cfee0.tar.gz |
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.c | 35 | ||||
-rw-r--r-- | src/treesit.c | 24 |
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 from the absolute start of the buffer, disregarding the narrowing. */) (register Lisp_Object position, Lisp_Object absolute) { - ptrdiff_t pos, start = BEGV_BYTE; + ptrdiff_t pos_byte, start_byte = BEGV_BYTE; if (MARKERP (position)) - pos = marker_position (position); + { + /* We don't trust the byte position if the marker's buffer is + not the current buffer. */ + if (XMARKER (position)->buffer != current_buffer) + pos_byte = CHAR_TO_BYTE (marker_position (position)); + else + pos_byte = marker_byte_position (position); + } else if (NILP (position)) - pos = PT; + pos_byte = PT_BYTE; else { CHECK_FIXNUM (position); - pos = XFIXNUM (position); + ptrdiff_t pos = XFIXNUM (position); + /* Check that POSITION is valid. */ + if (pos < BEG || pos > Z) + args_out_of_range_3 (position, make_int (BEG), make_int (Z)); + pos_byte = CHAR_TO_BYTE (pos); } if (!NILP (absolute)) - start = BEG_BYTE; + start_byte = BEG_BYTE; + else if (NILP (absolute)) + pos_byte = clip_to_bounds (BEGV_BYTE, pos_byte, ZV_BYTE); - /* Check that POSITION is in the accessible range of the buffer, or, - if we're reporting absolute positions, in the buffer. */ - if (NILP (absolute) && (pos < BEGV || pos > ZV)) - args_out_of_range_3 (make_int (pos), make_int (BEGV), make_int (ZV)); - else if (!NILP (absolute) && (pos < 1 || pos > Z)) - args_out_of_range_3 (make_int (pos), make_int (1), make_int (Z)); + /* Check that POSITION is valid. */ + if (pos_byte < BEG_BYTE || pos_byte > Z_BYTE) + args_out_of_range_3 (make_int (BYTE_TO_CHAR (pos_byte)), + make_int (BEG), make_int (Z)); - return make_int (count_lines (start, CHAR_TO_BYTE (pos)) + 1); + return make_int (count_lines (start_byte, pos_byte) + 1); } 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) static Lisp_Object Vtreesit_str_libtree_sitter; static Lisp_Object Vtreesit_str_tree_sitter; +#ifndef WINDOWSNT +static Lisp_Object Vtreesit_str_dot_0; +#endif static Lisp_Object Vtreesit_str_dot; static Lisp_Object Vtreesit_str_question_mark; static Lisp_Object Vtreesit_str_star; @@ -543,8 +546,21 @@ treesit_load_language_push_for_each_suffix (Lisp_Object lib_base_name, suffixes = Vdynamic_library_suffixes; FOR_EACH_TAIL (suffixes) - *path_candidates = Fcons (concat2 (lib_base_name, XCAR (suffixes)), - *path_candidates); + { + Lisp_Object candidate1 = concat2 (lib_base_name, XCAR (suffixes)); +#ifndef WINDOWSNT + /* On Posix hosts, support libraries named with ABI version + numbers. In the foreseeable future we only need to support + version 0.0. For more details, see + https://lists.gnu.org/archive/html/emacs-devel/2023-04/msg00386.html. */ + Lisp_Object candidate2 = concat2 (candidate1, Vtreesit_str_dot_0); + Lisp_Object candidate3 = concat2 (candidate2, Vtreesit_str_dot_0); + + *path_candidates = Fcons (candidate3, *path_candidates); + *path_candidates = Fcons (candidate2, *path_candidates); +#endif + *path_candidates = Fcons (candidate1, *path_candidates); + } } /* 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). */); Vtreesit_str_libtree_sitter = build_pure_c_string ("libtree-sitter-"); staticpro (&Vtreesit_str_tree_sitter); Vtreesit_str_tree_sitter = build_pure_c_string ("tree-sitter-"); +#ifndef WINDOWSNT + staticpro (&Vtreesit_str_dot_0); + Vtreesit_str_dot_0 = build_pure_c_string (".0"); +#endif staticpro (&Vtreesit_str_dot); Vtreesit_str_dot = build_pure_c_string ("."); staticpro (&Vtreesit_str_question_mark); |