commit e2abb95b6b03d13e60609ee85ea00bbf44a0bd6b (HEAD, refs/remotes/origin/master) Merge: c51bfef34a6 f4f30ff4c44 Author: Stefan Kangas Date: Thu Jan 12 06:30:12 2023 +0100 Merge from origin/emacs-29 f4f30ff4c44 Update to Org 9.6.1 09f7a920644 Add support for annotation_type_declaration 4a8891a462e * etc/NEWS: Mention incompatible changes in 'outline-mino... 384504edf35 Ensure VC package names are not empty 70947da708c Handle missing package description when unpacking vc pack... # Conflicts: # etc/NEWS commit f4f30ff4c44dcfdf780f1981aa541af713f2805f (refs/remotes/origin/emacs-29) Author: Kyle Meyer Date: Wed Jan 11 21:15:37 2023 -0500 Update to Org 9.6.1 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 @@ % Reference Card for Org Mode -\def\orgversionnumber{9.6} +\def\orgversionnumber{9.6.1} \def\versionyear{2021} % latest update \input emacsver.tex 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 @@ (defun org-release () "The release version of Org. Inserted by installing Org mode or when a release is made." - (let ((org-release "9.6")) + (let ((org-release "9.6.1")) org-release)) ;;;###autoload (defun org-git-version () "The Git version of Org mode. Inserted by installing Org or when a release is made." - (let ((org-git-version "release_9.6-90-ga6523f")) + (let ((org-git-version "release_9.6.1")) org-git-version)) (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 @@ ;; URL: https://orgmode.org ;; Package-Requires: ((emacs "25.1")) -;; Version: 9.6 +;; Version: 9.6.1 ;; This file is part of GNU Emacs. ;; commit 09f7a920644cc74a1f740454d0c9442eb9b97621 Author: Theodor Thornhill Date: Wed Jan 11 21:49:04 2023 +0100 Add support for annotation_type_declaration * lisp/progmodes/java-ts-mode.el (java-ts-mode--keywords): Add new keyword. (java-ts-mode--font-lock-settings): Add font-locking to the type feature. diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index 96d8045bd61..86e753c5f53 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -122,7 +122,8 @@ java-ts-mode--keywords "provides" "public" "requires" "return" "sealed" "static" "strictfp" "switch" "synchronized" "throw" "throws" "to" "transient" "transitive" - "try" "uses" "volatile" "while" "with" "record") + "try" "uses" "volatile" "while" "with" "record" + "@interface") "Java keywords for tree-sitter font-locking.") (defvar java-ts-mode--operators @@ -183,7 +184,10 @@ java-ts-mode--font-lock-settings :language 'java :override t :feature 'type - '((interface_declaration + '((annotation_type_declaration + name: (identifier) @font-lock-type-face) + + (interface_declaration name: (identifier) @font-lock-type-face) (class_declaration commit 4a8891a462e41e81a5232810b67d9d85f79bc515 Author: Juri Linkov Date: Wed Jan 11 21:37:33 2023 +0200 * etc/NEWS: Mention incompatible changes in 'outline-minor-mode-cycle-map'. * lisp/outline.el (outline-minor-mode-cycle--bind): Add docstring (bug#60426). (outline-minor-mode-cycle--bind): Default 'map' to 'outline-minor-mode-cycle-map'. (outline-minor-mode-cycle-map): Improve docstring. (outline-minor-mode): Move margin-cycling keys to 'outline-minor-mode-cycle-map'. diff --git a/etc/NEWS b/etc/NEWS index a28f5c9a65a..16d17821b78 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -350,6 +350,15 @@ next button, even if the mode has bound it to something else. This also means that 'TAB' on a button in an 'outline-minor-mode' heading will move point instead of collapsing the outline. +--- +** 'outline-minor-mode-cycle-map' is now parent of 'outline-minor-mode'. +Instead of adding text property 'keymap' with 'outline-minor-mode-cycle' +on outline headings in 'outline-minor-mode', the keymap +'outline-minor-mode-cycle' is now active in the whole buffer. +But keybindings in 'outline-minor-mode-cycle' still take effect +only on outline headings because they are bound with the help of +'outline-minor-mode-cycle--bind' that checks if point is on a heading. + --- ** 'Info-default-directory-list' is no longer populated at Emacs startup. If you have code in your init file that removes directories from 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 @@ outline-minor-mode-cycle-filter :version "28.1") (defvar outline-minor-mode-cycle) +(defvar outline-minor-mode-cycle-map) (defun outline-minor-mode-cycle--bind (map key binding &optional filter) - (define-key map key + "Define KEY as BINDING in MAP using FILTER. +The key takes effect only on the following conditions: +`outline-minor-mode-cycle' is non-nil, point is located on the heading line, +FILTER or `outline-minor-mode-cycle-filter' is nil or returns non-nil. +The argument MAP is optional and defaults to `outline-minor-mode-cycle-map'." + (define-key (or map outline-minor-mode-cycle-map) key `(menu-item "" ,binding ;; Filter out specific positions on the heading. @@ -227,8 +233,16 @@ outline-minor-mode-cycle-map (let ((map (make-sparse-keymap))) (outline-minor-mode-cycle--bind map (kbd "TAB") #'outline-cycle) (outline-minor-mode-cycle--bind map (kbd "") #'outline-cycle-buffer) + (keymap-set map " " 'outline-cycle) + (keymap-set map " " 'outline-cycle) + (keymap-set map " S-" 'outline-cycle-buffer) + (keymap-set map " S-" 'outline-cycle-buffer) map) - "Keymap used by `outline-minor-mode-cycle'.") + "Keymap used as a parent of the `outline-minor-mode' keymap. +It contains key bindings that can be used to cycle visibility. +The recommended way to bind keys is with `outline-minor-mode-cycle--bind' +when the key should be enabled only when `outline-minor-mode-cycle' is +non-nil and point is located on the heading line.") (defvar outline-mode-map (let ((map (make-sparse-keymap))) @@ -518,10 +532,6 @@ outline-minor-mode :keymap (define-keymap :parent outline-minor-mode-cycle-map "" outline-minor-mode-menu-bar-map - " " 'outline-cycle - " " 'outline-cycle - " S-" 'outline-cycle-buffer - " S-" 'outline-cycle-buffer (key-description outline-minor-mode-prefix) outline-mode-prefix-map) (if outline-minor-mode (progn commit c51bfef34a6bdefad048444c279ea5b63a6aada1 Author: Eli Zaretskii Date: Wed Jan 11 19:15:30 2023 +0200 ; Fix documentation of last change * etc/NEWS: * doc/emacs/programs.texi (Moving by Sentences): Minor wording fixes. diff --git a/doc/emacs/programs.texi b/doc/emacs/programs.texi index a2cdf6c6eb9..065ed1c51f7 100644 --- a/doc/emacs/programs.texi +++ b/doc/emacs/programs.texi @@ -266,24 +266,29 @@ Moving by Sentences (@pxref{Sentences}, @pxref{Moving by Defuns}). In a programming language a sentence is usually a complete language construct smaller than defuns, but larger than sexps (@pxref{List Motion,,, elisp, The -Emacs Lisp Reference Manual}). What exactly a sentence is in a -non-human language is dependent on the target language, but usually it -is complete statements, such as a variable definition and -initialization, or a conditional statement. An example of a sentence -in the C language could be +Emacs Lisp Reference Manual}). What exactly is a sentence in this +case depends on the programming language, but usually it is a complete +statement, such as a variable definition and initialization, or a +conditional statement. An example of a sentence in the C language +could be @example int x = 5; @end example +@noindent or in the JavaScript language it could look like @example +@group const thing = () => console.log("Hi"); - +@end group +@group const foo = [1] == '1' ? "No way" : "..."; +@end group + @end example @table @kbd @@ -308,7 +313,7 @@ Moving by Sentences @kbd{M-a} with a negative argument @minus{}@var{n} moves forward @var{n} times to the next end of a sentence. Likewise, @kbd{M-e} with -a negative argument moves back to a start of a sentence. +a negative argument moves back to the start of a sentence. @node Imenu @subsection Imenu diff --git a/etc/NEWS b/etc/NEWS index 0c782eeaee8..90a6c6a0522 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -69,8 +69,8 @@ Tree-sitter modes. This functionality utilizes the new ** Commands and variables to move by program statements *** New variable 'forward-sentence-function'. -Major modes now can set this variable to customize the behavior of the -'forward-sentence' function. +Major modes can now set this variable to customize the behavior of the +'forward-sentence' command. *** New function 'forward-sentence-default-function'. The previous implementation of 'forward-sentence' is moved into its @@ -78,11 +78,11 @@ own function, to be bound by 'forward-sentence-function'. *** New defvar-local 'treesit-sentence-type-regexp. Similarly to 'treesit-defun-type-regexp', this variable is used to -navigate sentences in Tree-sitter enabled modes. +define "sentences" in Tree-sitter enabled modes. *** New function 'treesit-forward-sentence'. -treesit.el now conditionally sets 'forward-sentence-function' for all -Tree-sitter modes that sets 'treesit-sentence-type-regexp'. +All tree-sitter modes that define 'treesit-sentence-type-regexp' now +set 'forward-sentence-function' to call 'treesit-forward-sentence'. * Changes in Specialized Modes and Packages in Emacs 30.1 commit 37d93975780f294fd7b3fefe6281a0a36638192f Author: Theodor Thornhill Date: Sun Jan 8 20:28:02 2023 +0100 Add forward-sentence with tree sitter support (bug#60623) * etc/NEWS: Mention the new changes. * lisp/textmodes/paragraphs.el (forward-sentence-default-function): Move old implementation to its own function. (forward-sentence-function): New defvar defaulting to old behavior. (forward-sentence): Use the variable in this function unconditionally. * lisp/treesit.el (treesit-sentence-type-regexp): New defvar. (treesit-forward-sentence): New defun. (treesit-major-mode-setup): Conditionally set forward-sentence-function. * doc/emacs/programs.texi (Defuns): Add new subsection. (Moving by Sentences): Add some documentation with xrefs to the elisp manual and related nodes. * doc/lispref/positions.texi (List Motion): Mention treesit-sentence-type-regexp and describe how to enable this functionality. diff --git a/doc/emacs/programs.texi b/doc/emacs/programs.texi index 44cad5a148e..a2cdf6c6eb9 100644 --- a/doc/emacs/programs.texi +++ b/doc/emacs/programs.texi @@ -163,6 +163,7 @@ Defuns * Left Margin Paren:: An open-paren or similar opening delimiter starts a defun if it is at the left margin. * Moving by Defuns:: Commands to move over or mark a major definition. +* Moving by Sentences:: Commands to move over certain code units. * Imenu:: Making buffer indexes as menus. * Which Function:: Which Function mode shows which function you are in. @end menu @@ -254,6 +255,61 @@ Moving by Defuns language. Other major modes may replace any or all of these key bindings for that purpose. +@node Moving by Sentences +@subsection Moving by Sentences +@cindex sentences, in programming languages + + These commands move point or set up the region based on units of +code, also called @dfn{sentences}. Even though sentences are usually +considered when writing human languages, Emacs can use the same +commands to move over certain constructs in programming languages +(@pxref{Sentences}, @pxref{Moving by Defuns}). In a programming +language a sentence is usually a complete language construct smaller +than defuns, but larger than sexps (@pxref{List Motion,,, elisp, The +Emacs Lisp Reference Manual}). What exactly a sentence is in a +non-human language is dependent on the target language, but usually it +is complete statements, such as a variable definition and +initialization, or a conditional statement. An example of a sentence +in the C language could be + +@example +int x = 5; +@end example + +or in the JavaScript language it could look like + +@example +const thing = () => console.log("Hi"); + +const foo = [1] == '1' + ? "No way" + : "..."; +@end example + +@table @kbd +@item M-a +Move to beginning of current or preceding sentence +(@code{backward-sentence}). +@item M-e +Move to end of current or following sentence (@code{forward-sentence}). +@end table + +@cindex move to beginning or end of sentence +@cindex sentence, move to beginning or end +@kindex M-a @r{(programming modes)} +@kindex M-e @r{(programming modes)} +@findex backward-sentence @r{(programming modes)} +@findex forward-sentence @r{(programming modes)} + The commands to move to the beginning and end of the current +sentence are @kbd{M-a} (@code{backward-sentence}) and @kbd{M-e} +(@code{forward-sentence}). If you repeat one of these commands, or +use a positive numeric argument, each repetition moves to the next +sentence in the direction of motion. + + @kbd{M-a} with a negative argument @minus{}@var{n} moves forward +@var{n} times to the next end of a sentence. Likewise, @kbd{M-e} with +a negative argument moves back to a start of a sentence. + @node Imenu @subsection Imenu @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 @@ Sentences of a sentence. Set the variable @code{sentence-end-without-period} to @code{t} in such cases. + Even though the above mentioned sentence movement commands are based +on human languages, other Emacs modes can set these command to get +similar functionality (@pxref{Moving by Sentences}). + @node Paragraphs @section Paragraphs @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 @@ List Motion recognize nested defuns. @end defvar +@defvar treesit-sentence-type-regexp +The value of this variable is a regexp matching the node type of sentence +nodes. (For ``node'' and ``node type'', @pxref{Parsing Program Source}.) +@end defvar + +@findex treesit-forward-sentence +@findex forward-sentence +@findex backward-sentence +If Emacs is compiled with tree-sitter, it can use the tree-sitter +parser information to move across syntax constructs. Since what +exactly is considered a sentence varies between languages, a major +mode should set @code{treesit-sentence-type-regexp} to determine that. +Then the mode can get navigation-by-sentence functionality for free, +by using @code{forward-sentence} and +@code{backward-sentence}(@pxref{Moving by Sentences,,, emacs, The +extensible self-documenting text editor}). + @node Skipping Characters @subsection Skipping Characters @cindex skipping characters diff --git a/etc/NEWS b/etc/NEWS index 3aa8f2abb77..0c782eeaee8 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -66,6 +66,24 @@ treesit.el now unconditionally sets 'transpose-sexps-function' for all Tree-sitter modes. This functionality utilizes the new 'transpose-sexps-function'. +** Commands and variables to move by program statements + +*** New variable 'forward-sentence-function'. +Major modes now can set this variable to customize the behavior of the +'forward-sentence' function. + +*** New function 'forward-sentence-default-function'. +The previous implementation of 'forward-sentence' is moved into its +own function, to be bound by 'forward-sentence-function'. + +*** New defvar-local 'treesit-sentence-type-regexp. +Similarly to 'treesit-defun-type-regexp', this variable is used to +navigate sentences in Tree-sitter enabled modes. + +*** New function 'treesit-forward-sentence'. +treesit.el now conditionally sets 'forward-sentence-function' for all +Tree-sitter modes that sets 'treesit-sentence-type-regexp'. + * Changes in Specialized Modes and Packages in Emacs 30.1 --- 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 @@ end-of-paragraph-text (if (< (point) (point-max)) (end-of-paragraph-text)))))) -(defun forward-sentence (&optional arg) +(defun forward-sentence-default-function (&optional arg) "Move forward to next end of sentence. With argument, repeat. When ARG is negative, move backward repeatedly to start of sentence. The variable `sentence-end' is a regular expression that matches ends of sentences. Also, every paragraph boundary terminates sentences as well." - (interactive "^p") (or arg (setq arg 1)) (let ((opoint (point)) (sentence-end (sentence-end))) @@ -480,6 +479,18 @@ forward-sentence (let ((npoint (constrain-to-field nil opoint t))) (not (= npoint opoint))))) +(defvar forward-sentence-function #'forward-sentence-default-function + "Function to be used to calculate sentence movements. +See `forward-sentence' for a description of its behavior.") + +(defun forward-sentence (&optional arg) + "Move forward to next end of sentence. With argument ARG, repeat. +If ARG is negative, move backward repeatedly to start of +sentence. Delegates its work to `forward-sentence-function'." + (interactive "^p") + (or arg (setq arg 1)) + (funcall forward-sentence-function arg)) + (defun count-sentences (start end) "Count sentences in current buffer from START to END." (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 @@ treesit-text-type-regexp \"text_block\" in the case of a string. This is used by `prog-fill-reindent-defun' and friends.") +(defvar-local treesit-sentence-type-regexp nil + "A regexp that matches the node type of sentence nodes. + +A sentence node is a node that is bigger than a sexp, and +delimits larger statements in the source code. It is, however, +smaller in scope than defuns. This is used by +`treesit-forward-sentence' and friends.") + +(defun treesit-forward-sentence (&optional arg) + "Tree-sitter `forward-sentence-function' function. + +ARG is the same as in `forward-sentence'. + +If inside comment or other nodes described in +`treesit-sentence-type-regexp', use +`forward-sentence-default-function', else move across nodes as +described by `treesit-sentence-type-regexp'." + (if (string-match-p + treesit-text-type-regexp + (treesit-node-type (treesit-node-at (point)))) + (funcall #'forward-sentence-default-function arg) + (funcall + (if (> arg 0) #'treesit-end-of-thing #'treesit-beginning-of-thing) + treesit-sentence-type-regexp (abs arg)))) + (defun treesit-default-defun-skipper () "Skips spaces after navigating a defun. This function tries to move to the beginning of a line, either by @@ -2259,6 +2284,8 @@ treesit-major-mode-setup #'treesit-add-log-current-defun)) (setq-local transpose-sexps-function #'treesit-transpose-sexps) + (when treesit-sentence-type-regexp + (setq-local forward-sentence-function #'treesit-forward-sentence)) ;; Imenu. (when treesit-simple-imenu-settings commit 384504edf35751eec2be9b52be5d3b250217d68f Author: Philip Kaludercic Date: Wed Jan 11 09:27:01 2023 +0100 Ensure VC package names are not empty * lisp/emacs-lisp/package-vc.el (package-vc--unpack): Raise an error if the package name is empty. (package-vc-install): Avoid generating an empty file name, if a URL ends with a slash, and raise an error if the package name is empty. diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el index ba1a01faeee..b5b8a6746a6 100644 --- a/lisp/emacs-lisp/package-vc.el +++ b/lisp/emacs-lisp/package-vc.el @@ -606,6 +606,8 @@ package-vc--unpack (name (package-desc-name pkg-desc)) (dirname (package-desc-full-name pkg-desc)) (pkg-dir (expand-file-name dirname package-user-dir))) + (when (string-empty-p name) + (user-error "Empty package name")) (setf (package-desc-dir pkg-desc) pkg-dir) (when (file-exists-p pkg-dir) (if (yes-or-no-p (format "Overwrite previous checkout for package `%s'?" name)) @@ -773,7 +775,9 @@ package-vc-install (package-vc--archives-initialize) (let* ((name-or-url (package-vc--read-package-name "Fetch and install package: " t)) - (name (file-name-base name-or-url))) + (name (file-name-base (directory-file-name name-or-url)))) + (when (string-empty-p name) + (user-error "Empty package name")) (list name-or-url (and current-prefix-arg :last-release) nil commit 70947da708c8e06e31a2930520b38bafe43dba39 Author: Philip Kaludercic Date: Wed Jan 11 09:21:57 2023 +0100 Handle missing package description when unpacking vc packages * lisp/emacs-lisp/package-vc.el (package-vc--unpack): Create a dummy descriptor if PKG-DESC is nil. diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el index ddcfe57928b..ba1a01faeee 100644 --- a/lisp/emacs-lisp/package-vc.el +++ b/lisp/emacs-lisp/package-vc.el @@ -600,6 +600,8 @@ package-vc--unpack how to fetch and build the package. See `package-vc--archive-spec-alist' for details. The optional argument REV specifies a specific revision to checkout. This overrides the `:branch' attribute in PKG-SPEC." + (unless pkg-desc + (package-desc-create :name (car pkg-spec) :kind 'vc)) (pcase-let* (((map :lisp-dir) pkg-spec) (name (package-desc-name pkg-desc)) (dirname (package-desc-full-name pkg-desc))