diff options
| author | Po Lu | 2023-01-13 16:08:29 +0800 |
|---|---|---|
| committer | Po Lu | 2023-01-13 16:08:29 +0800 |
| commit | a02f52cc9e7c10a3a63b22b54d4d0f9fc3bb6219 (patch) | |
| tree | 2a5c9b91d424080558a48bcd7f8877913e5638de | |
| parent | 24910d3f375a11360c66b742e1054b55e9e25ccc (diff) | |
| parent | f1310859a0d84ceb725c74bf37a2336c7d21153f (diff) | |
| download | emacs-a02f52cc9e7c10a3a63b22b54d4d0f9fc3bb6219.tar.gz emacs-a02f52cc9e7c10a3a63b22b54d4d0f9fc3bb6219.zip | |
Merge remote-tracking branch 'origin/master' into feature/android
| -rw-r--r-- | doc/emacs/programs.texi | 61 | ||||
| -rw-r--r-- | doc/emacs/text.texi | 4 | ||||
| -rw-r--r-- | doc/lispref/positions.texi | 17 | ||||
| -rw-r--r-- | etc/NEWS | 18 | ||||
| -rw-r--r-- | etc/NEWS.29 | 9 | ||||
| -rw-r--r-- | etc/refcards/orgcard.tex | 2 | ||||
| -rw-r--r-- | lisp/emacs-lisp/package-vc.el | 8 | ||||
| -rw-r--r-- | lisp/org/org-version.el | 4 | ||||
| -rw-r--r-- | lisp/org/org.el | 2 | ||||
| -rw-r--r-- | lisp/outline.el | 22 | ||||
| -rw-r--r-- | lisp/progmodes/eglot.el | 2 | ||||
| -rw-r--r-- | lisp/progmodes/java-ts-mode.el | 8 | ||||
| -rw-r--r-- | lisp/textmodes/paragraphs.el | 15 | ||||
| -rw-r--r-- | lisp/treesit.el | 27 |
14 files changed, 183 insertions, 16 deletions
diff --git a/doc/emacs/programs.texi b/doc/emacs/programs.texi index 44cad5a148e..065ed1c51f7 100644 --- a/doc/emacs/programs.texi +++ b/doc/emacs/programs.texi | |||
| @@ -163,6 +163,7 @@ Emacs we use it for all languages. | |||
| 163 | * Left Margin Paren:: An open-paren or similar opening delimiter | 163 | * Left Margin Paren:: An open-paren or similar opening delimiter |
| 164 | starts a defun if it is at the left margin. | 164 | starts a defun if it is at the left margin. |
| 165 | * Moving by Defuns:: Commands to move over or mark a major definition. | 165 | * Moving by Defuns:: Commands to move over or mark a major definition. |
| 166 | * Moving by Sentences:: Commands to move over certain code units. | ||
| 166 | * Imenu:: Making buffer indexes as menus. | 167 | * Imenu:: Making buffer indexes as menus. |
| 167 | * Which Function:: Which Function mode shows which function you are in. | 168 | * Which Function:: Which Function mode shows which function you are in. |
| 168 | @end menu | 169 | @end menu |
| @@ -254,6 +255,66 @@ they do their standard jobs in a way better fitting a particular | |||
| 254 | language. Other major modes may replace any or all of these key | 255 | language. Other major modes may replace any or all of these key |
| 255 | bindings for that purpose. | 256 | bindings for that purpose. |
| 256 | 257 | ||
| 258 | @node Moving by Sentences | ||
| 259 | @subsection Moving by Sentences | ||
| 260 | @cindex sentences, in programming languages | ||
| 261 | |||
| 262 | These commands move point or set up the region based on units of | ||
| 263 | code, also called @dfn{sentences}. Even though sentences are usually | ||
| 264 | considered when writing human languages, Emacs can use the same | ||
| 265 | commands to move over certain constructs in programming languages | ||
| 266 | (@pxref{Sentences}, @pxref{Moving by Defuns}). In a programming | ||
| 267 | language a sentence is usually a complete language construct smaller | ||
| 268 | than defuns, but larger than sexps (@pxref{List Motion,,, elisp, The | ||
| 269 | Emacs Lisp Reference Manual}). What exactly is a sentence in this | ||
| 270 | case depends on the programming language, but usually it is a complete | ||
| 271 | statement, such as a variable definition and initialization, or a | ||
| 272 | conditional statement. An example of a sentence in the C language | ||
| 273 | could be | ||
| 274 | |||
| 275 | @example | ||
| 276 | int x = 5; | ||
| 277 | @end example | ||
| 278 | |||
| 279 | @noindent | ||
| 280 | or in the JavaScript language it could look like | ||
| 281 | |||
| 282 | @example | ||
| 283 | @group | ||
| 284 | const thing = () => console.log("Hi"); | ||
| 285 | @end group | ||
| 286 | @group | ||
| 287 | const foo = [1] == '1' | ||
| 288 | ? "No way" | ||
| 289 | : "..."; | ||
| 290 | @end group | ||
| 291 | |||
| 292 | @end example | ||
| 293 | |||
| 294 | @table @kbd | ||
| 295 | @item M-a | ||
| 296 | Move to beginning of current or preceding sentence | ||
| 297 | (@code{backward-sentence}). | ||
| 298 | @item M-e | ||
| 299 | Move to end of current or following sentence (@code{forward-sentence}). | ||
| 300 | @end table | ||
| 301 | |||
| 302 | @cindex move to beginning or end of sentence | ||
| 303 | @cindex sentence, move to beginning or end | ||
| 304 | @kindex M-a @r{(programming modes)} | ||
| 305 | @kindex M-e @r{(programming modes)} | ||
| 306 | @findex backward-sentence @r{(programming modes)} | ||
| 307 | @findex forward-sentence @r{(programming modes)} | ||
| 308 | The commands to move to the beginning and end of the current | ||
| 309 | sentence are @kbd{M-a} (@code{backward-sentence}) and @kbd{M-e} | ||
| 310 | (@code{forward-sentence}). If you repeat one of these commands, or | ||
| 311 | use a positive numeric argument, each repetition moves to the next | ||
| 312 | sentence in the direction of motion. | ||
| 313 | |||
| 314 | @kbd{M-a} with a negative argument @minus{}@var{n} moves forward | ||
| 315 | @var{n} times to the next end of a sentence. Likewise, @kbd{M-e} with | ||
| 316 | a negative argument moves back to the start of a sentence. | ||
| 317 | |||
| 257 | @node Imenu | 318 | @node Imenu |
| 258 | @subsection Imenu | 319 | @subsection Imenu |
| 259 | @cindex index of buffer definitions | 320 | @cindex index of buffer definitions |
diff --git a/doc/emacs/text.texi b/doc/emacs/text.texi index 8fbf731a4f7..6e16e743a52 100644 --- a/doc/emacs/text.texi +++ b/doc/emacs/text.texi | |||
| @@ -253,6 +253,10 @@ value of @code{sentence-end-double-space}. | |||
| 253 | of a sentence. Set the variable @code{sentence-end-without-period} to | 253 | of a sentence. Set the variable @code{sentence-end-without-period} to |
| 254 | @code{t} in such cases. | 254 | @code{t} in such cases. |
| 255 | 255 | ||
| 256 | Even though the above mentioned sentence movement commands are based | ||
| 257 | on human languages, other Emacs modes can set these command to get | ||
| 258 | similar functionality (@pxref{Moving by Sentences}). | ||
| 259 | |||
| 256 | @node Paragraphs | 260 | @node Paragraphs |
| 257 | @section Paragraphs | 261 | @section Paragraphs |
| 258 | @cindex paragraphs | 262 | @cindex paragraphs |
diff --git a/doc/lispref/positions.texi b/doc/lispref/positions.texi index f3824436246..8d95ecee7ab 100644 --- a/doc/lispref/positions.texi +++ b/doc/lispref/positions.texi | |||
| @@ -858,6 +858,23 @@ top-level defuns, if the value is @code{nested}, navigation functions | |||
| 858 | recognize nested defuns. | 858 | recognize nested defuns. |
| 859 | @end defvar | 859 | @end defvar |
| 860 | 860 | ||
| 861 | @defvar treesit-sentence-type-regexp | ||
| 862 | The value of this variable is a regexp matching the node type of sentence | ||
| 863 | nodes. (For ``node'' and ``node type'', @pxref{Parsing Program Source}.) | ||
| 864 | @end defvar | ||
| 865 | |||
| 866 | @findex treesit-forward-sentence | ||
| 867 | @findex forward-sentence | ||
| 868 | @findex backward-sentence | ||
| 869 | If Emacs is compiled with tree-sitter, it can use the tree-sitter | ||
| 870 | parser information to move across syntax constructs. Since what | ||
| 871 | exactly is considered a sentence varies between languages, a major | ||
| 872 | mode should set @code{treesit-sentence-type-regexp} to determine that. | ||
| 873 | Then the mode can get navigation-by-sentence functionality for free, | ||
| 874 | by using @code{forward-sentence} and | ||
| 875 | @code{backward-sentence}(@pxref{Moving by Sentences,,, emacs, The | ||
| 876 | extensible self-documenting text editor}). | ||
| 877 | |||
| 861 | @node Skipping Characters | 878 | @node Skipping Characters |
| 862 | @subsection Skipping Characters | 879 | @subsection Skipping Characters |
| 863 | @cindex skipping characters | 880 | @cindex skipping characters |
| @@ -66,6 +66,24 @@ treesit.el now unconditionally sets 'transpose-sexps-function' for all | |||
| 66 | Tree-sitter modes. This functionality utilizes the new | 66 | Tree-sitter modes. This functionality utilizes the new |
| 67 | 'transpose-sexps-function'. | 67 | 'transpose-sexps-function'. |
| 68 | 68 | ||
| 69 | ** Commands and variables to move by program statements | ||
| 70 | |||
| 71 | *** New variable 'forward-sentence-function'. | ||
| 72 | Major modes can now set this variable to customize the behavior of the | ||
| 73 | 'forward-sentence' command. | ||
| 74 | |||
| 75 | *** New function 'forward-sentence-default-function'. | ||
| 76 | The previous implementation of 'forward-sentence' is moved into its | ||
| 77 | own function, to be bound by 'forward-sentence-function'. | ||
| 78 | |||
| 79 | *** New defvar-local 'treesit-sentence-type-regexp. | ||
| 80 | Similarly to 'treesit-defun-type-regexp', this variable is used to | ||
| 81 | define "sentences" in Tree-sitter enabled modes. | ||
| 82 | |||
| 83 | *** New function 'treesit-forward-sentence'. | ||
| 84 | All tree-sitter modes that define 'treesit-sentence-type-regexp' now | ||
| 85 | set 'forward-sentence-function' to call 'treesit-forward-sentence'. | ||
| 86 | |||
| 69 | 87 | ||
| 70 | * Changes in Specialized Modes and Packages in Emacs 30.1 | 88 | * Changes in Specialized Modes and Packages in Emacs 30.1 |
| 71 | --- | 89 | --- |
diff --git a/etc/NEWS.29 b/etc/NEWS.29 index a28f5c9a65a..16d17821b78 100644 --- a/etc/NEWS.29 +++ b/etc/NEWS.29 | |||
| @@ -351,6 +351,15 @@ also means that 'TAB' on a button in an 'outline-minor-mode' heading | |||
| 351 | will move point instead of collapsing the outline. | 351 | will move point instead of collapsing the outline. |
| 352 | 352 | ||
| 353 | --- | 353 | --- |
| 354 | ** 'outline-minor-mode-cycle-map' is now parent of 'outline-minor-mode'. | ||
| 355 | Instead of adding text property 'keymap' with 'outline-minor-mode-cycle' | ||
| 356 | on outline headings in 'outline-minor-mode', the keymap | ||
| 357 | 'outline-minor-mode-cycle' is now active in the whole buffer. | ||
| 358 | But keybindings in 'outline-minor-mode-cycle' still take effect | ||
| 359 | only on outline headings because they are bound with the help of | ||
| 360 | 'outline-minor-mode-cycle--bind' that checks if point is on a heading. | ||
| 361 | |||
| 362 | --- | ||
| 354 | ** 'Info-default-directory-list' is no longer populated at Emacs startup. | 363 | ** 'Info-default-directory-list' is no longer populated at Emacs startup. |
| 355 | If you have code in your init file that removes directories from | 364 | If you have code in your init file that removes directories from |
| 356 | 'Info-default-directory-list', this will no longer work. | 365 | 'Info-default-directory-list', this will no longer work. |
diff --git a/etc/refcards/orgcard.tex b/etc/refcards/orgcard.tex index 04d46756155..093dfceafa7 100644 --- a/etc/refcards/orgcard.tex +++ b/etc/refcards/orgcard.tex | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | % Reference Card for Org Mode | 1 | % Reference Card for Org Mode |
| 2 | \def\orgversionnumber{9.6} | 2 | \def\orgversionnumber{9.6.1} |
| 3 | \def\versionyear{2021} % latest update | 3 | \def\versionyear{2021} % latest update |
| 4 | \input emacsver.tex | 4 | \input emacsver.tex |
| 5 | 5 | ||
diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el index ddcfe57928b..b5b8a6746a6 100644 --- a/lisp/emacs-lisp/package-vc.el +++ b/lisp/emacs-lisp/package-vc.el | |||
| @@ -600,10 +600,14 @@ PKG-SPEC is a package specification, a property list describing | |||
| 600 | how to fetch and build the package. See `package-vc--archive-spec-alist' | 600 | how to fetch and build the package. See `package-vc--archive-spec-alist' |
| 601 | for details. The optional argument REV specifies a specific revision to | 601 | for details. The optional argument REV specifies a specific revision to |
| 602 | checkout. This overrides the `:branch' attribute in PKG-SPEC." | 602 | checkout. This overrides the `:branch' attribute in PKG-SPEC." |
| 603 | (unless pkg-desc | ||
| 604 | (package-desc-create :name (car pkg-spec) :kind 'vc)) | ||
| 603 | (pcase-let* (((map :lisp-dir) pkg-spec) | 605 | (pcase-let* (((map :lisp-dir) pkg-spec) |
| 604 | (name (package-desc-name pkg-desc)) | 606 | (name (package-desc-name pkg-desc)) |
| 605 | (dirname (package-desc-full-name pkg-desc)) | 607 | (dirname (package-desc-full-name pkg-desc)) |
| 606 | (pkg-dir (expand-file-name dirname package-user-dir))) | 608 | (pkg-dir (expand-file-name dirname package-user-dir))) |
| 609 | (when (string-empty-p name) | ||
| 610 | (user-error "Empty package name")) | ||
| 607 | (setf (package-desc-dir pkg-desc) pkg-dir) | 611 | (setf (package-desc-dir pkg-desc) pkg-dir) |
| 608 | (when (file-exists-p pkg-dir) | 612 | (when (file-exists-p pkg-dir) |
| 609 | (if (yes-or-no-p (format "Overwrite previous checkout for package `%s'?" name)) | 613 | (if (yes-or-no-p (format "Overwrite previous checkout for package `%s'?" name)) |
| @@ -771,7 +775,9 @@ regular package, but it will not remove a VC package. | |||
| 771 | (package-vc--archives-initialize) | 775 | (package-vc--archives-initialize) |
| 772 | (let* ((name-or-url (package-vc--read-package-name | 776 | (let* ((name-or-url (package-vc--read-package-name |
| 773 | "Fetch and install package: " t)) | 777 | "Fetch and install package: " t)) |
| 774 | (name (file-name-base name-or-url))) | 778 | (name (file-name-base (directory-file-name name-or-url)))) |
| 779 | (when (string-empty-p name) | ||
| 780 | (user-error "Empty package name")) | ||
| 775 | (list name-or-url | 781 | (list name-or-url |
| 776 | (and current-prefix-arg :last-release) | 782 | (and current-prefix-arg :last-release) |
| 777 | nil | 783 | nil |
diff --git a/lisp/org/org-version.el b/lisp/org/org-version.el index 942cc4eae8b..43d50e4387f 100644 --- a/lisp/org/org-version.el +++ b/lisp/org/org-version.el | |||
| @@ -5,13 +5,13 @@ | |||
| 5 | (defun org-release () | 5 | (defun org-release () |
| 6 | "The release version of Org. | 6 | "The release version of Org. |
| 7 | Inserted by installing Org mode or when a release is made." | 7 | Inserted by installing Org mode or when a release is made." |
| 8 | (let ((org-release "9.6")) | 8 | (let ((org-release "9.6.1")) |
| 9 | org-release)) | 9 | org-release)) |
| 10 | ;;;###autoload | 10 | ;;;###autoload |
| 11 | (defun org-git-version () | 11 | (defun org-git-version () |
| 12 | "The Git version of Org mode. | 12 | "The Git version of Org mode. |
| 13 | Inserted by installing Org or when a release is made." | 13 | Inserted by installing Org or when a release is made." |
| 14 | (let ((org-git-version "release_9.6-90-ga6523f")) | 14 | (let ((org-git-version "release_9.6.1")) |
| 15 | org-git-version)) | 15 | org-git-version)) |
| 16 | 16 | ||
| 17 | (provide 'org-version) | 17 | (provide 'org-version) |
diff --git a/lisp/org/org.el b/lisp/org/org.el index 8d226c2c5ab..869ff16a6da 100644 --- a/lisp/org/org.el +++ b/lisp/org/org.el | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | ;; URL: https://orgmode.org | 9 | ;; URL: https://orgmode.org |
| 10 | ;; Package-Requires: ((emacs "25.1")) | 10 | ;; Package-Requires: ((emacs "25.1")) |
| 11 | 11 | ||
| 12 | ;; Version: 9.6 | 12 | ;; Version: 9.6.1 |
| 13 | 13 | ||
| 14 | ;; This file is part of GNU Emacs. | 14 | ;; This file is part of GNU Emacs. |
| 15 | ;; | 15 | ;; |
diff --git a/lisp/outline.el b/lisp/outline.el index 91f6040687b..0bfda8388ed 100644 --- a/lisp/outline.el +++ b/lisp/outline.el | |||
| @@ -209,8 +209,14 @@ This option is only in effect when `outline-minor-mode-cycle' is non-nil." | |||
| 209 | :version "28.1") | 209 | :version "28.1") |
| 210 | 210 | ||
| 211 | (defvar outline-minor-mode-cycle) | 211 | (defvar outline-minor-mode-cycle) |
| 212 | (defvar outline-minor-mode-cycle-map) | ||
| 212 | (defun outline-minor-mode-cycle--bind (map key binding &optional filter) | 213 | (defun outline-minor-mode-cycle--bind (map key binding &optional filter) |
| 213 | (define-key map key | 214 | "Define KEY as BINDING in MAP using FILTER. |
| 215 | The key takes effect only on the following conditions: | ||
| 216 | `outline-minor-mode-cycle' is non-nil, point is located on the heading line, | ||
| 217 | FILTER or `outline-minor-mode-cycle-filter' is nil or returns non-nil. | ||
| 218 | The argument MAP is optional and defaults to `outline-minor-mode-cycle-map'." | ||
| 219 | (define-key (or map outline-minor-mode-cycle-map) key | ||
| 214 | `(menu-item | 220 | `(menu-item |
| 215 | "" ,binding | 221 | "" ,binding |
| 216 | ;; Filter out specific positions on the heading. | 222 | ;; Filter out specific positions on the heading. |
| @@ -227,8 +233,16 @@ This option is only in effect when `outline-minor-mode-cycle' is non-nil." | |||
| 227 | (let ((map (make-sparse-keymap))) | 233 | (let ((map (make-sparse-keymap))) |
| 228 | (outline-minor-mode-cycle--bind map (kbd "TAB") #'outline-cycle) | 234 | (outline-minor-mode-cycle--bind map (kbd "TAB") #'outline-cycle) |
| 229 | (outline-minor-mode-cycle--bind map (kbd "<backtab>") #'outline-cycle-buffer) | 235 | (outline-minor-mode-cycle--bind map (kbd "<backtab>") #'outline-cycle-buffer) |
| 236 | (keymap-set map "<left-margin> <mouse-1>" 'outline-cycle) | ||
| 237 | (keymap-set map "<right-margin> <mouse-1>" 'outline-cycle) | ||
| 238 | (keymap-set map "<left-margin> S-<mouse-1>" 'outline-cycle-buffer) | ||
| 239 | (keymap-set map "<right-margin> S-<mouse-1>" 'outline-cycle-buffer) | ||
| 230 | map) | 240 | map) |
| 231 | "Keymap used by `outline-minor-mode-cycle'.") | 241 | "Keymap used as a parent of the `outline-minor-mode' keymap. |
| 242 | It contains key bindings that can be used to cycle visibility. | ||
| 243 | The recommended way to bind keys is with `outline-minor-mode-cycle--bind' | ||
| 244 | when the key should be enabled only when `outline-minor-mode-cycle' is | ||
| 245 | non-nil and point is located on the heading line.") | ||
| 232 | 246 | ||
| 233 | (defvar outline-mode-map | 247 | (defvar outline-mode-map |
| 234 | (let ((map (make-sparse-keymap))) | 248 | (let ((map (make-sparse-keymap))) |
| @@ -518,10 +532,6 @@ See the command `outline-mode' for more information on this mode." | |||
| 518 | :keymap (define-keymap | 532 | :keymap (define-keymap |
| 519 | :parent outline-minor-mode-cycle-map | 533 | :parent outline-minor-mode-cycle-map |
| 520 | "<menu-bar>" outline-minor-mode-menu-bar-map | 534 | "<menu-bar>" outline-minor-mode-menu-bar-map |
| 521 | "<left-margin> <mouse-1>" 'outline-cycle | ||
| 522 | "<right-margin> <mouse-1>" 'outline-cycle | ||
| 523 | "<left-margin> S-<mouse-1>" 'outline-cycle-buffer | ||
| 524 | "<right-margin> S-<mouse-1>" 'outline-cycle-buffer | ||
| 525 | (key-description outline-minor-mode-prefix) outline-mode-prefix-map) | 535 | (key-description outline-minor-mode-prefix) outline-mode-prefix-map) |
| 526 | (if outline-minor-mode | 536 | (if outline-minor-mode |
| 527 | (progn | 537 | (progn |
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 6d192d9b333..c7fc443c8dc 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el | |||
| @@ -182,7 +182,7 @@ chosen (interactively or automatically)." | |||
| 182 | when probe return (cons probe args) | 182 | when probe return (cons probe args) |
| 183 | finally (funcall err))))))) | 183 | finally (funcall err))))))) |
| 184 | 184 | ||
| 185 | (defvar eglot-server-programs `(((rust-ts-mode rust-mode) . ,(eglot-alternatives '("rust-analyzer" "rls"))) | 185 | (defvar eglot-server-programs `(((rust-ts-mode rust-mode) . ("rust-analyzer")) |
| 186 | ((cmake-mode cmake-ts-mode) . ("cmake-language-server")) | 186 | ((cmake-mode cmake-ts-mode) . ("cmake-language-server")) |
| 187 | (vimrc-mode . ("vim-language-server" "--stdio")) | 187 | (vimrc-mode . ("vim-language-server" "--stdio")) |
| 188 | ((python-mode python-ts-mode) | 188 | ((python-mode python-ts-mode) |
diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index 87a4e2b90f8..8d432f1774e 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el | |||
| @@ -122,7 +122,8 @@ | |||
| 122 | "provides" "public" "requires" "return" "sealed" | 122 | "provides" "public" "requires" "return" "sealed" |
| 123 | "static" "strictfp" "switch" "synchronized" | 123 | "static" "strictfp" "switch" "synchronized" |
| 124 | "throw" "throws" "to" "transient" "transitive" | 124 | "throw" "throws" "to" "transient" "transitive" |
| 125 | "try" "uses" "volatile" "while" "with" "record") | 125 | "try" "uses" "volatile" "while" "with" "record" |
| 126 | "@interface") | ||
| 126 | "Java keywords for tree-sitter font-locking.") | 127 | "Java keywords for tree-sitter font-locking.") |
| 127 | 128 | ||
| 128 | (defvar java-ts-mode--operators | 129 | (defvar java-ts-mode--operators |
| @@ -183,7 +184,10 @@ | |||
| 183 | :language 'java | 184 | :language 'java |
| 184 | :override t | 185 | :override t |
| 185 | :feature 'type | 186 | :feature 'type |
| 186 | '((interface_declaration | 187 | '((annotation_type_declaration |
| 188 | name: (identifier) @font-lock-type-face) | ||
| 189 | |||
| 190 | (interface_declaration | ||
| 187 | name: (identifier) @font-lock-type-face) | 191 | name: (identifier) @font-lock-type-face) |
| 188 | 192 | ||
| 189 | (class_declaration | 193 | (class_declaration |
diff --git a/lisp/textmodes/paragraphs.el b/lisp/textmodes/paragraphs.el index 73abb155aaa..bf249fdcdfb 100644 --- a/lisp/textmodes/paragraphs.el +++ b/lisp/textmodes/paragraphs.el | |||
| @@ -441,13 +441,12 @@ the current paragraph with the one containing the mark." | |||
| 441 | (if (< (point) (point-max)) | 441 | (if (< (point) (point-max)) |
| 442 | (end-of-paragraph-text)))))) | 442 | (end-of-paragraph-text)))))) |
| 443 | 443 | ||
| 444 | (defun forward-sentence (&optional arg) | 444 | (defun forward-sentence-default-function (&optional arg) |
| 445 | "Move forward to next end of sentence. With argument, repeat. | 445 | "Move forward to next end of sentence. With argument, repeat. |
| 446 | When ARG is negative, move backward repeatedly to start of sentence. | 446 | When ARG is negative, move backward repeatedly to start of sentence. |
| 447 | 447 | ||
| 448 | The variable `sentence-end' is a regular expression that matches ends of | 448 | The variable `sentence-end' is a regular expression that matches ends of |
| 449 | sentences. Also, every paragraph boundary terminates sentences as well." | 449 | sentences. Also, every paragraph boundary terminates sentences as well." |
| 450 | (interactive "^p") | ||
| 451 | (or arg (setq arg 1)) | 450 | (or arg (setq arg 1)) |
| 452 | (let ((opoint (point)) | 451 | (let ((opoint (point)) |
| 453 | (sentence-end (sentence-end))) | 452 | (sentence-end (sentence-end))) |
| @@ -480,6 +479,18 @@ sentences. Also, every paragraph boundary terminates sentences as well." | |||
| 480 | (let ((npoint (constrain-to-field nil opoint t))) | 479 | (let ((npoint (constrain-to-field nil opoint t))) |
| 481 | (not (= npoint opoint))))) | 480 | (not (= npoint opoint))))) |
| 482 | 481 | ||
| 482 | (defvar forward-sentence-function #'forward-sentence-default-function | ||
| 483 | "Function to be used to calculate sentence movements. | ||
| 484 | See `forward-sentence' for a description of its behavior.") | ||
| 485 | |||
| 486 | (defun forward-sentence (&optional arg) | ||
| 487 | "Move forward to next end of sentence. With argument ARG, repeat. | ||
| 488 | If ARG is negative, move backward repeatedly to start of | ||
| 489 | sentence. Delegates its work to `forward-sentence-function'." | ||
| 490 | (interactive "^p") | ||
| 491 | (or arg (setq arg 1)) | ||
| 492 | (funcall forward-sentence-function arg)) | ||
| 493 | |||
| 483 | (defun count-sentences (start end) | 494 | (defun count-sentences (start end) |
| 484 | "Count sentences in current buffer from START to END." | 495 | "Count sentences in current buffer from START to END." |
| 485 | (let ((sentences 0) | 496 | (let ((sentences 0) |
diff --git a/lisp/treesit.el b/lisp/treesit.el index 25b2c70ce0a..f2e1b4ac807 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el | |||
| @@ -1795,6 +1795,31 @@ comments and multiline string literals. For example, | |||
| 1795 | \"text_block\" in the case of a string. This is used by | 1795 | \"text_block\" in the case of a string. This is used by |
| 1796 | `prog-fill-reindent-defun' and friends.") | 1796 | `prog-fill-reindent-defun' and friends.") |
| 1797 | 1797 | ||
| 1798 | (defvar-local treesit-sentence-type-regexp nil | ||
| 1799 | "A regexp that matches the node type of sentence nodes. | ||
| 1800 | |||
| 1801 | A sentence node is a node that is bigger than a sexp, and | ||
| 1802 | delimits larger statements in the source code. It is, however, | ||
| 1803 | smaller in scope than defuns. This is used by | ||
| 1804 | `treesit-forward-sentence' and friends.") | ||
| 1805 | |||
| 1806 | (defun treesit-forward-sentence (&optional arg) | ||
| 1807 | "Tree-sitter `forward-sentence-function' function. | ||
| 1808 | |||
| 1809 | ARG is the same as in `forward-sentence'. | ||
| 1810 | |||
| 1811 | If inside comment or other nodes described in | ||
| 1812 | `treesit-sentence-type-regexp', use | ||
| 1813 | `forward-sentence-default-function', else move across nodes as | ||
| 1814 | described by `treesit-sentence-type-regexp'." | ||
| 1815 | (if (string-match-p | ||
| 1816 | treesit-text-type-regexp | ||
| 1817 | (treesit-node-type (treesit-node-at (point)))) | ||
| 1818 | (funcall #'forward-sentence-default-function arg) | ||
| 1819 | (funcall | ||
| 1820 | (if (> arg 0) #'treesit-end-of-thing #'treesit-beginning-of-thing) | ||
| 1821 | treesit-sentence-type-regexp (abs arg)))) | ||
| 1822 | |||
| 1798 | (defun treesit-default-defun-skipper () | 1823 | (defun treesit-default-defun-skipper () |
| 1799 | "Skips spaces after navigating a defun. | 1824 | "Skips spaces after navigating a defun. |
| 1800 | This function tries to move to the beginning of a line, either by | 1825 | This function tries to move to the beginning of a line, either by |
| @@ -2259,6 +2284,8 @@ before calling this function." | |||
| 2259 | #'treesit-add-log-current-defun)) | 2284 | #'treesit-add-log-current-defun)) |
| 2260 | 2285 | ||
| 2261 | (setq-local transpose-sexps-function #'treesit-transpose-sexps) | 2286 | (setq-local transpose-sexps-function #'treesit-transpose-sexps) |
| 2287 | (when treesit-sentence-type-regexp | ||
| 2288 | (setq-local forward-sentence-function #'treesit-forward-sentence)) | ||
| 2262 | 2289 | ||
| 2263 | ;; Imenu. | 2290 | ;; Imenu. |
| 2264 | (when treesit-simple-imenu-settings | 2291 | (when treesit-simple-imenu-settings |