emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 65468109a5 3/4: Merge from origin/emacs-29


From: Po Lu
Subject: master 65468109a5 3/4: Merge from origin/emacs-29
Date: Thu, 1 Dec 2022 01:34:00 -0500 (EST)

branch: master
commit 65468109a53c605df991f72521de5ed3b63ba6b8
Merge: 95a9bad9e8 4161023a63
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Merge from origin/emacs-29
    
    4161023a63 Fix crashes and memory leaks during display deinitialization
    785fa80159 New user option: project-vc-extra-root-markers
    7a1f1825fd Add inline to c-ts-mode--keywords
    3d976d6a03 Remove duplicate "friend" from c-ts-mode--keywords
    01e7d4b2a1 Make treesit-defun-prefer-top-level more flexible
    fb5d9ff559 Fix c-ts-mode defun movement (bug#59628)
    7397f2099b * lisp/tab-bar.el: Keep tabs of the same group together (b...
    832b013ef0 Insert news for installed packages only
    cc6efa7992 ; Fix type error in 'package-maintainers'
    ee32ae7c36 ; * etc/NEWS: Add missing tree-sitter based modes.
    33546d6dd2 ; * etc/NEWS: Move an entry to a proper place.  (bug#59718)
    8617edfffd ; Fix typos
    
    # Conflicts:
    #       etc/NEWS
---
 .dir-locals.el                       |   3 +-
 ChangeLog.3                          |   2 +-
 doc/lispref/positions.texi           |  17 +++++
 doc/man/etags.1                      |   2 +-
 doc/misc/org.org                     |   8 +--
 etc/NEWS.19                          |   4 +-
 etc/NEWS.22                          |   2 +-
 etc/NEWS.29                          |  40 +++++++----
 etc/ORG-NEWS                         |  22 +++---
 lisp/emacs-lisp/package.el           |   7 +-
 lisp/org/ob-tangle.el                |   6 +-
 lisp/org/ol.el                       |   2 +-
 lisp/org/org-agenda.el               |   2 +-
 lisp/org/org-attach.el               |   2 +-
 lisp/org/org-capture.el              |   2 +-
 lisp/org/org-compat.el               |  12 ++--
 lisp/org/org-cycle.el                |   2 +-
 lisp/org/org-element.el              |  24 +++----
 lisp/org/org-fold-core.el            |  40 +++++------
 lisp/org/org-macs.el                 |   2 +-
 lisp/org/org-persist.el              |   2 +-
 lisp/org/org.el                      |  18 ++---
 lisp/org/ox-icalendar.el             |   2 +-
 lisp/org/ox-latex.el                 |  10 +--
 lisp/progmodes/c-ts-mode.el          |  40 +++++++++--
 lisp/progmodes/project.el            | 132 +++++++++++++++++++++++++++--------
 lisp/tab-bar.el                      |  12 ++--
 lisp/treesit.el                      |  30 ++++----
 src/frame.c                          |  13 +++-
 src/xterm.c                          |  31 +++++++-
 test/lisp/progmodes/project-tests.el |  29 ++++++++
 31 files changed, 357 insertions(+), 163 deletions(-)

diff --git a/.dir-locals.el b/.dir-locals.el
index f0ab46236f..fc89dff87f 100644
--- a/.dir-locals.el
+++ b/.dir-locals.el
@@ -11,7 +11,8 @@
          (vc-prepare-patches-separately . nil)))
  (c-mode . ((c-file-style . "GNU")
             (c-noise-macro-names . ("INLINE" "NO_INLINE" 
"ATTRIBUTE_NO_SANITIZE_UNDEFINED"
-                                    "UNINIT" "CALLBACK" "ALIGN_STACK"))
+                                    "UNINIT" "CALLBACK" "ALIGN_STACK" 
"ATTRIBUTE_MALLOC"
+                                    "ATTRIBUTE_DEALLOC_FREE"))
             (electric-quote-comment . nil)
             (electric-quote-string . nil)
             (indent-tabs-mode . t)
diff --git a/ChangeLog.3 b/ChangeLog.3
index d27a14d427..e7ad130d00 100644
--- a/ChangeLog.3
+++ b/ChangeLog.3
@@ -107948,7 +107948,7 @@
 
 2019-10-12  Rolf Ade  <rolf@pointsman.de>  (tiny change)
 
-       TCL indentation fix outside functions
+       Tcl indentation fix outside functions
 
        * lisp/progmodes/tcl.el (tcl-calculate-indent): Indent code
        correctly outside of function definitions (bug#23565).
diff --git a/doc/lispref/positions.texi b/doc/lispref/positions.texi
index a01e568de0..c065cc11e2 100644
--- a/doc/lispref/positions.texi
+++ b/doc/lispref/positions.texi
@@ -850,6 +850,23 @@ For example, @code{python-mode} sets this variable to a 
regexp that
 matches either @code{function_definition} or @code{class_definition}.
 @end defvar
 
+@defvar treesit-defun-prefer-top-level
+If this variable is non-@code{nil}, Emacs skips nested defun and
+prefers the top-level defun.
+
+In some languages, a defun could be nested in another one.  Normally
+Emacs stops at the first defun it encounters.  If this variable's
+value is @code{t}, whenever Emacs finds a defun node, it tries to go
+up the parse tree and find the top-level defun.
+
+This variable can also be a list of cons cells of the form
+@w{@code{(@var{from} . @var{to}))}}, where @var{from} and @var{to} are
+regexp matching tree-sitter node types.  When Emacs finds a defun node
+whose type matches any of the @var{from} regexp in the list, Emacs
+then tries to go up the parse tree to find the top-level node matching
+the corresponding @var{to} regexp.
+@end defvar
+
 @node Skipping Characters
 @subsection Skipping Characters
 @cindex skipping characters
diff --git a/doc/man/etags.1 b/doc/man/etags.1
index 4681a9dadb..8dbea25c4c 100644
--- a/doc/man/etags.1
+++ b/doc/man/etags.1
@@ -233,7 +233,7 @@ CONFIGURATION\\)\ +[^\ ]*\ +OF/'\ \-\-regex\='/[\ \\t]*\\
 \\|PROCEDURE\\|PROCESS\\|TYPE\\)[\ \\t]+\\([^\ \\t(]+\\)/\\3/'\fP
 .br
 
-Tag TCL files (this last example shows the usage of a \fItagregexp\fP):
+Tag Tcl files (this last example shows the usage of a \fItagregexp\fP):
 .br
 \fI\-\-lang\=none \-\-regex\='/proc[\ \\t]+\\([^\ \\t]+\\)/\\1/'\fP
 
diff --git a/doc/misc/org.org b/doc/misc/org.org
index 737e5c921f..43d85099cf 100644
--- a/doc/misc/org.org
+++ b/doc/misc/org.org
@@ -13722,7 +13722,7 @@ A sample Org file with the above headers:
 #+vindex: org-export-default-language
 LaTeX packages =babel= or =polyglossia= can also be loaded in a
 document.  The "AUTO" string will be replaced in both cases by the
-appropiate value for the =LANGUAGE= keyword, if present in the
+appropriate value for the =LANGUAGE= keyword, if present in the
 document, or by the value of ~org-export-default-language~.  Let's see
 some examples in one or another case.
 
@@ -18491,7 +18491,7 @@ options; they are mutually exclusive.
 
   Ignore the results completely.  This option is similar to =none=,
   but no processing is performed on the return value.  Calling the
-  code block programatically (see [[*How to evaluate source code]]) or by
+  code block programmatically (see [[*How to evaluate source code]]) or by
   reference (see [[*Passing arguments]] and [[*Noweb Reference Syntax]]) will
   always yield nil.
 
@@ -18784,7 +18784,7 @@ a octal shorthand is defined, =oXXX= (=o= for octal). 
Using this, our
 read-only example is =:tangle-mode o444=. Omitting the =o= prefix will
 cause the argument to be interpreted as an integer, which can lead to
 unexpected results (=444= is the same as =o674=).
-Two other shorthands are recognised, ls-style strings like
+Two other shorthands are recognized, ls-style strings like
 =rw-r--r--=, and chmod-style permissions like =g+w=.
 Note that chmod-style permissions are based on
 ~org-babel-tangle-default-file-mode~, which is =#o544= by default.
@@ -18792,7 +18792,7 @@ Note that chmod-style permissions are based on
 When =:tangle-mode= and =:shebang= are both specified, the give
 =:tangle-mode= will override the permissions from =:shebang=. When
 multiple source code blocks tangle to a single file with conflicting
-=:tangle-mode= header arguments, Org's behaviour is undefined.
+=:tangle-mode= header arguments, Org's behavior is undefined.
 
 #+cindex: @samp{no-expand}, header argument
 By default Org expands code blocks during tangling.  The =no-expand=
diff --git a/etc/NEWS.19 b/etc/NEWS.19
index d21cd8187f..25f803d6e2 100644
--- a/etc/NEWS.19
+++ b/etc/NEWS.19
@@ -1111,7 +1111,7 @@ function definition, variable, or property.
 
 ** Font Lock mode
 
-*** Supports Scheme, TCL and Help modes
+*** Supports Scheme, Tcl and Help modes
 
 For example, to automatically turn on Font Lock mode in the *Help*
 buffer, put:
@@ -1735,7 +1735,7 @@ projects to define project-specific structures.  It also 
enables the
 use of etags and TAGS files for languages not supported by etags.
 
 The Emacs manual section on Tags contains explanations and examples
-for Emacs's DEFVAR, VHDL, Cobol, PostScript and TCL.
+for Emacs's DEFVAR, VHDL, Cobol, PostScript and Tcl.
 
 ** Various mode-specific commands that used to be bound to C-c LETTER
 have been moved.
diff --git a/etc/NEWS.22 b/etc/NEWS.22
index b4ecbe7039..bf172b4cc9 100644
--- a/etc/NEWS.22
+++ b/etc/NEWS.22
@@ -1993,7 +1993,7 @@ It is a modern replacement for 'zone-mode', which is now 
obsolete.
 ** 'cfengine-mode' is a major mode for editing GNU Cfengine
 configuration files.
 
-** The TCL package tcl-mode.el was replaced by tcl.el.
+** The Tcl package tcl-mode.el was replaced by tcl.el.
 This was actually done in Emacs-21.1, and was not documented.
 
 * Changes in Specialized Modes and Packages in Emacs 22.1:
diff --git a/etc/NEWS.29 b/etc/NEWS.29
index cbd1889575..a9bf0eccd8 100644
--- a/etc/NEWS.29
+++ b/etc/NEWS.29
@@ -142,11 +142,6 @@ and then execute the rest of the script file as Emacs 
Lisp.  When it
 reaches the end of the script, Emacs will exit with an exit code from
 the value of the final form.
 
-+++
-** New function 'substitute-quotes'.
-This function works like 'substitute-command-keys' but only
-substitutes quote characters.
-
 +++
 ** Emacs now supports setting 'user-emacs-directory' via '--init-directory'.
 
@@ -2968,48 +2963,58 @@ Emacs buffers, like indentation and the like.  The new 
ert function
 'ert-test-erts-file' is used to parse these files.
 
 ---
-** New mode 'js-json-mode'.
+** New major mode 'js-json-mode'.
 This is a lightweight variant of 'js-mode' that is used by default
 when visiting JSON files.
 
-** New mode 'typescript-ts-mode'.
+** New major mode 'typescript-ts-mode'.
 A major mode based on the tree-sitter library for editing programs
 in the TypeScript language.  It includes support for font-locking,
 indentation, and navigation.
 
-** New mode 'c-ts-mode'.
+** New major mode 'c-ts-mode'.
 A major mode based on the tree-sitter library for editing programs
 in the C language.  It includes support for font-locking,
 indentation, Imenu, which-func, and navigation.
 
-** New mode 'c++-ts-mode'.
+** New major mode 'c++-ts-mode'.
 A major mode based on the tree-sitter library for editing programs
 in the C++ language.  It includes support for font-locking,
 indentation, Imenu, which-func, and navigation.
 
-** New mode 'java-ts-mode'.
+** New major mode 'java-ts-mode'.
 A major mode based on the tree-sitter library for editing programs
 in the Java language.  It includes support for font-locking,
 indentation, Imenu, which-func, and navigation.
 
-** New mode 'css-ts-mode'.
+** New major mode 'python-ts-mode'.
 A major mode based on the tree-sitter library for editing programs
-in the CSS language.  It includes support for font-locking,
+in the Python language.  It includes support for font-locking,
+indentation, Imenu, which-func, and navigation.
+
+** New major mode 'css-ts-mode'.
+A major mode based on the tree-sitter library for editing CSS
+(Cascading Style Sheets).  It includes support for font-locking,
 indentation, Imenu, which-func, and navigation.
 
-** New mode 'json-ts-mode'.
+** New major mode 'json-ts-mode'.
 A major mode based on the tree-sitter library for editing programs
 in the JSON language.  It includes support for font-locking,
 indentation, Imenu, which-func, and navigation.
 
-** New mode 'csharp-ts-mode'.
+** New major mode 'csharp-ts-mode'.
 A major mode based on the tree-sitter library for editing programs
 in the C# language.  It includes support for font-locking,
 indentation, Imenu, which-func, and navigation.
 
-** New mode 'csharp-mode'.
+** New major mode 'csharp-mode'.
 A major mode based on CC Mode for editing programs in the C# language.
 
+** New major mode 'bash-ts-mode'.
+A major mode based on the tree-sitter library for editing Bash shell
+scripts.  It includes support for font-locking, indentation, Imenu,
+which-func, and navigation.
+
 
 * Incompatible Lisp Changes in Emacs 29.1
 
@@ -3018,6 +3023,11 @@ A major mode based on CC Mode for editing programs in 
the C# language.
 This means that both the prompt and 'minibuffer-default-prompt-format'
 will have key definitions and single quotes handled specially.
 
++++
+** New function 'substitute-quotes'.
+This function works like 'substitute-command-keys' but only
+substitutes quote characters.
+
 ---
 ** 'find-image' now uses 'create-image'.
 This means that images found through 'find-image' also have
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 3e941047dc..67889c0b10 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -55,7 +55,7 @@ The old folding backend used in Org is poorly scalable when 
the file
 size increases beyond few Mbs.  The symptoms usually include slow
 cursor motion, especially in long-running Emacs sessions.
 
-A new optimised folding backend is now available, and enabled by
+A new optimized folding backend is now available, and enabled by
 default.  To disable it, put the following to the Emacs config *before*
 loading Org:
 
@@ -63,14 +63,14 @@ loading Org:
 (setq org-fold-core-style 'overlays)
 #+end_src
 
-Even more performance optimisation can be enabled by customising
+Even more performance optimization can be enabled by customizing
 =org-fold-core--optimise-for-huge-buffers=.  However, this option may
 be dangerous.  Please, read the variable docstring carefully to
 understand the possible consequences.
 
 When =org-fold-core-style= is set to =text-properties=, several new
 features will become available and several notable changes will happen
-to the Org behaviour.  The new features and changes are listed below.
+to the Org behavior.  The new features and changes are listed below.
 
 **** Hidden parts of the links can now be searched and revealed during isearch
 
@@ -78,7 +78,7 @@ In the past, hidden parts of the links could not be searched 
using
 isearch (=C-s=).  Now, they are searchable by default.  The hidden
 match is also revealed temporarily during isearch.
 
-To restore the old behaviour add the following core to your Emacs
+To restore the old behavior add the following core to your Emacs
 config:
 
 #+begin_src emacs-lisp
@@ -130,13 +130,13 @@ Now, it is not the case anymore.  The drawer folding 
state is
 preserved.  The initial folding state of all the drawers in buffer is
 set according to the startup visibility settings.
 
-To restore the old behaviour, add the following code to Emacs config:
+To restore the old behavior, add the following code to Emacs config:
 
 #+begin_src emacs-lisp
 (add-hook 'org-cycle-hook #'org-cycle-hide-drawers)
 #+end_src
 
-Note that old behaviour may cause performance issues when cycling
+Note that old behavior may cause performance issues when cycling
 headline visibility in large buffers.
 
 **** =outline-*= functions may no longer work correctly in Org mode
@@ -338,7 +338,7 @@ This is done by adding =#+ATTR_LATEX: :mode tabbing= at the 
top
 of the table.
 The default column width is set to 1/n times the latex textwidth,
 where n is the number of columns.
-This behaviour can be changed by supplying a =:align= parameter.
+This behavior can be changed by supplying a =:align= parameter.
 
 The tabbing environment can be useful when generating simple tables which
 can be span multiple pages and when table cells are allowed to overflow.
@@ -527,7 +527,7 @@ Diagnostic information about execution speed can be 
provided according
 to ~org-element--cache-map-statistics~ and
 ~org-element--cache-map-statistics-threshold~.
 
-~org-scan-tags~ and tag views in agenda utilise the new function.
+~org-scan-tags~ and tag views in agenda utilize the new function.
 *** New function ~org-element-at-point-no-context~
 
 This function is like ~org-element-at-point~, but it does not try to
@@ -552,10 +552,10 @@ argument.
 This function is intended for us in the definition of a ~kbd~ macro in
 files that are exported to Texinfo.
 
-*** =org-at-heading-p= now recognises optional argument. Its meaning is 
inverted.
+*** =org-at-heading-p= now recognizes optional argument. Its meaning is 
inverted.
 
 =org-at-heading-p= now returns t by default on headings inside folds.
-Passing optional argument will produce the old behaviour.
+Passing optional argument will produce the old behavior.
 
 *** =org-babel-execute:plantuml= can output ASCII graphs in the buffer
 
@@ -679,7 +679,7 @@ a function (called with the same arguments as
 
 An example of a such function for =info:= links is
 ~org-info-description-as-command~.  To access a manual section outside
-of Org, description may be pasted to shell prompt or evaluated withing
+of Org, description may be pasted to shell prompt or evaluated within
 Emacs using =M-:= (wrapped into parenthesis).  For example,
 description of the =info:org#Tags= link is =info "(org) Tags"=.  To
 restore earlier behavior add to your Emacs init file the following:
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 8d44fae30a..f10dc91572 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -2696,7 +2696,10 @@ Helper function for `describe-package'."
          (signed (if desc (package-desc-signed desc)))
          (maintainer (cdr (assoc :maintainer extras)))
          (authors (cdr (assoc :authors extras)))
-         (news (and-let* ((file (expand-file-name "news" pkg-dir))
+         (news (and-let* (pkg-dir
+                          ((not built-in))
+                          (file (expand-file-name "news" pkg-dir))
+                          ((file-regular-p file))
                           ((file-readable-p file)))
                  file)))
     (when (string= status "avail-obso")
@@ -4549,7 +4552,7 @@ will be signaled in that case."
       (user-error "Package `%s' has no explicit maintainer" name))
      ((and (not (progn
                   (require 'ietf-drums)
-                  (ietf-drums-parse-address maint)))
+                  (ietf-drums-parse-address (cdr maint))))
            (null no-error))
       (user-error "Package `%s' has no maintainer address" name))
      ((not (null maint))
diff --git a/lisp/org/ob-tangle.el b/lisp/org/ob-tangle.el
index e86f4e5286..bd17bda32b 100644
--- a/lisp/org/ob-tangle.el
+++ b/lisp/org/ob-tangle.el
@@ -339,7 +339,7 @@ matching a regular expression."
 
 (defun org-babel-interpret-file-mode (mode)
   "Determine the integer representation of a file MODE specification.
-The following forms are currently recognised:
+The following forms are currently recognized:
 - an integer (returned without modification)
 - \"o755\" (chmod style octal)
 - \"rwxrw-r--\" (ls style specification)
@@ -354,7 +354,7 @@ The following forms are currently recognised:
       (user-error "%1$o is not a valid file mode octal. \
 Did you give the decimal value %1$d by mistake?" mode)))
    ((not (stringp mode))
-    (error "File mode %S not recognised as a valid format." mode))
+    (error "File mode %S not recognized as a valid format." mode))
    ((string-match-p "^o0?[0-7][0-7][0-7]$" mode)
     (string-to-number (replace-regexp-in-string "^o" "" mode) 8))
    ((string-match-p 
"^[ugoa]*\\(?:[+-=][rwxXstugo]*\\)+\\(,[ugoa]*\\(?:[+-=][rwxXstugo]*\\)+\\)*$" 
mode)
@@ -365,7 +365,7 @@ Did you give the decimal value %1$d by mistake?" mode)))
                                             ",g=" (substring mode 3 6)
                                             ",o=" (substring mode 6 9))
                                    0))
-   (t (error "File mode %S not recognised as a valid format. See 
`org-babel-interpret-file-mode'." mode))))
+   (t (error "File mode %S not recognized as a valid format. See 
`org-babel-interpret-file-mode'." mode))))
 
 (defun org-babel-tangle-clean ()
   "Remove comments inserted by `org-babel-tangle'.
diff --git a/lisp/org/ol.el b/lisp/org/ol.el
index 0b4457b003..cd52e9cf4d 100644
--- a/lisp/org/ol.el
+++ b/lisp/org/ol.el
@@ -150,7 +150,7 @@ link.
   called with two arguments: the link location (a string such as
   \"~/foobar\", \"id:some-org-id\" or \"https://www.foo.com\";)
   and the description generated by `org-insert-link'.  It should
-  return the description to use (this reflects the behaviour of
+  return the description to use (this reflects the behavior of
   `org-link-make-description-function').  If it returns nil, no
   default description is used, but no error is thrown (from the
   user's perspective, this is equivalent to a default description
diff --git a/lisp/org/org-agenda.el b/lisp/org/org-agenda.el
index aecfc3d81c..eda2489384 100644
--- a/lisp/org/org-agenda.el
+++ b/lisp/org/org-agenda.el
@@ -5943,7 +5943,7 @@ displayed in agenda view."
     (goto-char (point-min))
     (while (re-search-forward regexp nil t)
       (catch :skip
-        ;; We do not run `org-agenda-skip' righ away because every single sexp
+        ;; We do not run `org-agenda-skip' right away because every single sexp
         ;; in the buffer is matched here, unlike day-specific search
         ;; in ordinary timestamps.  Most of the sexps will not match
         ;; the agenda day and it is quicker to run `org-agenda-skip' only for
diff --git a/lisp/org/org-attach.el b/lisp/org/org-attach.el
index f85811dc7f..41f3a568c0 100644
--- a/lisp/org/org-attach.el
+++ b/lisp/org/org-attach.el
@@ -524,7 +524,7 @@ DIR-property exists (that is different from the unset one)."
   "Attach URL."
   (interactive "MURL of the file to attach: \n")
   (let ((org-attach-method 'url)
-        (org-safe-remote-resources ; Assume saftey if in an interactive 
session.
+        (org-safe-remote-resources ; Assume safety if in an interactive 
session.
          (if noninteractive org-safe-remote-resources '(""))))
     (org-attach-attach url)))
 
diff --git a/lisp/org/org-capture.el b/lisp/org/org-capture.el
index df401d6a6c..b26afeb036 100644
--- a/lisp/org/org-capture.el
+++ b/lisp/org/org-capture.el
@@ -757,7 +757,7 @@ of the day at point (if any) or the current HH:MM time."
      (_ "* Invalid capture template"))))
 
 (defun org-capture--run-template-functions (keyword &optional local)
-  "Run funcitons associated with KEYWORD on template's plist.
+  "Run functions associated with KEYWORD on template's plist.
 For valid values of KEYWORD see `org-capture-templates'.
 If LOCAL is non-nil use the buffer-local value of `org-capture-plist'."
   ;; Used in place of `run-hooks' because these functions have no associated 
symbol.
diff --git a/lisp/org/org-compat.el b/lisp/org/org-compat.el
index 2f29754f1b..483f8844c3 100644
--- a/lisp/org/org-compat.el
+++ b/lisp/org/org-compat.el
@@ -1543,7 +1543,7 @@ key."
   "Run `org-fold-region' when in org-mode."
   (if (derived-mode-p 'org-mode)
       (org-fold-region (max from (point-min)) (min to (point-max)) flag 
'headline)
-    ;; Apply EXTRA to avoid breakages if adviced function definition
+    ;; Apply EXTRA to avoid breakages if advised function definition
     ;; changes.
     (apply oldfun from to flag extra)))
 
@@ -1551,7 +1551,7 @@ key."
   "Run `org-next-visible-heading' when in org-mode."
   (if (derived-mode-p 'org-mode)
       (org-next-visible-heading arg)
-    ;; Apply EXTRA to avoid breakages if adviced function definition
+    ;; Apply EXTRA to avoid breakages if advised function definition
     ;; changes.
     (apply oldfun arg extra)))
 
@@ -1571,7 +1571,7 @@ key."
                                   (point)))))
              (goto-char found)
              found)))
-    ;; Apply EXTRA to avoid breakages if adviced function definition
+    ;; Apply EXTRA to avoid breakages if advised function definition
     ;; changes.
     (apply oldfun invisible-ok extra)))
 
@@ -1579,7 +1579,7 @@ key."
   "Run `org-at-heading-p' when in org-mode."
   (if (derived-mode-p 'org-mode)
       (org-at-heading-p (not invisible-ok))
-    ;; Apply EXTRA to avoid breakages if adviced function definition
+    ;; Apply EXTRA to avoid breakages if advised function definition
     ;; changes.
     (apply oldfun invisible-ok extra)))
 
@@ -1587,7 +1587,7 @@ key."
   "Run `org-fold-hide-sublevels' when in org-mode."
   (if (derived-mode-p 'org-mode)
       (org-fold-hide-sublevels levels)
-    ;; Apply EXTRA to avoid breakages if adviced function definition
+    ;; Apply EXTRA to avoid breakages if advised function definition
     ;; changes.
     (apply oldfun levels extra)))
 
@@ -1600,7 +1600,7 @@ key."
             (org-fold-hide-subtree)
           (org-fold-show-children)
           (org-fold-show-entry 'hide-drawers)))
-    ;; Apply EXTRA to avoid breakages if adviced function definition
+    ;; Apply EXTRA to avoid breakages if advised function definition
     ;; changes.
     (apply oldfun extra)))
 
diff --git a/lisp/org/org-cycle.el b/lisp/org/org-cycle.el
index c06af06d95..9531ac4c8c 100644
--- a/lisp/org/org-cycle.el
+++ b/lisp/org/org-cycle.el
@@ -87,7 +87,7 @@
 (defvar-local org-cycle-subtree-status nil)
 (put 'org-cycle-subtree-status 'org-state t)
 
-;;;; Customisation:
+;;;; Customization:
 
 
 (defgroup org-cycle nil
diff --git a/lisp/org/org-element.el b/lisp/org/org-element.el
index a290b4121f..48ede9c528 100644
--- a/lisp/org/org-element.el
+++ b/lisp/org/org-element.el
@@ -713,11 +713,11 @@ is cleared and contents are removed in the process."
            ;; DATUM is i.e. a headline, it's property list (`:title'
            ;; in case of headline) can contain parsed objects.  The
            ;; objects will contain `:parent' property set to the DATUM
-           ;; itself.  When copied, these inner `:parent' propery
+           ;; itself.  When copied, these inner `:parent' property
            ;; values will contain incorrect object decoupled from
            ;; DATUM.  Changes to the DATUM copy will not longer be
            ;; reflected in the `:parent' properties.  So, we need to
-           ;; reassign inner `:parent' propreties to the DATUM copy
+           ;; reassign inner `:parent' properties to the DATUM copy
            ;; explicitly.
            (org-element-map element-copy (cons 'plain-text 
org-element-all-objects)
              (lambda (obj) (when (equal datum (org-element-property :parent 
obj))
@@ -4780,7 +4780,7 @@ Elements are accumulated into ACC."
                            ;; elements.  Below code reassigns
                            ;; `:parent' property of the element and
                            ;; may interfere with cache
-                           ;; synchronisation if parent element is not
+                           ;; synchronization if parent element is not
                            ;; yet in cache.  Moreover, the returned
                            ;; structure may be altered by caller code
                            ;; arbitrarily.  Hence, we return a copy of
@@ -5434,14 +5434,14 @@ OFFSET and, if they belong to element PARENT, are 
adopted by it.
 
 PHASE specifies the phase number, as an integer.
 
-For any synchronisation request, all the later requests in the cache
+For any synchronization request, all the later requests in the cache
 must not start at or before END.  See `org-element--cache-submit-request'.")
 
 (defvar-local org-element--cache-sync-timer nil
   "Timer used for cache synchronization.")
 
 (defvar-local org-element--cache-sync-keys-value nil
-  "Id value used to identify keys during synchronisation.
+  "Id value used to identify keys during synchronization.
 See `org-element--cache-key' for more information.")
 
 (defvar-local org-element--cache-change-tic nil
@@ -5468,9 +5468,9 @@ See `org-element--cache-key' for more information.")
 This variable is used to determine when re-parsing buffer is not going
 to slow down the command.
 
-If the commends end up modifying the cache, the worst case scenario is
+If the commands end up modifying the cache, the worst case scenario is
 performance drop.  So, advicing these commands is safe.  Yet, it is
-better to remove the commands adviced in such way from this list.")
+better to remove the commands advised in such a way from this list.")
 
 (defmacro org-element--request-key (request)
   "Get NEXT part of a `org-element--cache-sync-requests' REQUEST."
@@ -6291,7 +6291,7 @@ completing the request."
                 (key (org-element--cache-key data)))
             ;; Traverse the cache tree.  Ignore all the elements before
             ;; START.  Note that `avl-tree-stack' would not bypass the
-            ;; elements before START and thus would have beeen less
+            ;; elements before START and thus would have been less
             ;; efficient.
            (if (and leftp (avl-tree--node-left node)
                     (not (org-element--cache-key-less-p key start)))
@@ -6793,7 +6793,7 @@ By default (when this variable is nil), cache re-parses 
modified
 headlines immediately after modification preserving all the unaffected
 elements inside the headline.
 
-The default behaviour works best when users types inside Org buffer of
+The default behavior works best when users types inside Org buffer of
 when buffer modifications are mixed with cache requests.  However,
 large automated edits inserting/deleting many headlines are somewhat
 slower by default (as in `org-archive-subtree').  Let-binding this
@@ -7383,7 +7383,7 @@ the cache."
     (save-excursion
       (save-restriction
         (unless narrow (widen))
-        ;; Synchronise cache up to the end of mapped region.
+        ;; Synchronize cache up to the end of mapped region.
         (org-element-at-point to-pos)
         (cl-macrolet ((cache-root
                         ;; Use the most optimal version of cache available.
@@ -7418,7 +7418,7 @@ the cache."
                         ;; point.
                         () `(progn
                               ;; Parsing is one of the performance
-                              ;; bottlenecks.  Make sure to optimise it as
+                              ;; bottlenecks.  Make sure to optimize it as
                               ;; much as possible.
                               ;;
                               ;; Avoid extra staff like timer cancels et al
@@ -7737,7 +7737,7 @@ the cache."
                       ;; longer trust STACK.
                       (cache-walk-restart)))
                   ;; Second, move to the right branch of the tree or skip
-                  ;; it alltogether.
+                  ;; it altogether.
                   (if continue-flag
                      (setq continue-flag nil)
                    (setq node (if (and (car stack)
diff --git a/lisp/org/org-fold-core.el b/lisp/org/org-fold-core.el
index 692c51a74c..be600f8a0c 100644
--- a/lisp/org/org-fold-core.el
+++ b/lisp/org/org-fold-core.el
@@ -78,7 +78,7 @@
 
 ;; Similar to 'org-fold-visible, display of any arbitrary folding spec
 ;; can be configured using folding spec properties.  In particular,
-;; `:visible' folding spec proprety controls whether the folded text
+;; `:visible' folding spec property controls whether the folded text
 ;; is visible or not.  If the `:visible' folding spec property is nil,
 ;; folded text is hidden or displayed as a constant string (ellipsis)
 ;; according to the value of `:ellipsis' folding spec property.  See
@@ -91,7 +91,7 @@
 ;; If necessary, one can add or remove folding specs using
 ;; `org-fold-core-add-folding-spec' and `org-fold-core-remove-folding-spec'.
 
-;; If a buffer initialised with `org-fold-core-initialize' is cloned into 
indirect
+;; If a buffer initialized with `org-fold-core-initialize' is cloned into 
indirect
 ;; buffers, it's folding state is copied to that indirect buffer.
 ;; The folding states are independent.
 
@@ -148,7 +148,7 @@
 ;; same spec can be used for fold different syntaxical structures.
 ;; Any folding spec can be additionally referenced by a symbol listed
 ;; in the spec's `:alias' folding spec property.  For example, Org
-;; mode's `org-fold-outline' folding spec can be referened as any
+;; mode's `org-fold-outline' folding spec can be referenced as any
 ;; symbol from the following list: '(headline heading outline
 ;; inlinetask plain-list) The list is the value of the spec's `:alias'
 ;; property.
@@ -170,7 +170,7 @@
 ;; possible to control to unfold it temporarily during interactive
 ;; isearch session.
 
-;; The isearch behaviour is controlled on per-folding-spec basis by
+;; The isearch behavior is controlled on per-folding-spec basis by
 ;; setting `isearch-open' and `isearch-ignore' folding spec
 ;; properties.  The the docstring of `org-fold-core--specs' for more details.
 
@@ -179,12 +179,12 @@
 ;; The visibility of the text inserted in front, rear, or in the
 ;; middle of a folded region is managed according to `:front-sticky'
 ;; and `:rear-sticky' folding properties of the corresponding folding
-;; spec.  The rules are the same with stickyness of text properties in
+;; spec.  The rules are the same with stickiness of text properties in
 ;; Elisp.
 
 ;; If a text being inserted into the buffer is already folded and
-;; invisible (before applying the stickyness rules), then it is
-;; revealed.  This behaviour can be changed by wrapping the insertion
+;; invisible (before applying the stickiness rules), then it is
+;; revealed.  This behavior can be changed by wrapping the insertion
 ;; code into `org-fold-core-ignore-modifications' macro.  The macro will 
disable
 ;; all the processing related to buffer modifications.
 
@@ -233,13 +233,13 @@
 ;; visible part of a buffer may cause noticeable lags (which is still
 ;; orders of magnitude better in comparison with overlays).  If the
 ;; performance issues become critical while using this library, it is
-;; recommended to minimise the number of folding specs used in the
+;; recommended to minimize the number of folding specs used in the
 ;; same buffer at a time.
 
 ;; Alternatively, the library provides 
`org-fold-core--optimise-for-huge-buffers'
 ;; for additional speedup.  This can be used as a file-local variable
 ;; in huge buffers.  The variable can be set to enable various levels
-;; of extra optimisation.  See the docstring for detailed information.
+;; of extra optimization.  See the docstring for detailed information.
 
 ;; It is worth noting that when using 
`org-fold-core--optimise-for-huge-buffers'
 ;; with `grab-invisible' option, folded regions copied to other
@@ -250,7 +250,7 @@
 
 ;; Another possible bottleneck is the fragility check after the change
 ;; related to the folded text.  The functions used in `:fragile'
-;; folding properties must be optimised.  Also,
+;; folding properties must be optimized.  Also,
 ;; `org-fold-core-ignore-fragility-checks' or even 
`org-fold-core-ignore-modifications' may be
 ;; used when appropriate in the performance-critical code.  When
 ;; inserting text from within `org-fold-core-ignore-modifications' macro, it is
@@ -302,7 +302,7 @@ be revealed.")
 (defvar-local org-fold-core--optimise-for-huge-buffers nil
   "Non-nil turns on extra speedup on huge buffers (Mbs of folded text).
 
-This setting is risky and may cause various artefacts and degraded
+This setting is risky and may cause various artifacts and degraded
 functionality, especially when using external packages.  It is
 recommended to enable it on per-buffer basis as file-local variable.
 
@@ -337,7 +337,7 @@ following symbols:
   used.
 
 - `merge-folds': Do not distinguish between different types of folding
-  specs.  This is the most aggressive optimisation with unforeseen and
+  specs.  This is the most aggressive optimization with unforeseen and
   potentially drastic effects.")
 (put 'org-fold-core--optimise-for-huge-buffers 'safe-local-variable 'listp)
 
@@ -355,7 +355,7 @@ following symbols:
   "Folding specs defined in current buffer.
 
 Each spec is a list (SPEC-SYMBOL SPEC-PROPERTIES).
-SPEC-SYMBOL is the symbol respresenting the folding spec.
+SPEC-SYMBOL is the symbol representing the folding spec.
 SPEC-PROPERTIES is an alist defining folding spec properties.
 
 If a text region is folded using multiple specs, only the folding spec
@@ -600,7 +600,7 @@ unless RETURN-ONLY is non-nil."
                                                  
(org-fold-core-folding-spec-list)))
                                    (remove (assq 'invisible 
char-property-alias-alist)
                                            char-property-alias-alist)))
-                  ;; Set folding property stickyness according to
+                  ;; Set folding property stickiness according to
                   ;; their `:font-sticky' and `:rear-sticky'
                   ;; parameters.
                   (let (full-prop-list)
@@ -1185,7 +1185,7 @@ instead of text properties.  The created overlays will be 
stored in
            ;; We do not want it here.
            (with-silent-modifications
               (org-fold-core-region (car region) (cdr region) nil spec)
-             ;; The overlay is modelled after `outline-flag-region'
+             ;; The overlay is modeled after `outline-flag-region'
              ;; [2020-05-09 Sat] overlay for 'outline blocks.
              (let ((o (make-overlay (car region) (cdr region) nil 
'front-advance)))
                (overlay-put o 'evaporate t)
@@ -1303,7 +1303,7 @@ property, unfold the region if the :fragile function 
returns non-nil."
               (unless (org-fold-core-region-folded-p from to spec)
                (let ((spec-to (org-fold-core-get-folding-spec spec (min to (1- 
(point-max)))))
                      (spec-from (org-fold-core-get-folding-spec spec (max 
(point-min) (1- from)))))
-                  ;; Reveal folds around undoed deletion.
+                  ;; Reveal folds around undone deletion.
                   (when undo-in-progress
                     (let ((lregion (org-fold-core-get-region-at-point spec 
(max (point-min) (1- from))))
                           (rregion (org-fold-core-get-region-at-point spec 
(min to (1- (point-max))))))
@@ -1412,7 +1412,7 @@ property, unfold the region if the :fragile function 
returns non-nil."
 ;; To avoid the above situation, we simply clear all the properties,
 ;; unrealated to current buffer when a text is copied.
 ;; FIXME: Ideally, we may want to carry the folding state of copied
-;; text between buffer (probably via user customisation).
+;; text between buffer (probably via user customization).
 (defun org-fold-core--buffer-substring-filter (beg end &optional delete)
   "Clear folding state in killed text.
 This function is intended to be used as `filter-buffer-substring-function'.
@@ -1421,7 +1421,7 @@ The arguments and return value are as specified for 
`filter-buffer-substring'."
        ;; The list will be used as an argument to `remove-text-properties'.
        props-list)
     ;; There is no easy way to examine all the text properties of a
-    ;; string, so we utilise the fact that printed string
+    ;; string, so we utilize the fact that printed string
     ;; representation lists all its properties.
     ;; Loop over the elements of string representation.
     (unless (or (string= "" return-string)
@@ -1481,7 +1481,7 @@ The arguments and return value are as specified for 
`filter-buffer-substring'."
     return-string))
 
 (defun org-fold-core-update-optimisation (beg end)
-  "Update huge buffer optimisation between BEG and END.
+  "Update huge buffer optimization between BEG and END.
 See `org-fold-core--optimise-for-huge-buffers'."
   (when (and (memql 'grab-invisible org-fold-core--optimise-for-huge-buffers)
              (eq org-fold-core-style 'text-properties))
@@ -1494,7 +1494,7 @@ See `org-fold-core--optimise-for-huge-buffers'."
         (setq pos (org-fold-core-next-folding-state-change (caar 
org-fold-core--specs) pos end))))))
 
 (defun org-fold-core-remove-optimisation (beg end)
-  "Remove huge buffer optimisation between BEG and END.
+  "Remove huge buffer optimization between BEG and END.
 See `org-fold-core--optimise-for-huge-buffers'."
   (when (and (memql 'grab-invisible org-fold-core--optimise-for-huge-buffers)
              (eq org-fold-core-style 'text-properties))
diff --git a/lisp/org/org-macs.el b/lisp/org/org-macs.el
index 9188999007..0c6a2173d2 100644
--- a/lisp/org/org-macs.el
+++ b/lisp/org/org-macs.el
@@ -1082,7 +1082,7 @@ Return width in pixels when PIXELS is non-nil."
         (setq-local buffer-invisibility-spec
                     (if (listp current-invisibility-spec)
                         (mapcar (lambda (el)
-                                  ;; Consider elipsis to have 0 width.
+                                  ;; Consider ellipsis to have 0 width.
                                   ;; It is what Emacs 28+ does, but we have
                                   ;; to force it in earlier Emacs versions.
                                   (if (and (consp el) (cdr el))
diff --git a/lisp/org/org-persist.el b/lisp/org/org-persist.el
index d60fdc657a..108292f1e9 100644
--- a/lisp/org/org-persist.el
+++ b/lisp/org/org-persist.el
@@ -189,7 +189,7 @@
 (defcustom org-persist-remote-files 100
   "Whether to keep persistent data for remote files.
 
-When this variable is nil, never save persitent data associated with
+When this variable is nil, never save persistent data associated with
 remote files.  When t, always keep the data.  When
 `check-existence', contact remote server containing the file and only
 keep the data when the file exists on the server.  When a number, keep
diff --git a/lisp/org/org.el b/lisp/org/org.el
index a05a282293..be922a5da0 100644
--- a/lisp/org/org.el
+++ b/lisp/org/org.el
@@ -1383,13 +1383,13 @@ For more examples, see the system specific constants
 (defcustom org-resource-download-policy 'prompt
   "The policy applied to requests to obtain remote resources.
 
-This affects keywords like #+setupfile and #+incude on export,
+This affects keywords like #+setupfile and #+include on export,
 `org-persist-write:url',and `org-attach-url' in non-interactive
 Emacs sessions.
 
-This recognises four possible values:
+This recognizes four possible values:
 - t, remote resources should always be downloaded.
-- prompt, you will be prompted to download resources nt considered safe.
+- prompt, you will be prompted to download resources not considered safe.
 - safe, only resources considered safe will be downloaded.
 - nil, never download remote resources.
 
@@ -4625,7 +4625,7 @@ returns non-nil if any of them match."
                 ", which is not considered safe.\n\n"
                 "Do you want to download this?  You can type\n "
                 (propertize "!" 'face 'success)
-                " to download this resource, and permanantly mark it as 
safe.\n "
+                " to download this resource, and permanently mark it as 
safe.\n "
                 (if domain
                     (concat
                      (propertize "d" 'face 'success)
@@ -4636,7 +4636,7 @@ returns non-nil if any of them match."
                 (propertize "f" 'face 'success)
                 (if current-file
                     (concat
-                     " to download this resource, and permanantly mark all 
resources in "
+                     " to download this resource, and permanently mark all 
resources in "
                      (propertize current-file 'face 'underline)
                      " as safe.\n ")
                   "")
@@ -4764,7 +4764,7 @@ This is for getting out of special buffers like capture.")
 (defvar org-element-cache-persistent); Defined in org-element.el
 (defvar org-element-use-cache); Defined in org-element.el
 (defvar org-mode-loading nil
-  "Non-nil during Org mode initialisation.")
+  "Non-nil during Org mode initialization.")
 
 (defvar org-agenda-file-menu-enabled t
   "When non-nil, refresh Agenda files in Org menu when loading Org.")
@@ -5270,7 +5270,7 @@ This includes angle, plain, and bracket links."
                (progn
                   (add-face-text-property start end face-property)
                  (add-text-properties start end properties))
-              ;; Initialise folding when used outside org-mode.
+              ;; Initialize folding when used outside org-mode.
               (unless (or (derived-mode-p 'org-mode)
                          (and (org-fold-folding-spec-p 'org-link-description)
                                (org-fold-folding-spec-p 'org-link)))
@@ -5287,7 +5287,7 @@ This includes angle, plain, and bracket links."
                   (org-fold-core-set-folding-spec-property spec :visible t))
                 (org-fold-region start end nil 'org-link)
                 (org-fold-region start end nil 'org-link-description)
-                ;; We are folding the whole emphasised text with SPEC
+                ;; We are folding the whole emphasized text with SPEC
                 ;; first.  It makes everything invisible (or whatever
                 ;; the user wants).
                 (org-fold-region start end t spec)
@@ -6407,7 +6407,7 @@ Return nil before first heading."
                            "" h))
                          (h h)))
              (tags (and (not no-tags) (match-string 5))))
-          ;; Restore cleared optimisation.
+          ;; Restore cleared optimization.
           (org-fold-core-update-optimisation (match-beginning 0) (match-end 0))
          (mapconcat #'identity
                     (delq nil (list todo priority headline tags))
diff --git a/lisp/org/ox-icalendar.el b/lisp/org/ox-icalendar.el
index f4c904da4a..cfbfabafb0 100644
--- a/lisp/org/ox-icalendar.el
+++ b/lisp/org/ox-icalendar.el
@@ -75,7 +75,7 @@ for timed events.  If non-zero, alarms are created.
 (defcustom org-icalendar-force-alarm nil
   "Non-nil means alarm will be created even if is set to zero.
 
-This overrides default behaviour where zero means no alarm.  With
+This overrides default behavior where zero means no alarm.  With
 this set to non-nil and alarm set to zero, alarm will be created
 and will fire at the event start."
   :group 'org-export-icalendar
diff --git a/lisp/org/ox-latex.el b/lisp/org/ox-latex.el
index 46a348a68f..5b29a284c9 100644
--- a/lisp/org/ox-latex.el
+++ b/lisp/org/ox-latex.el
@@ -928,7 +928,7 @@ The function should return the string to be exported."
 (defcustom org-latex-src-block-backend 'verbatim
   "Backend used to generate source code listings.
 
-This sets the behaviour for fontifying source code, possibly even with
+This sets the behavior for fontifying source code, possibly even with
 color.  There are four implementations of this functionality you may
 choose from (ordered from least to most capable):
 1. Verbatim
@@ -942,7 +942,7 @@ highlighting (listings), or none at all (verbatim).
 When using listings, you also need to make use of LaTeX package
 \"listings\".  The \"color\" LaTeX package is also needed if you
 would like color too.  These can simply be added to
-`org-latex-packages-alist', using customise or something like:
+`org-latex-packages-alist', using customize or something like:
 
   (require \\='ox-latex)
   (add-to-list \\='org-latex-packages-alist \\='(\"\" \"listings\"))
@@ -981,7 +981,7 @@ Emacs' font-lock information.  This requires the Emacs 
package
 engrave-faces (available from ELPA), and the LaTeX package
 fvextra be installed.
 
-The styling of the engraved result can be customised with
+The styling of the engraved result can be customized with
 `org-latex-engraved-preamble' and `org-latex-engraved-options'.
 The default preamble also uses the LaTeX package tcolorbox in
 addition to fvextra."
@@ -1202,11 +1202,11 @@ as long as it:
   \"Verbatim\" environments (provided by fvextra) will be wrapped with.
 
 In the default value the colors \"EFD\" and \"EfD\" are provided
-as they are respectively the foreground and background colours,
+as they are respectively the foreground and background colors,
 just in case they aren't provided by the generated preamble, so
 we can assume they are always set.
 
-Within this preamble there are two recognised macro-like placeholders:
+Within this preamble there are two recognized macro-like placeholders:
 
   [FVEXTRA-SETUP]
 
diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index a79dabcd31..f802a6ddb2 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -168,7 +168,7 @@ MODE is either `c' or `cpp'."
   (let ((c-keywords
          '("break" "case" "const" "continue"
            "default" "do" "else" "enum"
-           "extern" "for" "goto" "if"
+           "extern" "for" "goto" "if" "inline"
            "long" "register" "return" "short"
            "signed" "sizeof" "static" "struct"
            "switch" "typedef" "union" "unsigned"
@@ -179,7 +179,7 @@ MODE is either `c' or `cpp'."
                   "catch" "class" "co_await" "co_return"
                   "co_yield" "compl" "concept" "consteval"
                   "constexpr" "constinit" "decltype" "delete"
-                  "explicit" "final" "friend" "friend"
+                  "explicit" "final" "friend"
                   "mutable" "namespace" "new" "noexcept"
                   "not" "not_eq" "operator" "or"
                   "or_eq" "override" "private" "protected"
@@ -505,6 +505,19 @@ the subtrees."
      (when var-index `(("Variable" . ,var-index)))
      (when func-index `(("Function" . ,func-index))))))
 
+(defun c-ts-mode--end-of-defun ()
+  "`end-of-defun-function' of `c-ts-mode'."
+  ;; A struct/enum/union_specifier node doesn't include the ; at the
+  ;; end, so we manually skip it.
+  (treesit-end-of-defun)
+  (when (looking-at (rx (* " ") ";"))
+    (goto-char (match-end 0))
+    ;; This part is copied from `end-of-defun'.
+    (unless (bolp)
+      (skip-chars-forward " \t")
+      (if (looking-at "\\s<\\|\n")
+         (forward-line 1)))))
+
 ;;;###autoload
 (define-derived-mode c-ts-mode--base-mode prog-mode "C"
   "Major mode for editing C, powered by tree-sitter."
@@ -512,8 +525,15 @@ the subtrees."
 
   ;; Navigation.
   (setq-local treesit-defun-type-regexp
-              (rx (or "specifier"
-                      "definition")))
+              (rx (or "function_definition"
+                      "type_definition"
+                      "struct_specifier"
+                      "enum_specifier"
+                      "union_specifier")))
+
+  ;; Nodes like struct/enum/union_specifier can appear in
+  ;; function_definitions, so we need to find the top-level node.
+  (setq-local treesit-defun-prefer-top-level t)
 
   ;; Indent.
   (when (eq c-ts-mode-indent-style 'linux)
@@ -559,7 +579,11 @@ the subtrees."
   ;; Font-lock.
   (setq-local treesit-font-lock-settings (c-ts-mode--font-lock-settings 'c))
 
-  (treesit-major-mode-setup))
+  (treesit-major-mode-setup)
+
+  ;; Override default value of end-of-defun-function set by
+  ;; `treesit-major-mode-setup'.
+  (setq-local end-of-defun-function #'c-ts-mode--end-of-defun))
 
 ;;;###autoload
 (define-derived-mode c++-ts-mode c-ts-mode--base-mode "C++"
@@ -587,7 +611,11 @@ the subtrees."
   ;; Font-lock.
   (setq-local treesit-font-lock-settings (c-ts-mode--font-lock-settings 'cpp))
 
-  (treesit-major-mode-setup))
+  (treesit-major-mode-setup)
+
+  ;; Override default value of end-of-defun-function set by
+  ;; `treesit-major-mode-setup'.
+  (setq-local end-of-defun-function #'c-ts-mode--end-of-defun))
 
 (provide 'c-ts-mode)
 
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index cc28bddff2..dfd3d5c7ab 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1,7 +1,7 @@
 ;;; project.el --- Operations on the current project  -*- lexical-binding: t; 
-*-
 
 ;; Copyright (C) 2015-2022 Free Software Foundation, Inc.
-;; Version: 0.8.3
+;; Version: 0.9.0
 ;; Package-Requires: ((emacs "26.1") (xref "1.4.0"))
 
 ;; This is a GNU ELPA :core package.  Avoid using functionality that
@@ -58,13 +58,30 @@
 ;;
 ;; This list can change in future versions.
 ;;
-;; VC project:
+;; Transient project:
+;;
+;; An instance of this type can be returned by `project-current' if no
+;; project was detected automatically, and the user had to pick a
+;; directory manually.  The fileset it describes is the whole
+;; directory, with the exception of some standard ignored files and
+;; directories.  This type has little purpose otherwise, as the only
+;; generic function it provides an override for is `project-root'.
+;;
+;; VC-aware project:
 ;;
 ;; Originally conceived as an example implementation, now it's a
 ;; relatively fast backend that delegates to 'git ls-files' or 'hg
 ;; status' to list the project's files.  It honors the VC ignore
 ;; files, but supports additions to the list using the user option
-;; `project-vc-ignores' (usually through .dir-locals.el).
+;; `project-vc-ignores' (usually through .dir-locals.el).  See the
+;; customization group `project-vc' for other options that control its
+;; behavior.
+;;
+;; If the repository is using any other VCS than Git or Hg, the file
+;; listing uses the default mechanism based on `find-program'.
+;;
+;; This project type can also be used for non-VCS controlled
+;; directories, see the variable `project-vc-extra-root-markers'.
 ;;
 ;; Utils:
 ;;
@@ -377,7 +394,7 @@ the buffer's value of `default-directory'."
     (nreverse bufs)))
 
 (defgroup project-vc nil
-  "Project implementation based on the VC package."
+  "VC-aware project implementation."
   :version "25.1"
   :group 'project)
 
@@ -397,21 +414,50 @@ you might have to restart Emacs to see the effect."
   :safe #'booleanp)
 
 (defcustom project-vc-include-untracked t
-  "When non-nil, the VC project backend includes untracked files."
+  "When non-nil, the VC-aware project backend includes untracked files."
   :type 'boolean
   :version "29.1"
   :safe #'booleanp)
 
 (defcustom project-vc-name nil
-  "When non-nil, the name of the current VC project.
+  "When non-nil, the name of the current VC-aware project.
 
-The best way to change the value a VC project reports as its
-name, is by setting this in .dir-locals.el."
+The best way to change the value a VC-aware project reports as
+its name, is by setting this in .dir-locals.el."
   :type '(choice (const :tag "Default to the base name" nil)
                  (string :tag "Custom name"))
   :version "29.1"
+  :package-version '(project . "0.9.0")
   :safe #'stringp)
 
+;; Not using regexps because these wouldn't work in Git pathspecs, in
+;; case we decide we need to be able to list nested projects.
+(defcustom project-vc-extra-root-markers nil
+  "List of additional markers to signal project roots.
+
+A marker is either a base file name or a glob pattern for such.
+
+A directory containing such a marker file or a file matching a
+marker pattern will be recognized as the root of a VC-aware
+project.
+
+Example values: \".dir-locals.el\", \"package.json\", \"pom.xml\",
+\"requirements.txt\", \"Gemfile\", \"*.gemspec\", \"autogen.sh\".
+
+These will be used in addition to regular directory markers such
+as \".git\", \".hg\", and so on, depending on the value of
+`vc-handled-backends'.  It is most useful when a project has
+subdirectories inside it that need to be considered as separate
+projects.  It can also be used for projects outside of VC
+repositories.
+
+In either case, their behavior will still obey the relevant
+variables, such as `project-vc-ignores' or `project-vc-name'."
+  :type 'list
+  :version "29.1"
+  :package-version '(project . "0.9.0")
+  :safe (lambda (val) (and (listp val) (cl-every #'stringp val))))
+
 ;; FIXME: Using the current approach, major modes are supposed to set
 ;; this variable to a buffer-local value.  So we don't have access to
 ;; the "external roots" of language A from buffers of language B, which
@@ -420,7 +466,7 @@ name, is by setting this in .dir-locals.el."
 ;;
 ;; We could add a second argument to this function: a file extension,
 ;; or a language name.  Some projects will know the set of languages
-;; used in them; for others, like VC-based projects, we'll need
+;; used in them; for others, like the VC-aware type, we'll need
 ;; auto-detection.  I see two options:
 ;;
 ;; - That could be implemented as a separate second hook, with a
@@ -444,32 +490,55 @@ name, is by setting this in .dir-locals.el."
 It should return a list of directory roots that contain source
 files related to the current buffer.
 
-The directory names should be absolute.  Used in the VC project
-backend implementation of `project-external-roots'.")
+The directory names should be absolute.  Used in the VC-aware
+project backend implementation of `project-external-roots'.")
 
 (defun project-try-vc (dir)
+  (defvar vc-svn-admin-directory)
+  (require 'vc-svn)
+  ;; FIXME: Learn to invalidate when the value of
+  ;; `project-vc-merge-submodules' or `project-vc-extra-root-markers'
+  ;; changes.
   (or (vc-file-getprop dir 'project-vc)
-      (let* ((backend (ignore-errors (vc-responsible-backend dir)))
+      (let* ((backend-markers-alist `((Git . ".git")
+                                      (Hg . ".hg")
+                                      (Bzr . ".bzr")
+                                      (SVN . ,vc-svn-admin-directory)
+                                      (DARCS . "_darcs")
+                                      (Fossil . ".fslckout")))
+             (backend-markers
+              (delete
+               nil
+               (mapcar
+                (lambda (b) (assoc-default b backend-markers-alist))
+                vc-handled-backends)))
+             (marker-re
+              (mapconcat
+               (lambda (m) (format "\\(%s\\)" (wildcard-to-regexp m)))
+               (append backend-markers project-vc-extra-root-markers)
+               "\\|"))
+             (locate-dominating-stop-dir-regexp
+              (or vc-ignore-dir-regexp locate-dominating-stop-dir-regexp))
+             last-matches
              (root
-              (pcase backend
-                ('Git
-                 ;; Don't stop at submodule boundary.
-                 (or (vc-file-getprop dir 'project-git-root)
-                     (let ((root (vc-call-backend backend 'root dir)))
-                       (vc-file-setprop
-                        dir 'project-git-root
-                        (if (and
-                             ;; FIXME: Invalidate the cache when the value
-                             ;; of this variable changes.
-                             project-vc-merge-submodules
-                             (project--submodule-p root))
-                            (let* ((parent (file-name-directory
-                                            (directory-file-name root))))
-                              (vc-call-backend backend 'root parent))
-                          root)))))
-                ('nil nil)
-                (_ (ignore-errors (vc-call-backend backend 'root dir)))))
+              (locate-dominating-file
+               dir
+               (lambda (d)
+                 ;; Maybe limit count to 100 when we can drop Emacs < 28.
+                 (setq last-matches (directory-files d nil marker-re t)))))
+             (backend
+              (cl-find-if
+               (lambda (b)
+                 (member (assoc-default b backend-markers-alist)
+                         last-matches))
+               vc-handled-backends))
              project)
+        (when (and
+               (eq backend 'Git)
+               project-vc-merge-submodules
+               (project--submodule-p root))
+          (let* ((parent (file-name-directory (directory-file-name root))))
+            (setq root (vc-call-backend 'Git 'root parent))))
         (when root
           (setq project (list 'vc backend root))
           ;; FIXME: Cache for a shorter time.
@@ -627,7 +696,8 @@ backend implementation of `project-external-roots'.")
   (let* ((root (nth 2 project))
          backend)
     (append
-     (when (file-equal-p dir root)
+     (when (and backend
+                (file-equal-p dir root))
        (setq backend (cadr project))
        (delq
         nil
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index f77f7492c3..2f8e8b2934 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -1920,13 +1920,16 @@ function `tab-bar-tab-name-function'."
     (when pos
       (tab-bar-move-tab-to pos (1+ tab-index)))))
 
-(defcustom tab-bar-tab-post-change-group-functions nil
+(defcustom tab-bar-tab-post-change-group-functions '(tab-bar-move-tab-to-group)
   "List of functions to call after changing a tab group.
-The current tab is supplied as an argument."
+This hook is run at the end of the function `tab-bar-change-tab-group'.
+The current tab is supplied as an argument.  You can use any function,
+but by default it enables the function `tab-bar-move-tab-to-group'
+that moves the tab closer to its group."
   :type 'hook
   :options '(tab-bar-move-tab-to-group)
   :group 'tab-bar
-  :version "28.1")
+  :version "29.1")
 
 (defun tab-bar-change-tab-group (group-name &optional tab-number)
   "Add the tab specified by its absolute position TAB-NUMBER to GROUP-NAME.
@@ -1937,7 +1940,8 @@ TAB-NUMBER counts from 1.
 If GROUP-NAME is the empty string, then remove the tab from any group.
 While using this command, you might also want to replace
 `tab-bar-format-tabs' with `tab-bar-format-tabs-groups' in
-`tab-bar-format' to group tabs on the tab bar."
+`tab-bar-format' to group tabs on the tab bar.
+At the end it runs the hook `tab-bar-tab-post-change-group-functions'."
   (interactive
    (let* ((tabs (funcall tab-bar-tabs-function))
           (tab-number (or current-prefix-arg
diff --git a/lisp/treesit.el b/lisp/treesit.el
index 8f092f475d..dd7895683f 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -1554,20 +1554,18 @@ For example, \"(function|class)_definition\".
 This is used by `treesit-beginning-of-defun' and friends.")
 
 (defvar-local treesit-defun-prefer-top-level nil
-  "When non-nil, `treesit-beginning-of-defun' prefers top-level defun.
+  "When non-nil, Emacs prefers top-level defun.
 
-In some languages, a defun (function, class, struct) could be
-nested in another one.  Normally `treesit-beginning-of-defun'
-just finds the first defun it encounter.  If this variable's
-value is t, `treesit-beginning-of-defun' tries to find the
-top-level defun, and ignores nested ones.
+In some languages, a defun could be nested in another one.
+Normally Emacs stops at the first defun it encounters.  If this
+variable's value is t, Emacs tries to find the top-level defun,
+and ignores nested ones.
 
-This variable can also be a list of tree-sitter node type
-regexps.  Then, when `treesit-beginning-of-defun' finds a defun
-node and that node's type matches one in the list,
-`treesit-beginning-of-defun' finds the top-level node matching
-that particular regexp (as opposed to any node matched by
-`treesit-defun-type-regexp').")
+This variable can also be a list of cons cells of the form (FROM
+. TO), where FROM and TO are tree-sitter node type regexps.  When
+Emacs finds a defun node whose type matches any of the FROM
+regexp in the list, Emacs then tries to find the top-level node
+matching the corresponding TO regexp.")
 
 (defun treesit--defun-maybe-top-level (node)
   "Maybe return the top-level equivalent of NODE.
@@ -1579,9 +1577,11 @@ For the detailed semantic see 
`treesit-defun-prefer-top-level'."
             node))
     ((pred consp)
      (cl-loop
-      for re in treesit-defun-prefer-top-level
-      if (string-match-p re (treesit-node-type node))
-      return (or (treesit-node-top-level node re)
+      for con in treesit-defun-prefer-top-level
+      for from = (car con)
+      for to = (cdr con)
+      if (string-match-p from (treesit-node-type node))
+      return (or (treesit-node-top-level node to)
                  node)
       finally return node))))
 
diff --git a/src/frame.c b/src/frame.c
index b57b296be5..05106a6c75 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -2214,17 +2214,24 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
     /* Since a similar behavior was observed on the Lucid and Motif
        builds (see Bug#5802, Bug#21509, Bug#23499, Bug#27816), we now
        don't delete the terminal for these builds either.  */
-    if (terminal->reference_count == 0 &&
-       (terminal->type == output_x_window || terminal->type == output_pgtk))
+    if (terminal->reference_count == 0
+       && (terminal->type == output_x_window
+           || terminal->type == output_pgtk))
       terminal->reference_count = 1;
 #endif /* USE_X_TOOLKIT || USE_GTK */
+
     if (terminal->reference_count == 0)
       {
        Lisp_Object tmp;
        XSETTERMINAL (tmp, terminal);
 
         kb = NULL;
-       Fdelete_terminal (tmp, NILP (force) ? Qt : force);
+
+       /* If force is noelisp, the terminal is going away inside
+          x_delete_terminal, and a recursive call to Fdelete_terminal
+          is unsafe!  */
+       if (!EQ (force, Qnoelisp))
+         Fdelete_terminal (tmp, NILP (force) ? Qt : force);
       }
     else
       kb = terminal->kboard;
diff --git a/src/xterm.c b/src/xterm.c
index 7eaf59d54b..44fad6e8d5 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -26768,13 +26768,14 @@ x_wm_supports_1 (struct x_display_info *dpyinfo, Atom 
want_atom)
 
       if (rc != Success || actual_type != XA_ATOM || x_had_errors_p (dpy))
         {
-          if (tmp_data) XFree (tmp_data);
+          if (tmp_data)
+           XFree (tmp_data);
           x_uncatch_errors ();
           unblock_input ();
           return false;
         }
 
-      dpyinfo->net_supported_atoms = (Atom *)tmp_data;
+      dpyinfo->net_supported_atoms = (Atom *) tmp_data;
       dpyinfo->nr_net_supported_atoms = actual_size;
       dpyinfo->net_supported_window = wmcheck_window;
     }
@@ -30630,6 +30631,9 @@ x_delete_display (struct x_display_info *dpyinfo)
        }
     }
 
+  if (dpyinfo->net_supported_atoms)
+    XFree (dpyinfo->net_supported_atoms);
+
   xfree (dpyinfo->color_names);
   xfree (dpyinfo->color_names_length);
   xfree (dpyinfo->x_id_name);
@@ -30741,7 +30745,11 @@ static struct redisplay_interface 
x_redisplay_interface =
 void
 x_delete_terminal (struct terminal *terminal)
 {
-  struct x_display_info *dpyinfo = terminal->display_info.x;
+  struct x_display_info *dpyinfo;
+  struct frame *f;
+  Lisp_Object tail, frame;
+
+  dpyinfo = terminal->display_info.x;
 
   /* Protect against recursive calls.  delete_frame in
      delete_terminal calls us back when it deletes our last frame.  */
@@ -30749,6 +30757,19 @@ x_delete_terminal (struct terminal *terminal)
     return;
 
   block_input ();
+
+  /* Delete all remaining frames on the display that is going away.
+     Otherwise, font backends assume the display is still up, and
+     xftfont_end_for_frame crashes.  */
+  FOR_EACH_FRAME (tail, frame)
+    {
+      f = XFRAME (frame);
+
+      if (FRAME_LIVE_P (f) && f->terminal == terminal)
+       /* Pass Qnoelisp rather than Qt.  */
+       delete_frame (frame, Qnoelisp);
+    }
+
 #ifdef HAVE_X_I18N
   /* We must close our connection to the XIM server before closing the
      X display.  */
@@ -30762,6 +30783,10 @@ x_delete_terminal (struct terminal *terminal)
       image_destroy_all_bitmaps (dpyinfo);
       XSetCloseDownMode (dpyinfo->display, DestroyAll);
 
+      /* Delete the scratch cursor GC, should it exist.  */
+      if (dpyinfo->scratch_cursor_gc)
+       XFreeGC (dpyinfo->display, dpyinfo->scratch_cursor_gc);
+
       /* Get rid of any drag-and-drop operation that might be in
         progress as well.  */
       if ((x_dnd_in_progress || x_dnd_waiting_for_finish)
diff --git a/test/lisp/progmodes/project-tests.el 
b/test/lisp/progmodes/project-tests.el
index d4b6bca7e8..55f3f499b3 100644
--- a/test/lisp/progmodes/project-tests.el
+++ b/test/lisp/progmodes/project-tests.el
@@ -110,4 +110,33 @@ When `project-ignores' includes a name matching project 
dir."
                      (list
                       (expand-file-name "some-file" dir)))))))
 
+(defvar project-tests--this-file (or (bound-and-true-p 
byte-compile-current-file)
+                                     (and load-in-progress load-file-name)
+                                     buffer-file-name))
+
+(ert-deftest project-vc-recognizes-git ()
+  "Check that Git repository is detected."
+  (skip-unless (eq (vc-responsible-backend default-directory) 'Git))
+  (let* ((vc-handled-backends '(Git))
+         (dir (file-name-directory project-tests--this-file))
+         (_ (vc-file-clearprops dir))
+         (project-vc-extra-root-markers nil)
+         (project (project-current nil dir)))
+    (should-not (null project))
+    (should (equal
+             "test/lisp/progmodes/project-tests.el"
+             (file-relative-name
+              project-tests--this-file
+              (project-root project))))))
+
+(ert-deftest project-vc-extra-root-markers-supports-wildcards ()
+  "Check that one can add wildcard entries."
+  (skip-unless (eq (vc-responsible-backend default-directory) 'Git))
+  (let* ((dir (file-name-directory project-tests--this-file))
+         (_ (vc-file-clearprops dir))
+         (project-vc-extra-root-markers '("files-x-tests.*"))
+         (project (project-current nil dir)))
+    (should-not (null project))
+    (should (string-match-p "/test/lisp/\\'" (project-root project)))))
+
 ;;; project-tests.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]