diff options
| author | Yuan Fu | 2024-12-01 17:52:16 -0800 |
|---|---|---|
| committer | Yuan Fu | 2024-12-01 17:52:16 -0800 |
| commit | 4afd1eca3662eda052d0017f83b4baa1f6131e8b (patch) | |
| tree | 10c2a2f0d338b8fb330fbbc9b21f296271b73ee2 | |
| parent | 676ff9fd7c083598b2955a463774283768d8e209 (diff) | |
| parent | cf4f1387a6561be7cd7387b766df4386a0fa472f (diff) | |
| download | emacs-4afd1eca3662eda052d0017f83b4baa1f6131e8b.tar.gz emacs-4afd1eca3662eda052d0017f83b4baa1f6131e8b.zip | |
Merge from emacs-30
cf4f1387a65 ; Update tree-sitter manual
3c7687c1dd1 Allow passing nil to treesit-node-match-p (bug#74612)
748b19e56e8 Update to version 2.58 of librsvg API (bug#74606)
4c67f636c08 Fix decoding of non-ASCII email attachments
bd8a6f70fb9 Prevent "Selecting deleted buffer" error with dabbrev-expand
0a753603a53 ; (dictionary-search-interface): Fix bug#74511.
| -rw-r--r-- | doc/lispref/parsing.texi | 32 | ||||
| -rw-r--r-- | lisp/dabbrev.el | 6 | ||||
| -rw-r--r-- | lisp/mail/rfc2231.el | 2 | ||||
| -rw-r--r-- | lisp/net/dictionary.el | 1 | ||||
| -rw-r--r-- | src/image.c | 26 | ||||
| -rw-r--r-- | src/treesit.c | 5 | ||||
| -rw-r--r-- | test/lisp/dabbrev-tests.el | 34 |
7 files changed, 93 insertions, 13 deletions
diff --git a/doc/lispref/parsing.texi b/doc/lispref/parsing.texi index 20b1085b46c..9fe828d8512 100644 --- a/doc/lispref/parsing.texi +++ b/doc/lispref/parsing.texi | |||
| @@ -1553,7 +1553,11 @@ The ``things'' feature in Emacs is independent of the pattern matching | |||
| 1553 | feature of tree-sitter, and comparatively less powerful, but more | 1553 | feature of tree-sitter, and comparatively less powerful, but more |
| 1554 | suitable for navigation and traversing the parse tree. | 1554 | suitable for navigation and traversing the parse tree. |
| 1555 | 1555 | ||
| 1556 | You can define things with @code{treesit-thing-settings}. | 1556 | @findex treesit-thing-definition |
| 1557 | @findex treesit-thing-defined-p | ||
| 1558 | You can define things with @var{treesit-thing-settings}, retrieve the | ||
| 1559 | predicate of a defined thing with @code{treesit-thing-definition}, and | ||
| 1560 | test if a thing is defined with @code{treesit-thing-defined-p}. | ||
| 1557 | 1561 | ||
| 1558 | @defvar treesit-thing-settings | 1562 | @defvar treesit-thing-settings |
| 1559 | This is an alist of thing definitions for each language. The key of | 1563 | This is an alist of thing definitions for each language. The key of |
| @@ -1609,6 +1613,25 @@ functions listed elsewhere also utilize the thing feature, e.g., | |||
| 1609 | tree-traversing functions like @code{treesit-search-forward}, | 1613 | tree-traversing functions like @code{treesit-search-forward}, |
| 1610 | @code{treesit-induce-sparse-tree}, etc. @xref{Retrieving Nodes}. | 1614 | @code{treesit-induce-sparse-tree}, etc. @xref{Retrieving Nodes}. |
| 1611 | 1615 | ||
| 1616 | @defun treesit-node-match-p node thing &optional ignore-missing | ||
| 1617 | This function checks whether @var{node} is a @var{thing}. | ||
| 1618 | |||
| 1619 | If @var{node} is a @var{thing}, return non-@code{nil}, otherwise return | ||
| 1620 | @code{nil}. For convenience, if @code{node} is @code{nil}, this | ||
| 1621 | function just returns @code{nil}. | ||
| 1622 | |||
| 1623 | The @var{thing} can be either a thing symbol like @code{defun}, or | ||
| 1624 | simply a predicate that defines a thing, like | ||
| 1625 | @code{"function_definition"}, or @w{@code{(or comment string)}}. | ||
| 1626 | |||
| 1627 | By default, if @var{thing} is undefined or malformed, this function | ||
| 1628 | signals @code{treesit-invalid-predicate} error. If @var{ignore-missing} | ||
| 1629 | is @code{t}, this function doesn't signal the error when @var{thing} is | ||
| 1630 | undefined and just returns @code{nil}; but it still signals the error if | ||
| 1631 | @var{thing} is a malformed predicate. | ||
| 1632 | |||
| 1633 | @end defun | ||
| 1634 | |||
| 1612 | @defun treesit-thing-prev position thing | 1635 | @defun treesit-thing-prev position thing |
| 1613 | This function returns the first node before @var{position} that is the | 1636 | This function returns the first node before @var{position} that is the |
| 1614 | specified @var{thing}. If no such node exists, it returns @code{nil}. | 1637 | specified @var{thing}. If no such node exists, it returns @code{nil}. |
| @@ -1616,8 +1639,7 @@ It's guaranteed that, if a node is returned, the node's end position is | |||
| 1616 | less or equal to @var{position}. In other words, this function never | 1639 | less or equal to @var{position}. In other words, this function never |
| 1617 | returns a node that encloses @var{position}. | 1640 | returns a node that encloses @var{position}. |
| 1618 | 1641 | ||
| 1619 | @var{thing} can be either a thing symbol like @code{defun}, or simply a | 1642 | Again, @var{thing} can be either a symbol or a predicate. |
| 1620 | thing definition like @code{"function_definition"}. | ||
| 1621 | @end defun | 1643 | @end defun |
| 1622 | 1644 | ||
| 1623 | @defun treesit-thing-next position thing | 1645 | @defun treesit-thing-next position thing |
| @@ -1641,7 +1663,7 @@ A positive @var{arg} means moving forward that many instances of | |||
| 1641 | @code{end}, stop at the end of @var{thing}. | 1663 | @code{end}, stop at the end of @var{thing}. |
| 1642 | 1664 | ||
| 1643 | Like in @code{treesit-thing-prev}, @var{thing} can be a thing symbol | 1665 | Like in @code{treesit-thing-prev}, @var{thing} can be a thing symbol |
| 1644 | defined in @code{treesit-thing-settings}, or a thing definition. | 1666 | defined in @code{treesit-thing-settings}, or a predicate. |
| 1645 | 1667 | ||
| 1646 | @var{tactic} determines how this function moves between things. It can | 1668 | @var{tactic} determines how this function moves between things. It can |
| 1647 | be @code{nested}, @code{top-level}, @code{restricted}, or @code{nil}. | 1669 | be @code{nested}, @code{top-level}, @code{restricted}, or @code{nil}. |
| @@ -1668,7 +1690,7 @@ i.e., start position must be strictly greater than @var{position}, and end | |||
| 1668 | position must be strictly less than @var{position}. | 1690 | position must be strictly less than @var{position}. |
| 1669 | 1691 | ||
| 1670 | @var{thing} can be either a thing symbol defined in | 1692 | @var{thing} can be either a thing symbol defined in |
| 1671 | @code{treesit-thing-settings}, or a thing definition. | 1693 | @code{treesit-thing-settings}, or a predicate. |
| 1672 | @end defun | 1694 | @end defun |
| 1673 | 1695 | ||
| 1674 | @findex treesit-beginning-of-thing | 1696 | @findex treesit-beginning-of-thing |
diff --git a/lisp/dabbrev.el b/lisp/dabbrev.el index bbe6a64b626..84306fb3ae7 100644 --- a/lisp/dabbrev.el +++ b/lisp/dabbrev.el | |||
| @@ -472,8 +472,10 @@ See also `dabbrev-abbrev-char-regexp' and \\[dabbrev-completion]." | |||
| 472 | ;; minibuffer. | 472 | ;; minibuffer. |
| 473 | (window-buffer (get-mru-window))) | 473 | (window-buffer (get-mru-window))) |
| 474 | ;; Otherwise, if we found the expansion in another | 474 | ;; Otherwise, if we found the expansion in another |
| 475 | ;; buffer, use that buffer for further expansions. | 475 | ;; buffer and that buffer is still live, use that |
| 476 | (dabbrev--last-buffer-found dabbrev--last-buffer-found) | 476 | ;; buffer for further expansions. |
| 477 | ((buffer-live-p dabbrev--last-buffer-found) | ||
| 478 | dabbrev--last-buffer-found) | ||
| 477 | ;; Otherwise, use the buffer where we invoked | 479 | ;; Otherwise, use the buffer where we invoked |
| 478 | ;; dabbrev-expand. | 480 | ;; dabbrev-expand. |
| 479 | (t (current-buffer)))) | 481 | (t (current-buffer)))) |
diff --git a/lisp/mail/rfc2231.el b/lisp/mail/rfc2231.el index 33324cafb5b..632e270a922 100644 --- a/lisp/mail/rfc2231.el +++ b/lisp/mail/rfc2231.el | |||
| @@ -193,7 +193,7 @@ must never cause a Lisp error." | |||
| 193 | (push (list attribute value encoded) cparams)) | 193 | (push (list attribute value encoded) cparams)) |
| 194 | ;; Repetition of a part; do nothing. | 194 | ;; Repetition of a part; do nothing. |
| 195 | ((and elem | 195 | ((and elem |
| 196 | (null number)) | 196 | (null part)) |
| 197 | ) | 197 | ) |
| 198 | ;; Concatenate continuation parts. | 198 | ;; Concatenate continuation parts. |
| 199 | (t | 199 | (t |
diff --git a/lisp/net/dictionary.el b/lisp/net/dictionary.el index 58c2e9771ba..42fb8c57b40 100644 --- a/lisp/net/dictionary.el +++ b/lisp/net/dictionary.el | |||
| @@ -317,6 +317,7 @@ Otherwise, `dictionary-search' displays definitions in a *Dictionary* buffer." | |||
| 317 | dictionary-read-dictionary-function) | 317 | dictionary-read-dictionary-function) |
| 318 | vals)) | 318 | vals)) |
| 319 | (set-default-toplevel-value symbol value)) | 319 | (set-default-toplevel-value symbol value)) |
| 320 | :initialize #'custom-initialize-changed | ||
| 320 | :version "30.1") | 321 | :version "30.1") |
| 321 | 322 | ||
| 322 | (defface dictionary-word-definition-face | 323 | (defface dictionary-word-definition-face |
diff --git a/src/image.c b/src/image.c index db7f6acd171..88b0f91413e 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -11706,7 +11706,11 @@ DEF_DLL_FN (void, rsvg_handle_get_dimensions, | |||
| 11706 | DEF_DLL_FN (gboolean, rsvg_handle_set_stylesheet, | 11706 | DEF_DLL_FN (gboolean, rsvg_handle_set_stylesheet, |
| 11707 | (RsvgHandle *, const guint8 *, gsize, GError **)); | 11707 | (RsvgHandle *, const guint8 *, gsize, GError **)); |
| 11708 | # endif | 11708 | # endif |
| 11709 | # if LIBRSVG_CHECK_VERSION (2, 58, 0) | ||
| 11710 | DEF_DLL_FN (GdkPixbuf *, rsvg_handle_get_pixbuf_and_error, (RsvgHandle *, GError **)); | ||
| 11711 | # else | ||
| 11709 | DEF_DLL_FN (GdkPixbuf *, rsvg_handle_get_pixbuf, (RsvgHandle *)); | 11712 | DEF_DLL_FN (GdkPixbuf *, rsvg_handle_get_pixbuf, (RsvgHandle *)); |
| 11713 | # endif | ||
| 11710 | DEF_DLL_FN (int, gdk_pixbuf_get_width, (const GdkPixbuf *)); | 11714 | DEF_DLL_FN (int, gdk_pixbuf_get_width, (const GdkPixbuf *)); |
| 11711 | DEF_DLL_FN (int, gdk_pixbuf_get_height, (const GdkPixbuf *)); | 11715 | DEF_DLL_FN (int, gdk_pixbuf_get_height, (const GdkPixbuf *)); |
| 11712 | DEF_DLL_FN (guchar *, gdk_pixbuf_get_pixels, (const GdkPixbuf *)); | 11716 | DEF_DLL_FN (guchar *, gdk_pixbuf_get_pixels, (const GdkPixbuf *)); |
| @@ -11765,8 +11769,11 @@ init_svg_functions (void) | |||
| 11765 | #if LIBRSVG_CHECK_VERSION (2, 48, 0) | 11769 | #if LIBRSVG_CHECK_VERSION (2, 48, 0) |
| 11766 | LOAD_DLL_FN (library, rsvg_handle_set_stylesheet); | 11770 | LOAD_DLL_FN (library, rsvg_handle_set_stylesheet); |
| 11767 | #endif | 11771 | #endif |
| 11772 | #if LIBRSVG_CHECK_VERSION (2, 58, 0) | ||
| 11773 | LOAD_DLL_FN (library, rsvg_handle_get_pixbuf_and_error); | ||
| 11774 | #else | ||
| 11768 | LOAD_DLL_FN (library, rsvg_handle_get_pixbuf); | 11775 | LOAD_DLL_FN (library, rsvg_handle_get_pixbuf); |
| 11769 | 11776 | #endif | |
| 11770 | LOAD_DLL_FN (gdklib, gdk_pixbuf_get_width); | 11777 | LOAD_DLL_FN (gdklib, gdk_pixbuf_get_width); |
| 11771 | LOAD_DLL_FN (gdklib, gdk_pixbuf_get_height); | 11778 | LOAD_DLL_FN (gdklib, gdk_pixbuf_get_height); |
| 11772 | LOAD_DLL_FN (gdklib, gdk_pixbuf_get_pixels); | 11779 | LOAD_DLL_FN (gdklib, gdk_pixbuf_get_pixels); |
| @@ -11811,7 +11818,11 @@ init_svg_functions (void) | |||
| 11811 | # if LIBRSVG_CHECK_VERSION (2, 48, 0) | 11818 | # if LIBRSVG_CHECK_VERSION (2, 48, 0) |
| 11812 | # undef rsvg_handle_set_stylesheet | 11819 | # undef rsvg_handle_set_stylesheet |
| 11813 | # endif | 11820 | # endif |
| 11814 | # undef rsvg_handle_get_pixbuf | 11821 | # if LIBRSVG_CHECK_VERSION (2, 58, 0) |
| 11822 | # undef rsvg_handle_get_pixbuf_and_error | ||
| 11823 | # else | ||
| 11824 | # undef rsvg_handle_get_pixbuf | ||
| 11825 | # endif | ||
| 11815 | # if LIBRSVG_CHECK_VERSION (2, 32, 0) | 11826 | # if LIBRSVG_CHECK_VERSION (2, 32, 0) |
| 11816 | # undef g_file_new_for_path | 11827 | # undef g_file_new_for_path |
| 11817 | # undef g_memory_input_stream_new_from_data | 11828 | # undef g_memory_input_stream_new_from_data |
| @@ -11852,7 +11863,11 @@ init_svg_functions (void) | |||
| 11852 | # if LIBRSVG_CHECK_VERSION (2, 48, 0) | 11863 | # if LIBRSVG_CHECK_VERSION (2, 48, 0) |
| 11853 | # define rsvg_handle_set_stylesheet fn_rsvg_handle_set_stylesheet | 11864 | # define rsvg_handle_set_stylesheet fn_rsvg_handle_set_stylesheet |
| 11854 | # endif | 11865 | # endif |
| 11855 | # define rsvg_handle_get_pixbuf fn_rsvg_handle_get_pixbuf | 11866 | # if LIBRSVG_CHECK_VERSION (2, 58, 0) |
| 11867 | # define rsvg_handle_get_pixbuf_and_error fn_rsvg_handle_get_pixbuf_and_error | ||
| 11868 | # else | ||
| 11869 | # define rsvg_handle_get_pixbuf fn_rsvg_handle_get_pixbuf | ||
| 11870 | # endif | ||
| 11856 | # if LIBRSVG_CHECK_VERSION (2, 32, 0) | 11871 | # if LIBRSVG_CHECK_VERSION (2, 32, 0) |
| 11857 | # define g_file_new_for_path fn_g_file_new_for_path | 11872 | # define g_file_new_for_path fn_g_file_new_for_path |
| 11858 | # define g_memory_input_stream_new_from_data \ | 11873 | # define g_memory_input_stream_new_from_data \ |
| @@ -12357,8 +12372,13 @@ svg_load_image (struct frame *f, struct image *img, char *contents, | |||
| 12357 | 12372 | ||
| 12358 | /* We can now get a valid pixel buffer from the svg file, if all | 12373 | /* We can now get a valid pixel buffer from the svg file, if all |
| 12359 | went ok. */ | 12374 | went ok. */ |
| 12375 | #if LIBRSVG_CHECK_VERSION (2, 58, 0) | ||
| 12376 | pixbuf = rsvg_handle_get_pixbuf_and_error (rsvg_handle, &err); | ||
| 12377 | if (err) goto rsvg_error; | ||
| 12378 | #else | ||
| 12360 | pixbuf = rsvg_handle_get_pixbuf (rsvg_handle); | 12379 | pixbuf = rsvg_handle_get_pixbuf (rsvg_handle); |
| 12361 | if (!pixbuf) goto rsvg_error; | 12380 | if (!pixbuf) goto rsvg_error; |
| 12381 | #endif | ||
| 12362 | g_object_unref (rsvg_handle); | 12382 | g_object_unref (rsvg_handle); |
| 12363 | xfree (wrapped_contents); | 12383 | xfree (wrapped_contents); |
| 12364 | 12384 | ||
diff --git a/src/treesit.c b/src/treesit.c index 5e1e9b01059..2372944e166 100644 --- a/src/treesit.c +++ b/src/treesit.c | |||
| @@ -4148,7 +4148,8 @@ PREDICATE can be a symbol representing a thing in | |||
| 4148 | `treesit-thing-settings', or a predicate, like regexp matching node | 4148 | `treesit-thing-settings', or a predicate, like regexp matching node |
| 4149 | type, etc. See `treesit-thing-settings' for more details. | 4149 | type, etc. See `treesit-thing-settings' for more details. |
| 4150 | 4150 | ||
| 4151 | Return non-nil if NODE matches PREDICATE, nil otherwise. | 4151 | Return non-nil if NODE matches PREDICATE, nil otherwise. If NODE is |
| 4152 | nil, return nil. | ||
| 4152 | 4153 | ||
| 4153 | Signals `treesit-invalid-predicate' if there's no definition of THING | 4154 | Signals `treesit-invalid-predicate' if there's no definition of THING |
| 4154 | in `treesit-thing-settings', or if PREDICATE is malformed. If | 4155 | in `treesit-thing-settings', or if PREDICATE is malformed. If |
| @@ -4156,6 +4157,8 @@ IGNORE-MISSING is non-nil, don't signal an error for missing THING | |||
| 4156 | definition, but still signal for malformed PREDICATE. */) | 4157 | definition, but still signal for malformed PREDICATE. */) |
| 4157 | (Lisp_Object node, Lisp_Object predicate, Lisp_Object ignore_missing) | 4158 | (Lisp_Object node, Lisp_Object predicate, Lisp_Object ignore_missing) |
| 4158 | { | 4159 | { |
| 4160 | if (NILP (node)) return Qnil; | ||
| 4161 | |||
| 4159 | CHECK_TS_NODE (node); | 4162 | CHECK_TS_NODE (node); |
| 4160 | 4163 | ||
| 4161 | Lisp_Object parser = XTS_NODE (node)->parser; | 4164 | Lisp_Object parser = XTS_NODE (node)->parser; |
diff --git a/test/lisp/dabbrev-tests.el b/test/lisp/dabbrev-tests.el index 987106aa5af..b5737373875 100644 --- a/test/lisp/dabbrev-tests.el +++ b/test/lisp/dabbrev-tests.el | |||
| @@ -238,7 +238,7 @@ entered." | |||
| 238 | ;; FIXME: Why is dabbrev--reset-global-variables needed here? | 238 | ;; FIXME: Why is dabbrev--reset-global-variables needed here? |
| 239 | (ert-deftest dabbrev-expand-test-minibuffer-3 () | 239 | (ert-deftest dabbrev-expand-test-minibuffer-3 () |
| 240 | "Test replacing an expansion in the minibuffer using two buffers. | 240 | "Test replacing an expansion in the minibuffer using two buffers. |
| 241 | The first expansion should befound in the buffer from which the | 241 | The first expansion should be found in the buffer from which the |
| 242 | minibuffer was entered, the replacement should found in another buffer." | 242 | minibuffer was entered, the replacement should found in another buffer." |
| 243 | (with-dabbrev-test | 243 | (with-dabbrev-test |
| 244 | (find-file (ert-resource-file "INSTALL_BEGIN")) | 244 | (find-file (ert-resource-file "INSTALL_BEGIN")) |
| @@ -275,4 +275,36 @@ minibuffer was entered, the replacement should found in another buffer." | |||
| 275 | (should (string= (minibuffer-contents) "Indic and")) | 275 | (should (string= (minibuffer-contents) "Indic and")) |
| 276 | (delete-minibuffer-contents)))) | 276 | (delete-minibuffer-contents)))) |
| 277 | 277 | ||
| 278 | (ert-deftest dabbrev-expand-after-killing-buffer () | ||
| 279 | "Test expansion after killing buffer containing first expansion. | ||
| 280 | Finding successive expansions in another live buffer should succeed, but | ||
| 281 | after killing the buffer, expansion should fail with a user-error." | ||
| 282 | ;; FIXME? The message shown by the user-error is in *Messages* but | ||
| 283 | ;; since the test finishes on hitting the user-error, we cannot test | ||
| 284 | ;; further, either for the content of the message or the content of | ||
| 285 | ;; the current buffer, so apparently cannot reproduce what a user | ||
| 286 | ;; entering these commands manually sees. | ||
| 287 | (with-dabbrev-test | ||
| 288 | (with-current-buffer (get-buffer-create "foo") | ||
| 289 | (insert "abc abd")) | ||
| 290 | (switch-to-buffer "*scratch*") | ||
| 291 | (erase-buffer) | ||
| 292 | (execute-kbd-macro (kbd "ab M-/")) | ||
| 293 | (should (string= (buffer-string) "abc")) | ||
| 294 | (execute-kbd-macro (kbd "SPC ab M-/")) | ||
| 295 | (should (string= (buffer-string) "abc abc")) | ||
| 296 | (erase-buffer) | ||
| 297 | (execute-kbd-macro (kbd "abc SPC ab M-/ M-/")) | ||
| 298 | (should (string= (buffer-string) "abc abd")) | ||
| 299 | (kill-buffer "foo") | ||
| 300 | (erase-buffer) | ||
| 301 | (should-error (execute-kbd-macro (kbd "abc SPC ab M-/ M-/")) | ||
| 302 | :type 'user-error) | ||
| 303 | ;; (should (string= (buffer-string) "abc abc")) | ||
| 304 | ;; (with-current-buffer "*Messages*" | ||
| 305 | ;; (goto-char (point-max)) | ||
| 306 | ;; (should (string= (buffer-substring (pos-bol) (pos-eol)) | ||
| 307 | ;; "No further dynamic expansion for ‘ab’ found"))) | ||
| 308 | )) | ||
| 309 | |||
| 278 | ;;; dabbrev-tests.el ends here | 310 | ;;; dabbrev-tests.el ends here |