diff options
| author | Stefan Monnier | 2023-01-14 09:10:45 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2023-01-14 09:10:45 -0500 |
| commit | 4f0459aaf756e56db5fb943177eec6eb5bd5fc4a (patch) | |
| tree | d4f404727a4a55e2efc1dd4979851bcb67ccd852 /src | |
| parent | 99120491730c5839a5ba15ded187d481af1e71a7 (diff) | |
| parent | 861556c1339cd65842ec3e24ba48590e6b72bd48 (diff) | |
| download | emacs-4f0459aaf756e56db5fb943177eec6eb5bd5fc4a.tar.gz emacs-4f0459aaf756e56db5fb943177eec6eb5bd5fc4a.zip | |
Merge from origin/emacs-29
861556c1339 Fix minibuffer-completion tests
c0578edc8fc ; * doc/misc/eglot.texi (Troubleshooting Eglot): Fix typo...
c6bbf9cc270 Add c-ts-mode tests
a760364f5f3 Fix c-ts-mode--fill-paragraph
2a2b1d09ac7 Fix minor issues with 'pp' and related commands
dfb38fb2ee6 ; Improve documentation of tree-sitter node comparison
e8a89a18b69 ; Fix non-tree-sitter builds
f27a330b99e ; Fix typo in ert-with-temp-file
956889d8ff1 Equal now recognizes tree-sitter nodes (bug#60659)
8f446c2d397 Fix c-ts-mode comment indentation (bug#60270)
083badc9c12 * lisp/subr.el (while-let): Use if-let, not if-let* (bug#...
9ecebcdded1 * lisp/simple.el (next-completion): Handle first completi...
cfd2b3504ab Fix encoding with 'utf-8-auto'
53b47df8229 Report cursor correctly on PGTK when there is a margin
# Conflicts:
# etc/NEWS
Diffstat (limited to 'src')
| -rw-r--r-- | src/coding.c | 2 | ||||
| -rw-r--r-- | src/fns.c | 9 | ||||
| -rw-r--r-- | src/pgtkterm.c | 3 | ||||
| -rw-r--r-- | src/treesit.c | 24 | ||||
| -rw-r--r-- | src/treesit.h | 1 |
5 files changed, 29 insertions, 10 deletions
diff --git a/src/coding.c b/src/coding.c index 4e59f2b6a1b..49dcd8634f3 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -1431,7 +1431,7 @@ encode_coding_utf_8 (struct coding_system *coding) | |||
| 1431 | ptrdiff_t produced_chars = 0; | 1431 | ptrdiff_t produced_chars = 0; |
| 1432 | int c; | 1432 | int c; |
| 1433 | 1433 | ||
| 1434 | if (CODING_UTF_8_BOM (coding) == utf_with_bom) | 1434 | if (CODING_UTF_8_BOM (coding) != utf_without_bom) |
| 1435 | { | 1435 | { |
| 1436 | ASSURE_DESTINATION (3); | 1436 | ASSURE_DESTINATION (3); |
| 1437 | EMIT_THREE_BYTES (UTF_8_BOM_1, UTF_8_BOM_2, UTF_8_BOM_3); | 1437 | EMIT_THREE_BYTES (UTF_8_BOM_1, UTF_8_BOM_2, UTF_8_BOM_3); |
| @@ -38,6 +38,10 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 38 | #include "puresize.h" | 38 | #include "puresize.h" |
| 39 | #include "gnutls.h" | 39 | #include "gnutls.h" |
| 40 | 40 | ||
| 41 | #ifdef HAVE_TREE_SITTER | ||
| 42 | #include "treesit.h" | ||
| 43 | #endif | ||
| 44 | |||
| 41 | enum equal_kind { EQUAL_NO_QUIT, EQUAL_PLAIN, EQUAL_INCLUDING_PROPERTIES }; | 45 | enum equal_kind { EQUAL_NO_QUIT, EQUAL_PLAIN, EQUAL_INCLUDING_PROPERTIES }; |
| 42 | static bool internal_equal (Lisp_Object, Lisp_Object, | 46 | static bool internal_equal (Lisp_Object, Lisp_Object, |
| 43 | enum equal_kind, int, Lisp_Object); | 47 | enum equal_kind, int, Lisp_Object); |
| @@ -2828,6 +2832,11 @@ internal_equal (Lisp_Object o1, Lisp_Object o2, enum equal_kind equal_kind, | |||
| 2828 | bool_vector_bytes (size))); | 2832 | bool_vector_bytes (size))); |
| 2829 | } | 2833 | } |
| 2830 | 2834 | ||
| 2835 | #ifdef HAVE_TREE_SITTER | ||
| 2836 | if (TS_NODEP (o1)) | ||
| 2837 | return treesit_node_eq (o1, o2); | ||
| 2838 | #endif | ||
| 2839 | |||
| 2831 | /* Aside from them, only true vectors, char-tables, compiled | 2840 | /* Aside from them, only true vectors, char-tables, compiled |
| 2832 | functions, and fonts (font-spec, font-entity, font-object) | 2841 | functions, and fonts (font-spec, font-entity, font-object) |
| 2833 | are sensible to compare, so eliminate the others now. */ | 2842 | are sensible to compare, so eliminate the others now. */ |
diff --git a/src/pgtkterm.c b/src/pgtkterm.c index 5158492ca09..c00e13550bd 100644 --- a/src/pgtkterm.c +++ b/src/pgtkterm.c | |||
| @@ -2959,7 +2959,8 @@ pgtk_draw_window_cursor (struct window *w, struct glyph_row *glyph_row, int x, | |||
| 2959 | if (w == XWINDOW (f->selected_window)) | 2959 | if (w == XWINDOW (f->selected_window)) |
| 2960 | { | 2960 | { |
| 2961 | int frame_x = (WINDOW_TO_FRAME_PIXEL_X (w, x) | 2961 | int frame_x = (WINDOW_TO_FRAME_PIXEL_X (w, x) |
| 2962 | + WINDOW_LEFT_FRINGE_WIDTH (w)); | 2962 | + WINDOW_LEFT_FRINGE_WIDTH (w) |
| 2963 | + WINDOW_LEFT_MARGIN_WIDTH (w)); | ||
| 2963 | int frame_y = WINDOW_TO_FRAME_PIXEL_Y (w, y); | 2964 | int frame_y = WINDOW_TO_FRAME_PIXEL_Y (w, y); |
| 2964 | pgtk_im_set_cursor_location (f, frame_x, frame_y, | 2965 | pgtk_im_set_cursor_location (f, frame_x, frame_y, |
| 2965 | w->phys_cursor_width, | 2966 | w->phys_cursor_width, |
diff --git a/src/treesit.c b/src/treesit.c index 55463122d14..33a7e3c8528 100644 --- a/src/treesit.c +++ b/src/treesit.c | |||
| @@ -2154,11 +2154,24 @@ If NODE is nil, return nil. */) | |||
| 2154 | return make_treesit_node (XTS_NODE (node)->parser, child); | 2154 | return make_treesit_node (XTS_NODE (node)->parser, child); |
| 2155 | } | 2155 | } |
| 2156 | 2156 | ||
| 2157 | /* Return true if NODE1 and NODE2 are the same node. Assumes they are | ||
| 2158 | TS_NODE type. */ | ||
| 2159 | bool treesit_node_eq (Lisp_Object node1, Lisp_Object node2) | ||
| 2160 | { | ||
| 2161 | treesit_initialize (); | ||
| 2162 | TSNode treesit_node_1 = XTS_NODE (node1)->node; | ||
| 2163 | TSNode treesit_node_2 = XTS_NODE (node2)->node; | ||
| 2164 | return ts_node_eq (treesit_node_1, treesit_node_2); | ||
| 2165 | } | ||
| 2166 | |||
| 2157 | DEFUN ("treesit-node-eq", | 2167 | DEFUN ("treesit-node-eq", |
| 2158 | Ftreesit_node_eq, | 2168 | Ftreesit_node_eq, |
| 2159 | Streesit_node_eq, 2, 2, 0, | 2169 | Streesit_node_eq, 2, 2, 0, |
| 2160 | doc: /* Return non-nil if NODE1 and NODE2 are the same node. | 2170 | doc: /* Return non-nil if NODE1 and NODE2 refer to the same node. |
| 2161 | If any one of NODE1 and NODE2 is nil, return nil. */) | 2171 | If any one of NODE1 and NODE2 is nil, return nil. |
| 2172 | This function uses the same equivalence metric as `equal', and returns | ||
| 2173 | non-nil if NODE1 and NODE2 refer to the same node in a syntax tree | ||
| 2174 | produced by tree-sitter. */) | ||
| 2162 | (Lisp_Object node1, Lisp_Object node2) | 2175 | (Lisp_Object node1, Lisp_Object node2) |
| 2163 | { | 2176 | { |
| 2164 | if (NILP (node1) || NILP (node2)) | 2177 | if (NILP (node1) || NILP (node2)) |
| @@ -2166,12 +2179,7 @@ If any one of NODE1 and NODE2 is nil, return nil. */) | |||
| 2166 | CHECK_TS_NODE (node1); | 2179 | CHECK_TS_NODE (node1); |
| 2167 | CHECK_TS_NODE (node2); | 2180 | CHECK_TS_NODE (node2); |
| 2168 | 2181 | ||
| 2169 | treesit_initialize (); | 2182 | bool same_node = treesit_node_eq (node1, node2); |
| 2170 | |||
| 2171 | TSNode treesit_node_1 = XTS_NODE (node1)->node; | ||
| 2172 | TSNode treesit_node_2 = XTS_NODE (node2)->node; | ||
| 2173 | |||
| 2174 | bool same_node = ts_node_eq (treesit_node_1, treesit_node_2); | ||
| 2175 | return same_node ? Qt : Qnil; | 2183 | return same_node ? Qt : Qnil; |
| 2176 | } | 2184 | } |
| 2177 | 2185 | ||
diff --git a/src/treesit.h b/src/treesit.h index 909609737d3..5382bc58817 100644 --- a/src/treesit.h +++ b/src/treesit.h | |||
| @@ -191,6 +191,7 @@ extern bool treesit_node_uptodate_p (Lisp_Object); | |||
| 191 | extern void treesit_delete_parser (struct Lisp_TS_Parser *); | 191 | extern void treesit_delete_parser (struct Lisp_TS_Parser *); |
| 192 | extern void treesit_delete_query (struct Lisp_TS_Query *); | 192 | extern void treesit_delete_query (struct Lisp_TS_Query *); |
| 193 | extern bool treesit_named_node_p (TSNode); | 193 | extern bool treesit_named_node_p (TSNode); |
| 194 | extern bool treesit_node_eq (Lisp_Object, Lisp_Object); | ||
| 194 | 195 | ||
| 195 | #endif /* HAVE_TREE_SITTER */ | 196 | #endif /* HAVE_TREE_SITTER */ |
| 196 | 197 | ||