aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2024-09-14 07:55:01 -0400
committerEli Zaretskii2024-09-14 07:55:01 -0400
commit0cf9886cdfb0dd3082d70cb08bd5845d8f42a813 (patch)
treeba002ead8726c12678648475a9a0823a53cd84ba
parent7eaa454283491f8397b29c9b208b1eee7706c3ea (diff)
parentd509a35699738519d42a35d72827b1111425669c (diff)
downloademacs-0cf9886cdfb0dd3082d70cb08bd5845d8f42a813.tar.gz
emacs-0cf9886cdfb0dd3082d70cb08bd5845d8f42a813.zip
Merge from origin/emacs-30
d509a356997 Fix regression in widget-move (bug#72995) ef0276de82b ; * lisp/cus-edit.el (setopt): Doc fix. (Bug#73098) b115c2d5eba ; * lisp/minibuffer.el (completion-pcm--merge-completions... 3cda1fdc3b7 Correctly include fixed strings before a prefix wildcard ... 57d93d0259a ; * lisp/treesit.el (treesit-major-mode-setup): Doc fix. ad289f364e5 ; Improve documentation of 'easy-menu-define' 3cad7cc8dc8 Set treesit-primary-parser for c and elixir ts mode 2f243fb91d6 ; Minor doc fix in treesit.el 6a6d7925c9d Fix range handling so it works for multibyte buffer (bug#... 76faf7e6091 Revert "Read more on each call to treesit's buffer reader" c70bd0e3fe9 Fix tree-sitter indent preset prev-adaptive-prefix 272df33fb8b ; * CONTRIBUTE: Minor copyedits. 8e1187e336f Improve NEWS entries ca3932121a8 Don't fail uniquify-tests in non-version-controlled sourc... 79f68597aba ; * etc/ORG-NEWS: Fix typo. d66b70f3607 * doc/misc/auth.texi: Minor copy edits. 2c6b7b2da9f ; * admin/MAINTAINERS: Remove some entries for Artur Mala... 11e7ae3964e Fix bug#72254 # Conflicts: # etc/NEWS
-rw-r--r--CONTRIBUTE5
-rw-r--r--admin/MAINTAINERS5
-rw-r--r--doc/lispref/keymaps.texi3
-rw-r--r--doc/misc/auth.texi27
-rw-r--r--etc/NEWS.3084
-rw-r--r--etc/ORG-NEWS2
-rw-r--r--lisp/cus-edit.el5
-rw-r--r--lisp/emacs-lisp/easymenu.el3
-rw-r--r--lisp/minibuffer.el15
-rw-r--r--lisp/progmodes/c-ts-mode.el3
-rw-r--r--lisp/progmodes/elixir-ts-mode.el3
-rw-r--r--lisp/treesit.el9
-rw-r--r--lisp/wid-edit.el5
-rw-r--r--src/pgtkselect.c20
-rw-r--r--src/treesit.c215
-rw-r--r--src/treesit.h23
-rw-r--r--test/lisp/minibuffer-tests.el17
-rw-r--r--test/lisp/uniquify-tests.el1
-rw-r--r--test/lisp/wid-edit-tests.el17
-rw-r--r--test/src/treesit-tests.el27
20 files changed, 316 insertions, 173 deletions
diff --git a/CONTRIBUTE b/CONTRIBUTE
index 96113d658b8..5bf555ad5fe 100644
--- a/CONTRIBUTE
+++ b/CONTRIBUTE
@@ -208,8 +208,9 @@ formatting them:
208 208
209- Unindented ChangeLog entries normally come next. However, if the 209- Unindented ChangeLog entries normally come next. However, if the
210 commit couldn't be properly summarized in the brief summary line, 210 commit couldn't be properly summarized in the brief summary line,
211 you can put a paragraph (after the empty line and before the 211 you can put one or more paragraphs (after the empty line and before
212 individual ChangeLog entries) that further describes the commit. 212 the individual ChangeLog entries) that further describe(s) the
213 commit.
213 214
214- Lines in ChangeLog entries should preferably be not longer than 63 215- Lines in ChangeLog entries should preferably be not longer than 63
215 characters, and must not exceed 78 characters, unless they consist 216 characters, and must not exceed 78 characters, unless they consist
diff --git a/admin/MAINTAINERS b/admin/MAINTAINERS
index 11a264f9ead..8930f47b35b 100644
--- a/admin/MAINTAINERS
+++ b/admin/MAINTAINERS
@@ -58,9 +58,7 @@ Bastien Guerry
58 doc/misc/org.texi 58 doc/misc/org.texi
59 59
60Artur Malabarba 60Artur Malabarba
61 lisp/emacs-lisp/package.el
62 lisp/emacs-lisp/let-alist.el 61 lisp/emacs-lisp/let-alist.el
63 lisp/character-fold.el
64 62
65Michael Albinus 63Michael Albinus
66 Tramp 64 Tramp
@@ -295,9 +293,6 @@ Stefan Monnier
295 lisp/progmodes/tcl.el 293 lisp/progmodes/tcl.el
296 lisp/emacs-lisp/easymenu.el 294 lisp/emacs-lisp/easymenu.el
297 295
298Artur Malabarba
299 lisp/isearch.el
300
301Paul Eggert 296Paul Eggert
302 .dir-locals.el 297 .dir-locals.el
303 .gitattributes 298 .gitattributes
diff --git a/doc/lispref/keymaps.texi b/doc/lispref/keymaps.texi
index c06de3a6852..2f9529a2a18 100644
--- a/doc/lispref/keymaps.texi
+++ b/doc/lispref/keymaps.texi
@@ -3243,7 +3243,8 @@ contents are given by @var{menu}.
3243 3243
3244If @var{symbol} is non-@code{nil}, it should be a symbol; then this 3244If @var{symbol} is non-@code{nil}, it should be a symbol; then this
3245macro defines @var{symbol} as a function for popping up the menu 3245macro defines @var{symbol} as a function for popping up the menu
3246(@pxref{Pop-Up Menus}), with @var{doc} as its documentation string. 3246(@pxref{Pop-Up Menus}), with @var{doc} as its documentation string. It
3247also defines @var{symbol} as a variable whose value is the menu.
3247@var{symbol} should not be quoted. 3248@var{symbol} should not be quoted.
3248 3249
3249Regardless of the value of @var{symbol}, if @var{maps} is a keymap, 3250Regardless of the value of @var{symbol}, if @var{maps} is a keymap,
diff --git a/doc/misc/auth.texi b/doc/misc/auth.texi
index bb4beb38837..17467f81941 100644
--- a/doc/misc/auth.texi
+++ b/doc/misc/auth.texi
@@ -73,7 +73,7 @@ It is a way for multiple applications to share a single configuration
73@chapter Overview 73@chapter Overview
74 74
75The auth-source library is simply a way for Emacs and Gnus, among 75The auth-source library is simply a way for Emacs and Gnus, among
76others, to answer the old burning question ``What are my user name and 76others, to answer the old burning question ``What is my user name and
77password?'' 77password?''
78 78
79(This is different from the old question about burning ``Where is the 79(This is different from the old question about burning ``Where is the
@@ -82,11 +82,11 @@ fire extinguisher, please?''.)
82The auth-source library supports more than just the user name or the 82The auth-source library supports more than just the user name or the
83password (known as the secret). 83password (known as the secret).
84 84
85Similarly, the auth-source library supports multiple storage backend, 85Similarly, the auth-source library supports multiple storage backends,
86currently either the classic ``netrc'' backend, examples of which you 86currently either the classic ``netrc'' backend, examples of which you
87can see later in this document, JSON files, the Secret Service API, and pass, the 87can see later in this document, JSON files, the Secret Service API, and
88standard unix password manager. This is done with EIEIO-based 88@samp{pass}, the standard unix password manager. This is done with
89backends and you can write your own if you want. 89EIEIO-based backends, and you can write your own if you want.
90 90
91@node Help for users 91@node Help for users
92@chapter Help for users 92@chapter Help for users
@@ -363,7 +363,7 @@ collections such as @code{"login"}.
363 363
364With GNOME Keyring, there exists a special collection called 364With GNOME Keyring, there exists a special collection called
365@code{"session"}, which has the lifetime of the user being logged in. 365@code{"session"}, which has the lifetime of the user being logged in.
366Its data are not stored on disk and go away when the user logs out. 366Its data is not stored on disk and goes away when the user logs out.
367Therefore, it can be used to store and retrieve secret items 367Therefore, it can be used to store and retrieve secret items
368temporarily. The @code{"session"} collection is better than a 368temporarily. The @code{"session"} collection is better than a
369persistent collection when the secret items should not live 369persistent collection when the secret items should not live
@@ -372,7 +372,7 @@ by the string @code{"session"}, or by @code{nil}, whenever a
372collection parameter is needed. 372collection parameter is needed.
373 373
374However, other Secret Service provider don't create this temporary 374However, other Secret Service provider don't create this temporary
375@code{"session"} collection. You shall check first that this 375@code{"session"} collection. You must check first that this
376collection exists, before you use it. 376collection exists, before you use it.
377 377
378@defun secrets-list-items collection 378@defun secrets-list-items collection
@@ -474,13 +474,13 @@ functions.
474@chapter The Unix password store 474@chapter The Unix password store
475 475
476@uref{https://www.passwordstore.org,,The standard unix password 476@uref{https://www.passwordstore.org,,The standard unix password
477manager} (or just @code{pass}) stores your passwords in 477manager} (or just @samp{pass}) stores your passwords in
478@code{gpg}-protected files following the Unix philosophy. The store 478@code{gpg}-protected files following the Unix philosophy. The store
479location (any directory) must be specified in the 479location (any directory) must be specified in the
480@code{auth-source-pass-filename} variable which defaults to 480@code{auth-source-pass-filename} variable which defaults to
481@file{~/.password-store}. 481@file{~/.password-store}.
482 482
483Emacs integration of @code{pass} follows the approach suggested by the 483Emacs integration of @samp{pass} follows the approach suggested by the
484pass project itself for data organization to find data. In 484pass project itself for data organization to find data. In
485particular, to store a password for the user @code{rms} on the host 485particular, to store a password for the user @code{rms} on the host
486@code{gnu.org} and port @code{22}, you should use one of the following 486@code{gnu.org} and port @code{22}, you should use one of the following
@@ -531,12 +531,13 @@ while searching for an entry matching the @code{rms} user on host
531However, such processing is not applied when the option 531However, such processing is not applied when the option
532@code{auth-source-pass-extra-query-keywords} is set to @code{t}. 532@code{auth-source-pass-extra-query-keywords} is set to @code{t}.
533 533
534Users of @code{pass} may also be interested in functionality provided 534Users of @samp{pass} may also be interested in functionality provided
535by other Emacs packages: 535by other Emacs packages:
536 536
537@itemize 537@itemize
538@item 538@item
539@uref{https://git.zx2c4.com/password-store/tree/contrib/emacs/password-store.el,,password-store}: library wrapping @code{pass}; 539@uref{https://git.zx2c4.com/password-store/tree/contrib/emacs/password-store.el,,password-store}:
540library wrapping @samp{pass};
540@item 541@item
541@uref{https://github.com/NicolasPetton/pass,,pass}: major mode to manipulate the store and edit entries; 542@uref{https://github.com/NicolasPetton/pass,,pass}: major mode to manipulate the store and edit entries;
542@item 543@item
@@ -585,7 +586,7 @@ The auth-source library only has a few functions for external use.
585 586
586@defun auth-source-search &rest spec &key type max host user port secret require create delete &allow-other-keys 587@defun auth-source-search &rest spec &key type max host user port secret require create delete &allow-other-keys
587This function searches (or modifies) authentication backends according 588This function searches (or modifies) authentication backends according
588to @var{spec}. See the function's doc-string for details. 589to @var{spec}. See the function's docstring for details.
589@c TODO more details. 590@c TODO more details.
590@end defun 591@end defun
591 592
@@ -635,8 +636,6 @@ authentication information we just used, if it was newly created.''
635After the first time it's called, the @code{:save-function} will not 636After the first time it's called, the @code{:save-function} will not
636run again (but it will log something if you have set 637run again (but it will log something if you have set
637@code{auth-source-debug} to @code{'trivia}). This is so it won't ask 638@code{auth-source-debug} to @code{'trivia}). This is so it won't ask
638the same question again, which is annoying. This is so it won't ask
639the same question again, which is annoying. This is so it won't ask
640the same question again, which is annoying. 639the same question again, which is annoying.
641 640
642So the responsibility of the API user that specified @code{:create t} 641So the responsibility of the API user that specified @code{:create t}
diff --git a/etc/NEWS.30 b/etc/NEWS.30
index 18d4c6b2158..9b66e67c49a 100644
--- a/etc/NEWS.30
+++ b/etc/NEWS.30
@@ -150,7 +150,7 @@ number has been bumped to 2048 bits.
150+++ 150+++
151** URL now never sends user email addresses in HTTP requests. 151** URL now never sends user email addresses in HTTP requests.
152Emacs never sent email addresses by default, but it used to be 152Emacs never sent email addresses by default, but it used to be
153possible to customize 'url-privacy-level' so that the users email 153possible to customize 'url-privacy-level' so that the user's email
154address was sent along in HTTP requests. This feature has now been 154address was sent along in HTTP requests. This feature has now been
155removed, as it was considered more dangerous than useful. RFC 9110 155removed, as it was considered more dangerous than useful. RFC 9110
156(§ 10.1.2) also recommends against it. The user option 156(§ 10.1.2) also recommends against it. The user option
@@ -670,15 +670,15 @@ that shows as diffs replacements in the marked files in Dired.
670+++ 670+++
671** New mode of prompting for register names and showing preview. 671** New mode of prompting for register names and showing preview.
672The new user option 'register-use-preview' can be customized to the 672The new user option 'register-use-preview' can be customized to the
673value t or insist to request a different user interface of prompting for 673value t or 'insist' to request a different user interface of prompting for
674register names and previewing the registers: Emacs will require 674register names and previewing the registers: Emacs will require
675confirmation for overwriting the value of a register, and will show 675confirmation for overwriting the value of a register, and will show
676the preview of registers without delay. You can also customize this 676the preview of registers without delay. You can also customize this
677new option to disable the preview completely. 677new option to disable the preview completely.
678 678
679The default value of 'register-use-preview' preserves the behavior of 679The default value of 'register-use-preview' ('traditional') preserves the
680Emacs 29 and before. See the Info node "(emacs) Registers" for more 680behavior of Emacs 29 and before. See the Info node "(emacs) Registers"
681details about the new UI and its variants. 681for more details about the new UI and its variants.
682 682
683+++ 683+++
684** New advanced macro counter commands. 684** New advanced macro counter commands.
@@ -1464,8 +1464,8 @@ bookmark URIs.
1464*** New command 'eww-copy-alternate-url'. 1464*** New command 'eww-copy-alternate-url'.
1465It copies an alternate link on the page currently visited in EWW into 1465It copies an alternate link on the page currently visited in EWW into
1466the kill ring. Alternate links are optional metadata that HTML pages 1466the kill ring. Alternate links are optional metadata that HTML pages
1467use for linking to their alternative representations, such as 1467use for linking to their alternative representations, such as translated
1468translated versions or associated RSS feeds. 1468versions or associated RSS feeds. It is bound to 'A' by default.
1469 1469
1470+++ 1470+++
1471*** 'eww-open-in-new-buffer' supports the prefix argument. 1471*** 'eww-open-in-new-buffer' supports the prefix argument.
@@ -1565,9 +1565,10 @@ following to your init file:
1565 1565
1566--- 1566---
1567*** New user option 'package-vc-register-as-project'. 1567*** New user option 'package-vc-register-as-project'.
1568When non-nil, it will automatically register every package as a 1568When non-nil, 'package-vc-install' and 'package-vc-checkout' will
1569project, that you can quickly select using 'project-switch-project' 1569automatically register every package they install as a project, that you
1570('C-x p p'). 1570can quickly select using 'project-switch-project' ('C-x p p'). Default
1571is t.
1571 1572
1572--- 1573---
1573*** New user option 'package-vc-allow-build-commands'. 1574*** New user option 'package-vc-allow-build-commands'.
@@ -1592,9 +1593,9 @@ in a clean environment.
1592 1593
1593+++ 1594+++
1594*** New user option 'flymake-indicator-type'. 1595*** New user option 'flymake-indicator-type'.
1595This user option controls which error indicator type Flymake should use 1596This controls which error indicator type Flymake should use in the
1596in current buffer. Depending on your preference, this can either use 1597current buffer. Depending on your preference, this can either use
1597fringes or margins for indicating errors. 1598fringes or margins for indicating errors, the default is 'margins'.
1598 1599
1599+++ 1600+++
1600*** New user option 'flymake-margin-indicators-string'. 1601*** New user option 'flymake-margin-indicators-string'.
@@ -1603,14 +1604,14 @@ the margin indicator.
1603 1604
1604+++ 1605+++
1605*** New user option 'flymake-autoresize-margins'. 1606*** New user option 'flymake-autoresize-margins'.
1606If non-nil, Flymake will resize the margins when 'flymake-mode' is 1607If non-nil (the default), Flymake will resize the margins when
1607turned on or off. 1608'flymake-mode' is turned on or off.
1608Only relevant if 'flymake-indicator-type' is set to 'margins'. 1609Only relevant if 'flymake-indicator-type' is set to 'margins'.
1609 1610
1610+++ 1611+++
1611*** New user option 'flymake-margin-indicator-position'. 1612*** New user option 'flymake-margin-indicator-position'.
1612It controls which margin (left or right) is used for margin 1613It controls whether to use margins for margin indicators, and which
1613indicators. 1614margin (left or right) to use. Default is to use the left margin.
1614 1615
1615+++ 1616+++
1616*** New user option 'flymake-show-diagnostics-at-end-of-line'. 1617*** New user option 'flymake-show-diagnostics-at-end-of-line'.
@@ -1618,7 +1619,7 @@ When non-nil, Flymake shows summarized descriptions of diagnostics at
1618the end of the line. Depending on your preference, this can either be 1619the end of the line. Depending on your preference, this can either be
1619distracting and easily confused with actual code, or a significant 1620distracting and easily confused with actual code, or a significant
1620early aid that relieves you from moving the buffer or reaching for the 1621early aid that relieves you from moving the buffer or reaching for the
1621mouse to consult an error message. 1622mouse to consult an error message. Default is nil.
1622 1623
1623** Flyspell 1624** Flyspell
1624 1625
@@ -1626,6 +1627,7 @@ mouse to consult an error message.
1626*** New user option 'flyspell-check-changes'. 1627*** New user option 'flyspell-check-changes'.
1627When non-nil, Flyspell mode spell-checks only words that you edited; it 1628When non-nil, Flyspell mode spell-checks only words that you edited; it
1628does not check unedited words just because you move point across them. 1629does not check unedited words just because you move point across them.
1630Default is nil.
1629 1631
1630--- 1632---
1631** JS mode. 1633** JS mode.
@@ -1647,7 +1649,7 @@ buffers contain Javascript code.
1647*** New user option 'python-indent-block-paren-deeper'. 1649*** New user option 'python-indent-block-paren-deeper'.
1648If non-nil, increase the indentation of the lines inside parens in a 1650If non-nil, increase the indentation of the lines inside parens in a
1649header of a block when they are indented to the same level as the body 1651header of a block when they are indented to the same level as the body
1650of the block: 1652of the block, producing:
1651 1653
1652 if (some_expression 1654 if (some_expression
1653 and another_expression): 1655 and another_expression):
@@ -1659,6 +1661,8 @@ instead of:
1659 and another_expression): 1661 and another_expression):
1660 do_something() 1662 do_something()
1661 1663
1664Default is nil.
1665
1662--- 1666---
1663*** New user option 'python-interpreter-args'. 1667*** New user option 'python-interpreter-args'.
1664This allows the user to specify command line arguments to the non 1668This allows the user to specify command line arguments to the non
@@ -1699,8 +1703,8 @@ This keyword enables the user to install packages using package-vc.el.
1699 1703
1700+++ 1704+++
1701*** New user option 'use-package-vc-prefer-newest'. 1705*** New user option 'use-package-vc-prefer-newest'.
1702This allows the user to always install the newest commit of a package 1706If non-nil, always install the newest commit of a package when using the
1703when using the ':vc' keyword. 1707':vc' keyword rather than its stable release. Default is nil.
1704 1708
1705** Gnus 1709** Gnus
1706 1710
@@ -1749,6 +1753,7 @@ Controls how the 'dictionary-search' command prompts for and displays
1749dictionary definitions. Customize this user option to 'help' to have 1753dictionary definitions. Customize this user option to 'help' to have
1750'dictionary-search' display definitions in a "*Help*" buffer and 1754'dictionary-search' display definitions in a "*Help*" buffer and
1751provide dictionary-based minibuffer completion for word selection. 1755provide dictionary-based minibuffer completion for word selection.
1756Default is nil, which means to use a "*Dictionary*" buffer.
1752 1757
1753--- 1758---
1754*** New user option 'dictionary-read-word-prompt'. 1759*** New user option 'dictionary-read-word-prompt'.
@@ -1971,11 +1976,11 @@ If non-nil, moving point forward or backward between widgets by typing
1971*** New user option 'ruby-rubocop-use-bundler'. 1976*** New user option 'ruby-rubocop-use-bundler'.
1972By default it retains the previous behavior: read the contents of 1977By default it retains the previous behavior: read the contents of
1973Gemfile and act accordingly. But you can also set it to t or nil to 1978Gemfile and act accordingly. But you can also set it to t or nil to
1974skip the check. 1979skip checking the Gemfile.
1975 1980
1976*** New user option 'ruby-bracketed-args-indent'. 1981*** New user option 'ruby-bracketed-args-indent'.
1977When it is set to nil, multiple consecutive open braces/brackets/parens 1982When it is set to nil, multiple consecutive open braces/brackets/parens
1978result in only one additional indentation level. 1983result in only one additional indentation level. Default is t.
1979 1984
1980** Thingatpt 1985** Thingatpt
1981 1986
@@ -2003,7 +2008,8 @@ will return the URL for that bug.
2003*** New user option 'Buffer-menu-group-by'. 2008*** New user option 'Buffer-menu-group-by'.
2004It controls how buffers are divided into groups that are displayed with 2009It controls how buffers are divided into groups that are displayed with
2005headings using Outline minor mode. Using commands that mark buffers 2010headings using Outline minor mode. Using commands that mark buffers
2006on the outline heading line will mark all buffers in the outline. 2011on the outline heading line will mark all buffers in the outline. By
2012default, no grouping is performed.
2007 2013
2008+++ 2014+++
2009*** New command 'Buffer-menu-toggle-internal'. 2015*** New command 'Buffer-menu-toggle-internal'.
@@ -2025,9 +2031,9 @@ Previously, it was set to t, but this broke remote file name detection.
2025 2031
2026--- 2032---
2027*** More control on automatic update of Proced buffers. 2033*** More control on automatic update of Proced buffers.
2028The user option 'proced-auto-update-flag' can now be set to two 2034The user option 'proced-auto-update-flag' can now be set to an
2029additional values, which control automatic updates of Proced buffers 2035additional value 'visible', which controls automatic updates of Proced
2030that are not displayed in some window. 2036buffers that are displayed in some window.
2031 2037
2032--- 2038---
2033*** nXML Mode now comes with schemas for Mono/.NET development. 2039*** nXML Mode now comes with schemas for Mono/.NET development.
@@ -2165,7 +2171,8 @@ This is a minor mode for editing regular expressions in the minibuffer,
2165for example in 'query-replace-regexp'. It correctly highlights parens 2171for example in 'query-replace-regexp'. It correctly highlights parens
2166via 'show-paren-mode' and 'blink-matching-paren' in a user-friendly way, 2172via 'show-paren-mode' and 'blink-matching-paren' in a user-friendly way,
2167avoids reporting alleged paren mismatches and makes sexp navigation more 2173avoids reporting alleged paren mismatches and makes sexp navigation more
2168intuitive. 2174intuitive. It is enabled by default, 'minibuffer-regexp-prompts' can be
2175used to tune when it takes effect.
2169 2176
2170--- 2177---
2171** The highly accessible Modus themes collection has eight items. 2178** The highly accessible Modus themes collection has eight items.
@@ -2291,7 +2298,7 @@ unibyte string.
2291buffer-local value from the minibuffer. 2298buffer-local value from the minibuffer.
2292 2299
2293+++ 2300+++
2294** 'minibuffer-allow-text-properties' also affects completions. 2301** 'minibuffer-allow-text-properties' now also affects completions.
2295When it has a non-nil value, then completion functions like 2302When it has a non-nil value, then completion functions like
2296'completing-read' don't discard text properties from the returned 2303'completing-read' don't discard text properties from the returned
2297completion candidate. 2304completion candidate.
@@ -2321,7 +2328,7 @@ values.
2321 2328
2322--- 2329---
2323** User option 'tramp-completion-reread-directory-timeout' has been removed. 2330** User option 'tramp-completion-reread-directory-timeout' has been removed.
2324This user option has been obsoleted in Emacs 27, use 2331This user option was obsoleted in Emacs 27, use
2325'remote-file-name-inhibit-cache' instead. 2332'remote-file-name-inhibit-cache' instead.
2326 2333
2327+++ 2334+++
@@ -2497,7 +2504,7 @@ where arguments after the first are keyword/value pairs, all optional:
2497':key' specifies a function that produces the sorting key from an element, 2504':key' specifies a function that produces the sorting key from an element,
2498':lessp' specifies the ordering predicate, defaulting to 'value<', 2505':lessp' specifies the ordering predicate, defaulting to 'value<',
2499':reverse' is used to reverse the sorting order, 2506':reverse' is used to reverse the sorting order,
2500':in-place is used for in-place sorting, as the default is now to 2507':in-place' is used for in-place sorting, as the default is now to
2501sort a copy of the input. 2508sort a copy of the input.
2502 2509
2503The new signature is less error-prone and reduces the need to write 2510The new signature is less error-prone and reduces the need to write
@@ -2574,7 +2581,8 @@ analogous to 'w32-notification-notify'.
2574** New Haiku specific variable 'haiku-pass-control-tab-to-system'. 2581** New Haiku specific variable 'haiku-pass-control-tab-to-system'.
2575This sets whether Emacs should pass 'C-TAB' on to the system instead of 2582This sets whether Emacs should pass 'C-TAB' on to the system instead of
2576handling it, fixing a problem where window switching would not activate 2583handling it, fixing a problem where window switching would not activate
2577if an Emacs frame had focus on the Haiku operating system. 2584if an Emacs frame had focus on the Haiku operating system. Default
2585value is t.
2578 2586
2579+++ 2587+++
2580** New value 'if-regular' for the REPLACE argument to 'insert-file-contents'. 2588** New value 'if-regular' for the REPLACE argument to 'insert-file-contents'.
@@ -2956,9 +2964,9 @@ default to use 'LANGUAGE'.
2956 2964
2957--- 2965---
2958** New optional argument to 'modify-dir-local-variable'. 2966** New optional argument to 'modify-dir-local-variable'.
2959A 5th argument, optional, has been added to 2967An optional 5th argument FILE has been added to
2960'modify-dir-local-variable'. It can be used to specify which 2968'modify-dir-local-variable'. It can be used to specify which file to
2961dir-locals file to modify. 2969modify instead of the default ".dir-locals.el".
2962 2970
2963** Connection local variables 2971** Connection local variables
2964 2972
@@ -3012,13 +3020,13 @@ They pertained to the internal storage size which is now irrelevant.
3012** 'treesit-install-language-grammar' can handle local directory instead of URL. 3020** 'treesit-install-language-grammar' can handle local directory instead of URL.
3013It is now possible to pass a directory of a local repository as URL 3021It is now possible to pass a directory of a local repository as URL
3014inside 'treesit-language-source-alist', so that calling 3022inside 'treesit-language-source-alist', so that calling
3015'treesit-install-language-grammar' would avoid cloning the repository. 3023'treesit-install-language-grammar' will avoid cloning the repository.
3016It may be useful, for example, for the purposes of bisecting a 3024It may be useful, for example, for the purposes of bisecting a
3017treesitter grammar. 3025treesitter grammar.
3018 3026
3019+++
3020** New buffer-local variable 'tabulated-list-groups'. 3027** New buffer-local variable 'tabulated-list-groups'.
3021It controls display and separate sorting of groups of entries. 3028It controls display and separate sorting of groups of entries. By
3029default no grouping or sorting is done.
3022 3030
3023+++ 3031+++
3024** New variable 'revert-buffer-restore-functions'. 3032** New variable 'revert-buffer-restore-functions'.
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index eeab970e3e1..bb8d5d32065 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -286,7 +286,7 @@ when ~org-yank-dnd-method~ is =attach=.
286 286
287*** Alignment of image previews can be customized 287*** Alignment of image previews can be customized
288 288
289Previously, all the image previews where always left-aligned. 289Previously, all the image previews were always left-aligned.
290 290
291Now, you can customize image previews to be left-aligned, centered, or right-aligned. 291Now, you can customize image previews to be left-aligned, centered, or right-aligned.
292 292
diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el
index 3ab5f11532e..b25dbad5919 100644
--- a/lisp/cus-edit.el
+++ b/lisp/cus-edit.el
@@ -1053,6 +1053,11 @@ This is like `setq', but is meant for user options instead of
1053plain variables. This means that `setopt' will execute any 1053plain variables. This means that `setopt' will execute any
1054`custom-set' form associated with VARIABLE. 1054`custom-set' form associated with VARIABLE.
1055 1055
1056Note that `setopt' will emit a warning if the type of a VALUE
1057does not match the type of the corresponding VARIABLE as
1058declared by `defcustom'. (VARIABLE will be assigned the value
1059even if it doesn't match the type.)
1060
1056\(fn [VARIABLE VALUE]...)" 1061\(fn [VARIABLE VALUE]...)"
1057 (declare (debug setq)) 1062 (declare (debug setq))
1058 (unless (zerop (mod (length pairs) 2)) 1063 (unless (zerop (mod (length pairs) 2))
diff --git a/lisp/emacs-lisp/easymenu.el b/lisp/emacs-lisp/easymenu.el
index 6740c2af58d..0a273ef0f7c 100644
--- a/lisp/emacs-lisp/easymenu.el
+++ b/lisp/emacs-lisp/easymenu.el
@@ -38,7 +38,8 @@
38(defmacro easy-menu-define (symbol maps doc menu) 38(defmacro easy-menu-define (symbol maps doc menu)
39 "Define a pop-up menu and/or menu bar menu specified by MENU. 39 "Define a pop-up menu and/or menu bar menu specified by MENU.
40If SYMBOL is non-nil, define SYMBOL as a function to pop up the 40If SYMBOL is non-nil, define SYMBOL as a function to pop up the
41submenu defined by MENU, with DOC as its doc string. 41submenu defined by MENU, with DOC as its doc string. Also define
42SYMBOL as a variable whose value is the menu.
42 43
43MAPS, if non-nil, should be a keymap or a list of keymaps; add 44MAPS, if non-nil, should be a keymap or a list of keymaps; add
44the submenu defined by MENU to the keymap or each of the keymaps, 45the submenu defined by MENU to the keymap or each of the keymaps,
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index cd59b108a7e..804afe9cb43 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -4420,18 +4420,21 @@ the same set of elements."
4420 (unique (or (and (eq prefix t) (setq prefix fixed)) 4420 (unique (or (and (eq prefix t) (setq prefix fixed))
4421 (and (stringp prefix) 4421 (and (stringp prefix)
4422 (eq t (try-completion prefix comps)))))) 4422 (eq t (try-completion prefix comps))))))
4423 ;; if the common prefix is unique, it also is a common
4424 ;; suffix, so we should add it for `prefix' elements
4425 (unless (or (and (eq elem 'prefix) (not unique))
4426 (equal prefix ""))
4427 (push prefix res))
4428 ;; If there's only one completion, `elem' is not useful 4423 ;; If there's only one completion, `elem' is not useful
4429 ;; any more: it can only match the empty string. 4424 ;; any more: it can only match the empty string.
4430 ;; FIXME: in some cases, it may be necessary to turn an 4425 ;; FIXME: in some cases, it may be necessary to turn an
4431 ;; `any' into a `star' because the surrounding context has 4426 ;; `any' into a `star' because the surrounding context has
4432 ;; changed such that string->pattern wouldn't add an `any' 4427 ;; changed such that string->pattern wouldn't add an `any'
4433 ;; here any more. 4428 ;; here any more.
4434 (unless unique 4429 (if unique
4430 ;; If the common prefix is unique, it also is a common
4431 ;; suffix, so we should add it for `prefix' elements.
4432 (push prefix res)
4433 ;; `prefix' only wants to include the fixed part before the
4434 ;; wildcard, not the result of growing that fixed part.
4435 (when (eq elem 'prefix)
4436 (setq prefix fixed))
4437 (push prefix res)
4435 (push elem res) 4438 (push elem res)
4436 ;; Extract common suffix additionally to common prefix. 4439 ;; Extract common suffix additionally to common prefix.
4437 ;; Don't do it for `any' since it could lead to a merged 4440 ;; Don't do it for `any' since it could lead to a merged
diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index 7f23b30a88a..26b352874c2 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -1325,7 +1325,8 @@ in your init files."
1325 ;; Create an "for-each" parser, see `c-ts-mode--emacs-set-ranges' 1325 ;; Create an "for-each" parser, see `c-ts-mode--emacs-set-ranges'
1326 ;; for more. 1326 ;; for more.
1327 (when c-ts-mode-emacs-sources-support 1327 (when c-ts-mode-emacs-sources-support
1328 (treesit-parser-create 'c nil nil 'for-each)) 1328 (setq-local treesit-primary-parser
1329 (treesit-parser-create 'c nil nil 'for-each)))
1329 1330
1330 (let ((primary-parser (treesit-parser-create 'c))) 1331 (let ((primary-parser (treesit-parser-create 'c)))
1331 ;; Comments. 1332 ;; Comments.
diff --git a/lisp/progmodes/elixir-ts-mode.el b/lisp/progmodes/elixir-ts-mode.el
index 815827ed13c..a3e11658468 100644
--- a/lisp/progmodes/elixir-ts-mode.el
+++ b/lisp/progmodes/elixir-ts-mode.el
@@ -701,7 +701,8 @@ Return nil if NODE is not a defun node or doesn't have a name."
701 (require 'heex-ts-mode) 701 (require 'heex-ts-mode)
702 (treesit-parser-create 'heex)) 702 (treesit-parser-create 'heex))
703 703
704 (treesit-parser-create 'elixir) 704 (setq-local treesit-primary-parser
705 (treesit-parser-create 'elixir))
705 706
706 (setq-local treesit-language-at-point-function 707 (setq-local treesit-language-at-point-function
707 'elixir-ts--treesit-language-at-point) 708 'elixir-ts--treesit-language-at-point)
diff --git a/lisp/treesit.el b/lisp/treesit.el
index 234ef9159de..8773b31c83f 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -1636,7 +1636,7 @@ See `treesit-simple-indent-presets'.")
1636 1636
1637 (goto-char bol) 1637 (goto-char bol)
1638 (setq this-line-has-prefix 1638 (setq this-line-has-prefix
1639 (and (looking-at-p adaptive-fill-regexp) 1639 (and (looking-at adaptive-fill-regexp)
1640 (not (string-match-p 1640 (not (string-match-p
1641 (rx bos (* whitespace) eos) 1641 (rx bos (* whitespace) eos)
1642 (match-string 0))))) 1642 (match-string 0)))))
@@ -2938,7 +2938,8 @@ when a major mode sets it.")
2938 2938
2939(defun treesit-outline-search (&optional bound move backward looking-at) 2939(defun treesit-outline-search (&optional bound move backward looking-at)
2940 "Search for the next outline heading in the syntax tree. 2940 "Search for the next outline heading in the syntax tree.
2941See the descriptions of arguments in `outline-search-function'." 2941For BOUND, MOVE, BACKWARD, LOOKING-AT, see the descriptions in
2942`outline-search-function'."
2942 (if looking-at 2943 (if looking-at
2943 (when-let* ((node (or (treesit-thing-at (pos-eol) treesit-outline-predicate) 2944 (when-let* ((node (or (treesit-thing-at (pos-eol) treesit-outline-predicate)
2944 (treesit-thing-at (pos-bol) treesit-outline-predicate))) 2945 (treesit-thing-at (pos-bol) treesit-outline-predicate)))
@@ -3047,6 +3048,10 @@ If `treesit-defun-name-function' is non-nil, set up
3047 3048
3048If `treesit-simple-imenu-settings' is non-nil, set up Imenu. 3049If `treesit-simple-imenu-settings' is non-nil, set up Imenu.
3049 3050
3051If either `treesit-outline-predicate' or `treesit-simple-imenu-settings'
3052are non-nil, and Outline minor mode settings don't alreay exist, setup
3053Outline minor mode.
3054
3050If `sexp', `sentence' are defined in `treesit-thing-settings', 3055If `sexp', `sentence' are defined in `treesit-thing-settings',
3051enable tree-sitter navigation commands for them. 3056enable tree-sitter navigation commands for them.
3052 3057
diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
index 05c3f412bf6..1d47f80b0dd 100644
--- a/lisp/wid-edit.el
+++ b/lisp/wid-edit.el
@@ -1336,7 +1336,10 @@ nothing is shown in the echo area."
1336 (let ((new (widget-tabable-at))) 1336 (let ((new (widget-tabable-at)))
1337 (while (and (eq (widget-tabable-at) new) (not (bobp))) 1337 (while (and (eq (widget-tabable-at) new) (not (bobp)))
1338 (backward-char))) 1338 (backward-char)))
1339 (unless (bobp) (forward-char))) 1339 ;; If the widget is at BOB, point is already at the widget's
1340 ;; starting position; otherwise, advance point to put it at the
1341 ;; start of the widget (cf. bug#69943 and bug#72995).
1342 (unless (and (widget-tabable-at) (bobp)) (forward-char)))
1340 (unless suppress-echo 1343 (unless suppress-echo
1341 (widget-echo-help (point))) 1344 (widget-echo-help (point)))
1342 (run-hooks 'widget-move-hook)) 1345 (run-hooks 'widget-move-hook))
diff --git a/src/pgtkselect.c b/src/pgtkselect.c
index c9f117126b2..dede89facb1 100644
--- a/src/pgtkselect.c
+++ b/src/pgtkselect.c
@@ -1644,10 +1644,24 @@ frame's display, or the first available X display. */)
1644 1644
1645 if (NILP (val) && FRAME_LIVE_P (f)) 1645 if (NILP (val) && FRAME_LIVE_P (f))
1646 { 1646 {
1647 Lisp_Object frame; 1647 Lisp_Object frame, val;
1648 XSETFRAME (frame, f); 1648 XSETFRAME (frame, f);
1649 return pgtk_get_foreign_selection (selection_symbol, target_type, 1649
1650 time_stamp, frame); 1650 val = pgtk_get_foreign_selection (selection_symbol, target_type,
1651 time_stamp, frame);
1652
1653 /* A window property holding just one item is indistinguishable
1654 from an array of one element, and is always decoded as the
1655 former, producing issues with programs that expect the TARGETS
1656 property always to return vectors, even when the toolkit
1657 reports just one data type. Though X sidesteps this ambiguity
1658 by defining TARGETS as returning at least two properties
1659 TARGETS and MULTIPLE, GTK knows no such scruples, and therefore
1660 symbol values (or nil) should be enclosed in vectors when
1661 TARGETS is being requested. (bug#72254) */
1662 if (EQ (target_type, QTARGETS) && (NILP (val) || SYMBOLP (val)))
1663 val = make_vector (NILP (val) ? 0 : 1, val);
1664 return val;
1651 } 1665 }
1652 1666
1653 if (CONSP (val) && SYMBOLP (XCAR (val))) 1667 if (CONSP (val) && SYMBOLP (XCAR (val)))
diff --git a/src/treesit.c b/src/treesit.c
index 8c586109b2d..3790f5046c1 100644
--- a/src/treesit.c
+++ b/src/treesit.c
@@ -504,7 +504,7 @@ treesit_debug_print_parser_list (char *msg, Lisp_Object parser)
504 SSDATA (SYMBOL_NAME (Vthis_command)), 504 SSDATA (SYMBOL_NAME (Vthis_command)),
505 SSDATA (SYMBOL_NAME (XTS_PARSER (parser)->language_symbol)), 505 SSDATA (SYMBOL_NAME (XTS_PARSER (parser)->language_symbol)),
506 buf_name, BUF_BEG (buf), 506 buf_name, BUF_BEG (buf),
507 BUF_BEGV (buf), BUF_Z (buf), BUF_ZV (buf)); 507 BUF_BEGV (buf), BUF_ZV (buf), BUF_Z (buf));
508 Lisp_Object tail = BVAR (buf, ts_parser_list); 508 Lisp_Object tail = BVAR (buf, ts_parser_list);
509 509
510 FOR_EACH_TAIL (tail) 510 FOR_EACH_TAIL (tail)
@@ -968,6 +968,9 @@ treesit_record_change (ptrdiff_t start_byte, ptrdiff_t old_end_byte,
968 } 968 }
969} 969}
970 970
971static TSRange *treesit_make_ts_ranges (Lisp_Object, Lisp_Object,
972 uint32_t *);
973
971/* Comment (ref:visible-beg-null) The purpose of visible_beg/end is to 974/* Comment (ref:visible-beg-null) The purpose of visible_beg/end is to
972 keep track of "which part of the buffer does the tree-sitter tree 975 keep track of "which part of the buffer does the tree-sitter tree
973 see", in order to update the tree correctly. Visible_beg/end have 976 see", in order to update the tree correctly. Visible_beg/end have
@@ -1096,48 +1099,85 @@ treesit_sync_visible_region (Lisp_Object parser)
1096 XTS_PARSER (parser)->visible_end = visible_end; 1099 XTS_PARSER (parser)->visible_end = visible_end;
1097 1100
1098 /* Fix ranges so that the ranges stays with in visible_end. Here we 1101 /* Fix ranges so that the ranges stays with in visible_end. Here we
1099 try to do minimal work so that the ranges is minimally correct such 1102 try to do minimal work so that the ranges is minimally correct and
1100 that there's no OOB error. Usually treesit-update-ranges should 1103 there's no OOB error. Usually treesit-update-ranges should update
1101 update the parser with actually correct ranges. */ 1104 the parser with semantically correct ranges.
1102 if (NILP (XTS_PARSER (parser)->last_set_ranges)) return; 1105
1103 uint32_t len; 1106 We start with the charpos ranges, because for bytepos ranges, after
1104 const TSRange *ranges 1107 user edits, the ranges start/end might end up inside a multibyte
1105 = ts_parser_included_ranges (XTS_PARSER (parser)->parser, &len); 1108 char! See (ref:bytepos-range-pitfall) below. */
1106 /* We might need to discard some ranges that exceeds visible_end, in 1109 Lisp_Object lisp_ranges = XTS_PARSER (parser)->last_set_ranges;
1107 that case, new_len is the length of the new ranges array (which 1110 if (NILP (lisp_ranges)) return;
1108 will be shorter than len). */ 1111
1109 uint32_t new_len = 0; 1112 Lisp_Object new_ranges_head = lisp_ranges;
1110 uint32_t new_end = 0; 1113
1111 for (int idx = 0; idx < len; idx++) 1114 FOR_EACH_TAIL_SAFE (lisp_ranges)
1112 { 1115 {
1113 TSRange range = ranges[idx]; 1116 Lisp_Object range = XCAR (lisp_ranges);
1114 /* If this range starts after visible_end, we don't include this 1117 ptrdiff_t beg = XFIXNUM (XCAR (range));
1115 range and the ranges after it in the new ranges. */ 1118 ptrdiff_t end = XFIXNUM (XCDR (range));
1116 if (range.start_byte + visible_beg >= visible_end) 1119
1120 if (end <= visible_beg)
1121 /* Even the end is before visible_beg, discard this range. */
1122 new_ranges_head = XCDR (new_ranges_head);
1123 else if (beg >= visible_end)
1124 {
1125 /* Even the beg is after visible_end, dicard this range and all
1126 the ranges after it. */
1127 XSETCDR (range, Qnil);
1117 break; 1128 break;
1118 /* If this range's end is after visible_end, we don't include any 1129 }
1119 ranges after it, and changes the end of this range to 1130 else
1120 visible_end. */ 1131 {
1121 if (range.end_byte + visible_beg > visible_end) 1132 /* At this point, the range overlaps with the visible portion of
1122 { 1133 the buffer in some way (in front / in back / completely
1123 new_end = visible_end - visible_beg; 1134 encased / completely encases). */
1124 new_len++; 1135 if (beg < visible_beg)
1125 break; 1136 XSETCAR (range, make_fixnum (visible_beg));
1126 } 1137 if (end > visible_end)
1127 new_len++; 1138 XSETCDR (range, make_fixnum (visible_end));
1139 }
1140 }
1141
1142 XTS_PARSER (parser)->last_set_ranges = new_ranges_head;
1143
1144 if (NILP (new_ranges_head))
1145 {
1146 bool success;
1147 success = ts_parser_set_included_ranges (XTS_PARSER (parser)->parser,
1148 NULL, 0);
1149 eassert (success);
1128 } 1150 }
1129 if (new_len != len || new_end != 0) 1151 else
1130 { 1152 {
1131 TSRange *new_ranges = xmalloc (sizeof (TSRange) * new_len); 1153 uint32_t len = 0;
1132 memcpy (new_ranges, ranges, sizeof (TSRange) * new_len); 1154 TSRange *ts_ranges = treesit_make_ts_ranges (new_ranges_head, parser,
1133 new_ranges[new_len - 1].end_byte = new_end; 1155 &len);
1134 /* TODO: What should we do if this fails? */ 1156 bool success;
1135 ts_parser_set_included_ranges (XTS_PARSER (parser)->parser, 1157 success = ts_parser_set_included_ranges (XTS_PARSER (parser)->parser,
1136 new_ranges, new_len); 1158 ts_ranges, len);
1137 xfree (new_ranges); 1159 xfree (ts_ranges);
1160 eassert (success);
1138 } 1161 }
1139} 1162}
1140 1163
1164/* (ref:bytepos-range-pitfall) Suppose we have the following buffer
1165 content ([ ] is a unibyte char, [ ] is a multibyte char):
1166
1167 [a][b][c][d][e][ f ]
1168
1169 and the following ranges (denoted by braces):
1170
1171 [a][b][c][d][e][ f ]
1172 { }{ }
1173
1174 So far so good, now user deletes a unibyte char at the beginning:
1175
1176 [b][c][d][e][ f ]
1177 { }{ }
1178
1179 Oops, now our range cuts into the multibyte char, bad! */
1180
1141static void 1181static void
1142treesit_check_buffer_size (struct buffer *buffer) 1182treesit_check_buffer_size (struct buffer *buffer)
1143{ 1183{
@@ -1274,13 +1314,16 @@ treesit_read_buffer (void *parser, uint32_t byte_index,
1274 beg = NULL; 1314 beg = NULL;
1275 len = 0; 1315 len = 0;
1276 } 1316 }
1277 /* Normal case, read until the gap or visible end. */ 1317 /* Normal case, read a character. We can't give tree-sitter the
1318 whole buffer range because we move the gap around, realloc the
1319 buffer, etc; and there's no way to invalidate the previously
1320 given range in tree-sitter. Move over, benchmark shows there's
1321 very little difference between passing a whole chunk vs passing a
1322 single char at once. The only cost is funcall I guess. */
1278 else 1323 else
1279 { 1324 {
1280 beg = (char *) BUF_BYTE_ADDRESS (buffer, byte_pos); 1325 beg = (char *) BUF_BYTE_ADDRESS (buffer, byte_pos);
1281 ptrdiff_t gap_bytepos = BUF_GPT_BYTE (buffer); 1326 len = BYTES_BY_CHAR_HEAD ((int) *beg);
1282 len = (byte_pos < gap_bytepos)
1283 ? gap_bytepos - byte_pos : visible_end - byte_pos;
1284 } 1327 }
1285 /* We never let tree-sitter to parse buffers that large so this 1328 /* We never let tree-sitter to parse buffers that large so this
1286 assertion should never hit. */ 1329 assertion should never hit. */
@@ -1831,6 +1874,48 @@ treesit_make_ranges (const TSRange *ranges, uint32_t len,
1831 return Fnreverse (list); 1874 return Fnreverse (list);
1832} 1875}
1833 1876
1877/* Convert lisp ranges to tree-sitter ranges. Set LEN to the length of
1878 the ranges. RANGES must be a valid ranges list, (cons of numbers, no
1879 overlap, etc). PARSER must be a parser. This function doesn't check
1880 for types. Caller must free the returned ranges. */
1881static TSRange *
1882treesit_make_ts_ranges (Lisp_Object ranges, Lisp_Object parser, uint32_t *len)
1883{
1884 ptrdiff_t ranges_len = list_length (ranges);
1885 if (ranges_len > UINT32_MAX)
1886 xsignal (Qargs_out_of_range, list2 (ranges, Flength (ranges)));
1887
1888 *len = (uint32_t) ranges_len;
1889 TSRange *treesit_ranges = xmalloc (sizeof (TSRange) * ranges_len);
1890
1891 struct buffer *buffer = XBUFFER (XTS_PARSER (parser)->buffer);
1892
1893 for (int idx = 0; idx < ranges_len; idx++, ranges = XCDR (ranges))
1894 {
1895 Lisp_Object range = XCAR (ranges);
1896 ptrdiff_t beg_byte = buf_charpos_to_bytepos (buffer,
1897 XFIXNUM (XCAR (range)));
1898 ptrdiff_t end_byte = buf_charpos_to_bytepos (buffer,
1899 XFIXNUM (XCDR (range)));
1900
1901 /* Shouldn't violate assertion since we just checked for
1902 buffer size at the beginning of this function. */
1903 eassert (beg_byte - BUF_BEGV_BYTE (buffer) <= UINT32_MAX);
1904 eassert (end_byte - BUF_BEGV_BYTE (buffer) <= UINT32_MAX);
1905
1906 /* We don't care about points, put in dummy values. */
1907 TSRange rg =
1908 {
1909 {0, 0}, {0, 0},
1910 (uint32_t) beg_byte - XTS_PARSER (parser)->visible_beg,
1911 (uint32_t) end_byte - XTS_PARSER (parser)->visible_beg
1912 };
1913 treesit_ranges[idx] = rg;
1914 }
1915
1916 return treesit_ranges;
1917}
1918
1834DEFUN ("treesit-parser-set-included-ranges", 1919DEFUN ("treesit-parser-set-included-ranges",
1835 Ftreesit_parser_set_included_ranges, 1920 Ftreesit_parser_set_included_ranges,
1836 Streesit_parser_set_included_ranges, 1921 Streesit_parser_set_included_ranges,
@@ -1870,33 +1955,8 @@ buffer. */)
1870 } 1955 }
1871 else 1956 else
1872 { 1957 {
1873 /* Set ranges for PARSER. */ 1958 uint32_t len = 0;
1874 if (list_length (ranges) > UINT32_MAX) 1959 TSRange *treesit_ranges = treesit_make_ts_ranges (ranges, parser, &len);
1875 xsignal (Qargs_out_of_range, list2 (ranges, Flength (ranges)));
1876 uint32_t len = (uint32_t) list_length (ranges);
1877 TSRange *treesit_ranges = xmalloc (sizeof (TSRange) * len);
1878 struct buffer *buffer = XBUFFER (XTS_PARSER (parser)->buffer);
1879
1880 /* We can use XFIXNUM, XCAR, XCDR freely because we have checked
1881 the input by treesit_check_range_argument. */
1882 for (int idx = 0; !NILP (ranges); idx++, ranges = XCDR (ranges))
1883 {
1884 Lisp_Object range = XCAR (ranges);
1885 ptrdiff_t beg_byte = buf_charpos_to_bytepos (buffer,
1886 XFIXNUM (XCAR (range)));
1887 ptrdiff_t end_byte = buf_charpos_to_bytepos (buffer,
1888 XFIXNUM (XCDR (range)));
1889 /* Shouldn't violate assertion since we just checked for
1890 buffer size at the beginning of this function. */
1891 eassert (beg_byte - BUF_BEGV_BYTE (buffer) <= UINT32_MAX);
1892 eassert (end_byte - BUF_BEGV_BYTE (buffer) <= UINT32_MAX);
1893 /* We don't care about start and end points, put in dummy
1894 values. */
1895 TSRange rg = {{0, 0}, {0, 0},
1896 (uint32_t) beg_byte - BUF_BEGV_BYTE (buffer),
1897 (uint32_t) end_byte - BUF_BEGV_BYTE (buffer)};
1898 treesit_ranges[idx] = rg;
1899 }
1900 success = ts_parser_set_included_ranges (XTS_PARSER (parser)->parser, 1960 success = ts_parser_set_included_ranges (XTS_PARSER (parser)->parser,
1901 treesit_ranges, len); 1961 treesit_ranges, len);
1902 xfree (treesit_ranges); 1962 xfree (treesit_ranges);
@@ -1923,26 +1983,9 @@ See also `treesit-parser-set-included-ranges'. */)
1923 treesit_check_parser (parser); 1983 treesit_check_parser (parser);
1924 treesit_initialize (); 1984 treesit_initialize ();
1925 1985
1926 /* Our return value depends on the buffer state (BUF_BEGV_BYTE,
1927 etc), so we need to sync up. */
1928 treesit_check_buffer_size (XBUFFER (XTS_PARSER (parser)->buffer));
1929 treesit_sync_visible_region (parser); 1986 treesit_sync_visible_region (parser);
1930 /* When the parser doesn't have a range set and we call
1931 ts_parser_included_ranges on it, it doesn't return an empty list,
1932 but rather return DEFAULT_RANGE. (A single range where start_byte
1933 = 0, end_byte = UINT32_MAX). So we need to track whether the
1934 parser is ranged ourselves. */
1935 if (NILP (XTS_PARSER (parser)->last_set_ranges))
1936 return Qnil;
1937
1938 uint32_t len;
1939 const TSRange *ranges
1940 = ts_parser_included_ranges (XTS_PARSER (parser)->parser, &len);
1941
1942 struct buffer *buffer = XBUFFER (XTS_PARSER (parser)->buffer);
1943
1944 1987
1945 return treesit_make_ranges (ranges, len, parser, buffer); 1988 return XTS_PARSER (parser)->last_set_ranges;
1946} 1989}
1947 1990
1948DEFUN ("treesit-parser-notifiers", Ftreesit_parser_notifiers, 1991DEFUN ("treesit-parser-notifiers", Ftreesit_parser_notifiers,
diff --git a/src/treesit.h b/src/treesit.h
index 14ffd553712..b90f9134542 100644
--- a/src/treesit.h
+++ b/src/treesit.h
@@ -45,12 +45,23 @@ struct Lisp_TS_Parser
45 same tag. A tag is primarily used to differentiate between 45 same tag. A tag is primarily used to differentiate between
46 parsers for the same language. */ 46 parsers for the same language. */
47 Lisp_Object tag; 47 Lisp_Object tag;
48 /* The Lisp ranges last set. This is use to compare to the new ranges 48 /* The Lisp ranges last set. One purpose for it is to compare to the
49 the users wants to set, and avoid reparse if the new ranges is the 49 new ranges the users wants to set, and avoid reparse if the new
50 same as the last set one. This might go out of sync with the 50 ranges is the same as the current one. Another purpose is to store
51 ranges we return from Ftreesit_parser_included_ranges, if we did a 51 the ranges in charpos (ts api returns ranges in bytepos). We need
52 ranges fix in treesit_sync_visible_region, but I don't think 52 to use charpos so we don't end up having a range cut into a
53 that'll cause any harm. */ 53 multibyte character. (See (ref:bytepos-range-pitfall) in treesit.c
54 for more detail.)
55
56 treesit-parser-set-included-ranges sets this field;
57 treesit-parser-included-ranges directly returns this field, and
58 before each reparse, treesit_sync_visible_region uses this to
59 calculate a range for the parser that fits in the visible region.
60
61 Trivia: when the parser doesn't have a range set and we call
62 ts_parser_included_ranges on it, it doesn't return an empty list,
63 but rather return DEFAULT_RANGE. (A single range where start_byte
64 = 0, end_byte = UINT32_MAX). */
54 Lisp_Object last_set_ranges; 65 Lisp_Object last_set_ranges;
55 /* The buffer associated with this parser. */ 66 /* The buffer associated with this parser. */
56 Lisp_Object buffer; 67 Lisp_Object buffer;
diff --git a/test/lisp/minibuffer-tests.el b/test/lisp/minibuffer-tests.el
index df36bce4634..38c2b8c4552 100644
--- a/test/lisp/minibuffer-tests.el
+++ b/test/lisp/minibuffer-tests.el
@@ -306,13 +306,20 @@
306 6))) 306 6)))
307 307
308(ert-deftest completion-substring-test-5 () 308(ert-deftest completion-substring-test-5 ()
309 ;; merge-completions needs to work correctly when 309 ;; Normally a `prefix' wildcard ignores the common prefix to its
310 ;; left, since it only grows the common suffix; but if that common
311 ;; prefix is also a common suffix, it should be included.
310 (should (equal 312 (should (equal
311 (completion-pcm--merge-completions '("ab" "sab") '(prefix "b")) 313 (completion-pcm--merge-try '(prefix "b") '("ab" "sab") "" "")
312 '("b" "a" prefix))) 314 '("ab" . 2)))
313 (should (equal 315 (should (equal
314 (completion-pcm--merge-completions '("ab" "ab") '(prefix "b")) 316 (completion-pcm--merge-try '(prefix "b") '("ab" "ab") "" "")
315 '("b" "a"))) 317 '("ab" . 2)))
318 ;; When there's a fixed string before `prefix', that fixed string
319 ;; should always be included.
320 (should (equal
321 (completion-pcm--merge-try '("a" prefix "b") '("axb" "ayb") "" "")
322 '("ab" . 2)))
316 ;; substring completion should successfully complete the entire string 323 ;; substring completion should successfully complete the entire string
317 (should (equal 324 (should (equal
318 (completion-substring-try-completion "b" '("ab" "ab") nil 0) 325 (completion-substring-try-completion "b" '("ab" "ab") nil 0)
diff --git a/test/lisp/uniquify-tests.el b/test/lisp/uniquify-tests.el
index 4124ce056d3..9b33c9d7d47 100644
--- a/test/lisp/uniquify-tests.el
+++ b/test/lisp/uniquify-tests.el
@@ -129,6 +129,7 @@ uniquify-trailing-separator-p is ignored"
129(require 'project) 129(require 'project)
130(ert-deftest uniquify-project-transform () 130(ert-deftest uniquify-project-transform ()
131 "`project-uniquify-dirname-transform' works" 131 "`project-uniquify-dirname-transform' works"
132 (skip-unless (project-current nil source-directory))
132 (let ((uniquify-dirname-transform #'project-uniquify-dirname-transform) 133 (let ((uniquify-dirname-transform #'project-uniquify-dirname-transform)
133 (project-vc-name "foo1/bar") 134 (project-vc-name "foo1/bar")
134 bufs) 135 bufs)
diff --git a/test/lisp/wid-edit-tests.el b/test/lisp/wid-edit-tests.el
index d416eb99022..03e7e5a7b7d 100644
--- a/test/lisp/wid-edit-tests.el
+++ b/test/lisp/wid-edit-tests.el
@@ -344,6 +344,23 @@ return nil, even with a non-nil bubblep argument."
344 (should (string= "Third" (widget-value (widget-at)))) 344 (should (string= "Third" (widget-value (widget-at))))
345 (widget-forward 1))) ; Should not signal beginning-of-buffer error. 345 (widget-forward 1))) ; Should not signal beginning-of-buffer error.
346 346
347(ert-deftest widget-test-widget-move-bug72995 ()
348 "Test moving to a widget that starts at buffer position 2."
349 (with-temp-buffer
350 ;; The first tabable widget begins at position 2 (bug#72995).
351 (widget-insert " ")
352 (dolist (el '("First" "Second" "Third"))
353 (widget-create 'push-button el))
354 (widget-insert "\n")
355 (use-local-map widget-keymap)
356 (widget-setup)
357 ;; Make sure there is no tabable widget at BOB.
358 (goto-char (point-min))
359 (should-not (widget-tabable-at))
360 ;; Check that we can move to the first widget after BOB.
361 (widget-forward 1)
362 (should (widget-tabable-at))))
363
347(ert-deftest widget-test-color-match () 364(ert-deftest widget-test-color-match ()
348 "Test that the :match function for the color widget works." 365 "Test that the :match function for the color widget works."
349 (let ((widget (widget-convert 'color))) 366 (let ((widget (widget-convert 'color)))
diff --git a/test/src/treesit-tests.el b/test/src/treesit-tests.el
index d62344e81f0..1d18cc16532 100644
--- a/test/src/treesit-tests.el
+++ b/test/src/treesit-tests.el
@@ -686,6 +686,33 @@ visible_end.)"
686 (should (equal '((16 . 28)) (treesit-query-range 686 (should (equal '((16 . 28)) (treesit-query-range
687 'javascript query nil nil '(1 . -1))))))) 687 'javascript query nil nil '(1 . -1)))))))
688 688
689(ert-deftest treesit-range-fixup-after-edit ()
690 "Tests if Emacs can fix OOB ranges after deleting text or narrowing."
691 (skip-unless (treesit-language-available-p 'json))
692 (with-temp-buffer
693 (let ((parser (treesit-parser-create 'json)))
694 (insert "11111111111111111111")
695 (treesit-parser-set-included-ranges parser '((1 . 20)))
696 (treesit-parser-root-node parser)
697 (should (equal (treesit-parser-included-ranges parser)
698 '((1 . 20))))
699
700 (narrow-to-region 5 15)
701 (should (equal (treesit-parser-included-ranges parser)
702 '((5 . 15))))
703
704 (widen)
705 ;; Trickier ranges
706 ;; 11111111111111111111
707 ;; [ ] [ ]
708 ;; { narrow }
709 (treesit-parser-set-included-ranges parser '((1 . 7) (10 . 15)))
710 (should (equal (treesit-parser-included-ranges parser)
711 '((1 . 7) (10 . 15))))
712 (narrow-to-region 5 13)
713 (should (equal (treesit-parser-included-ranges parser)
714 '((5 . 7) (10 . 13)))))))
715
689;;; Multiple language 716;;; Multiple language
690 717
691(ert-deftest treesit-multi-lang () 718(ert-deftest treesit-multi-lang ()