emacs-diffs
[Top][All Lists]
Advanced

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

master 99feed933a 1/2: Merge from origin/emacs-29


From: Stefan Kangas
Subject: master 99feed933a 1/2: Merge from origin/emacs-29
Date: Fri, 23 Dec 2022 00:45:26 -0500 (EST)

branch: master
commit 99feed933ac8b8a3384eeb40254ef2e2de4f31de
Merge: 17bf6a829c 0754173c92
Author: Stefan Kangas <stefankangas@gmail.com>
Commit: Stefan Kangas <stefankangas@gmail.com>

    Merge from origin/emacs-29
    
    0754173c923 ; Fix docstring
    014232d3840 Eglot: eglot--servers-by-xrefed-file doesn't need to be v...
    bbe35c280c2 Prevent stale servers when using eglot-extend-to-xref
    9bf13a3fb9e ; * src/alloc.c (Fmemory_info): Doc fix.
    baa33a5c054 * etc/tutorials/TUTORIAL.cn: Fix typos.  (Bug#60221)
    98d7f76b451 Merge branch 'emacs-29' of git.savannah.gnu.org:/srv/git/...
    a488a6870ac Add alias for removed font-lock function
    02e046566e2 Set beginning/end-of-defun-function in treesit-major-mode...
    7dea58b88db Add treesit-defun-at-point and fix c-ts-mode-indent-defun
    69123d4aa4e ; Fix treesit--defuns-around
    05d8310fb5d Use the new keyword ':repeat' in repeatable keymaps.
---
 etc/tutorials/TUTORIAL.cn     |  4 ++--
 lisp/bindings.el              | 13 ++++---------
 lisp/comint.el                |  4 +---
 lisp/dired.el                 |  2 +-
 lisp/eshell/em-prompt.el      |  4 +---
 lisp/eshell/esh-mode.el       |  4 +---
 lisp/font-lock.el             |  1 +
 lisp/keymap.el                |  2 +-
 lisp/outline.el               | 15 ++-------------
 lisp/progmodes/c-ts-mode.el   | 11 ++++-------
 lisp/progmodes/eglot.el       |  8 +++++---
 lisp/shell.el                 |  4 +---
 lisp/tab-bar.el               |  6 ++----
 lisp/textmodes/reftex-vars.el |  4 ++--
 lisp/treesit.el               | 41 ++++++++++++++++++++++++++++++++++++++---
 lisp/window.el                |  7 ++-----
 lisp/winner.el                |  4 +---
 src/alloc.c                   |  2 +-
 18 files changed, 70 insertions(+), 66 deletions(-)

diff --git a/etc/tutorials/TUTORIAL.cn b/etc/tutorials/TUTORIAL.cn
index 770d9a83be..cb430d3fdb 100644
--- a/etc/tutorials/TUTORIAL.cn
+++ b/etc/tutorials/TUTORIAL.cn
@@ -299,7 +299,7 @@ Emacs 可以有多个“窗格”,每个窗格显示不同的文字。后面
 
 >>  试试 C-u 8 *,这将会插入 ********。
 
-好,现在你应该已经掌握了最基本的的文本插入和修改功能,其实删除还可以
+好,现在你应该已经掌握了最基本的文本插入和修改功能,其实删除还可以
 “以词为单位”进行,下面是一个关于“删除”操作的小结:
 
         <DEL>        删除光标前的一个字符
@@ -316,7 +316,7 @@ Emacs 可以有多个“窗格”,每个窗格显示不同的文字。后面
 
 注意“<DEL> 和 C-d”还有“M-<DEL> 和 M-d”是根据前述惯例从 C-f和 M-f 衍生
 出来的(其实<DEL>不是控制字符,我们先忽略这一点)。C-k和 M-k 的关系在
-某种程度上与 C-e 和 M-e 一样――如果把“一行”和“一句”作一个类比的话。
+某种程度上与 C-e 和 M-e 一样――如果把“一行”和“一句”做一个类比的话。
 
 你也可以用一种通用的办法来移除缓冲区里的任何一部分:首先把光标移动到你
 想要移除的区域的一端,然后按 C-<SPC>(<SPC>指空格)【注意,C-<SPC> 往
diff --git a/lisp/bindings.el b/lisp/bindings.el
index a3f51ebb31..f2e0799f72 100644
--- a/lisp/bindings.el
+++ b/lisp/bindings.el
@@ -1012,8 +1012,8 @@ if `inhibit-field-text-motion' is non-nil."
 ;; (define-key ctl-x-map "U" 'undo-only)
 (defvar-keymap undo-repeat-map
   :doc "Keymap to repeat undo key sequences \\`C-x u u'.  Used in 
`repeat-mode'."
+  :repeat t
   "u" #'undo)
-(put 'undo 'repeat-map 'undo-repeat-map)
 
 (define-key global-map '[(control ??)] 'undo-redo)
 (define-key global-map [?\C-\M-_] 'undo-redo)
@@ -1033,12 +1033,10 @@ if `inhibit-field-text-motion' is non-nil."
 
 (defvar-keymap buffer-navigation-repeat-map
   :doc "Keymap to repeat `next-buffer' and `previous-buffer'.  Used in 
`repeat-mode'."
+  :repeat t
   "<right>" #'next-buffer
   "<left>"  #'previous-buffer)
 
-(put 'next-buffer 'repeat-map 'buffer-navigation-repeat-map)
-(put 'previous-buffer 'repeat-map 'buffer-navigation-repeat-map)
-
 (let ((map minibuffer-local-map))
   (define-key map "\en"   'next-history-element)
   (define-key map [next]  'next-history-element)
@@ -1111,12 +1109,11 @@ if `inhibit-field-text-motion' is non-nil."
 
 (defvar-keymap next-error-repeat-map
   :doc "Keymap to repeat `next-error' key sequences.  Used in `repeat-mode'."
+  :repeat t
   "n"   #'next-error
   "M-n" #'next-error
   "p"   #'previous-error
   "M-p" #'previous-error)
-(put 'next-error 'repeat-map 'next-error-repeat-map)
-(put 'previous-error 'repeat-map 'next-error-repeat-map)
 
 (defvar-keymap goto-map
   :doc "Keymap for navigation commands."
@@ -1474,12 +1471,10 @@ if `inhibit-field-text-motion' is non-nil."
 
 (defvar-keymap page-navigation-repeat-map
   :doc "Keymap to repeat page navigation key sequences.  Used in 
`repeat-mode'."
+  :repeat t
   "]" #'forward-page
   "[" #'backward-page)
 
-(put 'forward-page 'repeat-map 'page-navigation-repeat-map)
-(put 'backward-page 'repeat-map 'page-navigation-repeat-map)
-
 (define-key ctl-x-map "\C-p" 'mark-page)
 (define-key ctl-x-map "l" 'count-lines-page)
 (define-key ctl-x-map "np" 'narrow-to-page)
diff --git a/lisp/comint.el b/lisp/comint.el
index 7ba423e65d..77d213574f 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -606,12 +606,10 @@ via PTYs.")
 
 (defvar-keymap comint-repeat-map
   :doc "Keymap to repeat comint key sequences.  Used in `repeat-mode'."
+  :repeat t
   "C-n" #'comint-next-prompt
   "C-p" #'comint-previous-prompt)
 
-(put #'comint-next-prompt 'repeat-map 'comint-repeat-map)
-(put #'comint-previous-prompt 'repeat-map 'comint-repeat-map)
-
 ;; Fixme: Is this still relevant?
 (defvar comint-ptyp t
   "Non-nil if communications via pty; false if by pipe.  Buffer local.
diff --git a/lisp/dired.el b/lisp/dired.el
index 81e62f88cf..f5d1b90abf 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -4882,9 +4882,9 @@ Interactively with prefix argument, read FILE-NAME."
 
 (defvar-keymap dired-jump-map
   :doc "Keymap to repeat `dired-jump'.  Used in `repeat-mode'."
+  :repeat t
   "j"   #'dired-jump
   "C-j" #'dired-jump)
-(put 'dired-jump 'repeat-map 'dired-jump-map)
 
 
 ;;; Miscellaneous commands
diff --git a/lisp/eshell/em-prompt.el b/lisp/eshell/em-prompt.el
index a8744de1db..abb123bcff 100644
--- a/lisp/eshell/em-prompt.el
+++ b/lisp/eshell/em-prompt.el
@@ -102,12 +102,10 @@ arriving, or after."
 
 (defvar-keymap eshell-prompt-repeat-map
   :doc "Keymap to repeat eshell-prompt key sequences.  Used in `repeat-mode'."
+  :repeat t
   "C-n" #'eshell-next-prompt
   "C-p" #'eshell-previous-prompt)
 
-(put #'eshell-next-prompt 'repeat-map 'eshell-prompt-repeat-map)
-(put #'eshell-previous-prompt 'repeat-map 'eshell-prompt-repeat-map)
-
 ;;; Functions:
 
 (define-minor-mode eshell-prompt-mode
diff --git a/lisp/eshell/esh-mode.el b/lisp/eshell/esh-mode.el
index 4357a0e29a..b3db0f6af4 100644
--- a/lisp/eshell/esh-mode.el
+++ b/lisp/eshell/esh-mode.el
@@ -282,12 +282,10 @@ This is used by `eshell-watch-for-password-prompt'."
 
 (defvar-keymap eshell-command-repeat-map
   :doc "Keymap to repeat eshell-command key sequences.  Used in `repeat-mode'."
+  :repeat t
   "C-f" #'eshell-forward-argument
   "C-b" #'eshell-backward-argument)
 
-(put #'eshell-forward-argument 'repeat-map 'eshell-command-repeat-map)
-(put #'eshell-backward-argument 'repeat-map 'eshell-command-repeat-map)
-
 ;;; User Functions:
 
 (defun eshell-kill-buffer-function ()
diff --git a/lisp/font-lock.el b/lisp/font-lock.el
index bf9a179d6a..2dfbe3ad23 100644
--- a/lisp/font-lock.el
+++ b/lisp/font-lock.el
@@ -2361,6 +2361,7 @@ in which C preprocessor directives are used, e.g. 
`asm-mode' and
 
 (define-obsolete-function-alias 'font-lock-after-fontify-buffer #'ignore 
"29.1")
 (define-obsolete-function-alias 'font-lock-after-unfontify-buffer #'ignore 
"29.1")
+(define-obsolete-function-alias 'font-lock-fontify-syntactically-region 
#'font-lock-default-fontify-syntactically "29.1")
 
 
 (provide 'font-lock)
diff --git a/lisp/keymap.el b/lisp/keymap.el
index b355f68aa2..e93e3c5f3b 100644
--- a/lisp/keymap.el
+++ b/lisp/keymap.el
@@ -625,7 +625,7 @@ command exists in this specific map, but it doesn't have the
            `(defvar ,variable-name
               (define-keymap ,@(nreverse opts) ,@defs)
               ,@(and doc (list doc)))))
-      (if repeat
+      (if props
           `(progn
              ,defvar-form
              ,@(nreverse props))
diff --git a/lisp/outline.el b/lisp/outline.el
index 53bfc4d556..c2b33b4c58 100644
--- a/lisp/outline.el
+++ b/lisp/outline.el
@@ -1868,6 +1868,7 @@ With a prefix argument, show headings up to that LEVEL."
 
 
 (defvar-keymap outline-navigation-repeat-map
+  :repeat t
   "C-b" #'outline-backward-same-level
   "b"   #'outline-backward-same-level
   "C-f" #'outline-forward-same-level
@@ -1879,14 +1880,8 @@ With a prefix argument, show headings up to that LEVEL."
   "C-u" #'outline-up-heading
   "u"   #'outline-up-heading)
 
-(dolist (command '(outline-backward-same-level
-                   outline-forward-same-level
-                   outline-next-visible-heading
-                   outline-previous-visible-heading
-                   outline-up-heading))
-  (put command 'repeat-map 'outline-navigation-repeat-map))
-
 (defvar-keymap outline-editing-repeat-map
+  :repeat t
   "C-v" #'outline-move-subtree-down
   "v"   #'outline-move-subtree-down
   "C-^" #'outline-move-subtree-up
@@ -1896,12 +1891,6 @@ With a prefix argument, show headings up to that LEVEL."
   "C-<" #'outline-promote
   "<"   #'outline-promote)
 
-(dolist (command '(outline-move-subtree-down
-                   outline-move-subtree-up
-                   outline-demote
-                   outline-promote))
-  (put command 'repeat-map 'outline-editing-repeat-map))
-
 
 (provide 'outline)
 (provide 'noutline)
diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index cf941236f8..6f7056864f 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -556,13 +556,10 @@ the semicolon.  This function skips the semicolon."
 
 `treesit-defun-type-regexp' defines what constructs to indent."
   (interactive "*")
-  (let ((orig-point (point-marker)))
-    ;; If `treesit-beginning-of-defun' returns nil, we are not in a
-    ;; defun, so don't indent anything.
-    (when (treesit-beginning-of-defun)
-      (let ((start (point)))
-        (treesit-end-of-defun)
-        (indent-region start (point))))
+  (when-let ((orig-point (point-marker))
+             (node (treesit-defun-at-point)))
+    (indent-region (treesit-node-start node)
+                   (treesit-node-end node))
     (goto-char orig-point)))
 
 (defvar-keymap c-ts-mode-map
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 0f1bfd0447..15cb1b6fad 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -908,6 +908,8 @@ PRESERVE-BUFFERS as in `eglot-shutdown', which see."
            do (with-demoted-errors "[eglot] shutdown all: %s"
                 (cl-loop for s in ss do (eglot-shutdown s nil nil 
preserve-buffers)))))
 
+(defvar eglot--servers-by-xrefed-file (make-hash-table :test 'equal))
+
 (defun eglot--on-shutdown (server)
   "Called by jsonrpc.el when SERVER is already dead."
   ;; Turn off `eglot--managed-mode' where appropriate.
@@ -926,6 +928,9 @@ PRESERVE-BUFFERS as in `eglot-shutdown', which see."
   (setf (gethash (eglot--project server) eglot--servers-by-project)
         (delq server
               (gethash (eglot--project server) eglot--servers-by-project)))
+  (maphash (lambda (f s)
+             (when (eq s server) (remhash f eglot--servers-by-xrefed-file)))
+           eglot--servers-by-xrefed-file)
   (cond ((eglot--shutdown-requested server)
          t)
         ((not (eglot--inhibit-autoreconnect server))
@@ -1057,9 +1062,6 @@ be guessed."
 (put 'eglot-lsp-context 'variable-documentation
      "Dynamically non-nil when searching for projects in LSP context.")
 
-(defvar eglot--servers-by-xrefed-file
-  (make-hash-table :test 'equal :weakness 'value))
-
 (defun eglot--current-project ()
   "Return a project object for Eglot's LSP purposes.
 This relies on `project-current' and thus on
diff --git a/lisp/shell.el b/lisp/shell.el
index dadbdcbc03..727f2aa0dd 100644
--- a/lisp/shell.el
+++ b/lisp/shell.el
@@ -395,12 +395,10 @@ Useful for shells like zsh that has this feature."
 
 (defvar-keymap shell-repeat-map
   :doc "Keymap to repeat shell key sequences.  Used in `repeat-mode'."
+  :repeat t
   "C-f" #'shell-forward-command
   "C-b" #'shell-backward-command)
 
-(put #'shell-forward-command 'repeat-map 'shell-repeat-map)
-(put #'shell-backward-command 'repeat-map 'shell-repeat-map)
-
 (defcustom shell-mode-hook '()
   "Hook for customizing Shell mode."
   :type 'hook
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index 69283cce14..0bab3aba80 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -2654,18 +2654,16 @@ When `switch-to-buffer-obey-display-actions' is non-nil,
 (defvar-keymap tab-bar-switch-repeat-map
   :doc "Keymap to repeat tab switch key sequences \\`C-x t o o O'.
 Used in `repeat-mode'."
+  :repeat t
   "o" #'tab-next
   "O" #'tab-previous)
-(put 'tab-next 'repeat-map 'tab-bar-switch-repeat-map)
-(put 'tab-previous 'repeat-map 'tab-bar-switch-repeat-map)
 
 (defvar-keymap tab-bar-move-repeat-map
   :doc "Keymap to repeat tab move key sequences \\`C-x t m m M'.
 Used in `repeat-mode'."
+  :repeat t
   "m" #'tab-move
   "M" #'tab-bar-move-tab-backward)
-(put 'tab-move 'repeat-map 'tab-bar-move-repeat-map)
-(put 'tab-bar-move-tab-backward 'repeat-map 'tab-bar-move-repeat-map)
 
 
 (provide 'tab-bar)
diff --git a/lisp/textmodes/reftex-vars.el b/lisp/textmodes/reftex-vars.el
index ee94cc5d69..51dedddf3a 100644
--- a/lisp/textmodes/reftex-vars.el
+++ b/lisp/textmodes/reftex-vars.el
@@ -2096,8 +2096,8 @@ may require a restart of Emacs in order to become 
effective."
 
 (defcustom reftex-allow-detached-macro-args nil
   "Non-nil means, allow arguments of macros to be detached by whitespace.
-When this is t, `aaa' will be considered as argument of \\bb in the following
-construct:  \\bbb [xxx] {aaa}."
+When this is t, `aaa' will be considered as argument of \\bbb in
+the following construct: \\bbb [xxx] {aaa}."
   :group 'reftex-miscellaneous-configurations
   :type 'boolean)
 
diff --git a/lisp/treesit.el b/lisp/treesit.el
index 04019cae60..75330ac121 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -1666,10 +1666,13 @@ REGEXP and PRED are the same as in 
`treesit-defun-type-regexp'."
          ;; defun, in that case we want to use a node that's actually
          ;; before/after point.
          (node-before (if (>= (treesit-node-start node) pos)
-                          (treesit-search-forward-goto node "" t t t)
+                          (save-excursion
+                            (treesit-search-forward-goto node "" t t t))
                         node))
          (node-after (if (<= (treesit-node-end node) pos)
-                         (treesit-search-forward-goto node "" nil nil t)
+                         (save-excursion
+                           (treesit-search-forward-goto
+                            node "" nil nil t))
                        node))
          (result (list nil nil nil))
          (pred (or pred (lambda (_) t))))
@@ -1840,6 +1843,29 @@ function is called recursively."
     ;; Counter equal to 0 means we successfully stepped ARG steps.
     (if (eq counter 0) pos nil)))
 
+;; TODO: In corporate into thing-at-point.
+(defun treesit-defun-at-point ()
+  "Return the defun at point or nil if none is found.
+
+Respects `treesit-defun-tactic': return the top-level defun if it
+is `top-level', return the immediate parent defun if it is
+`nested'."
+  (pcase-let* ((`(,regexp . ,pred)
+                (if (consp treesit-defun-type-regexp)
+                    treesit-defun-type-regexp
+                  (cons treesit-defun-type-regexp nil)))
+               (`(,_ ,next ,parent)
+                (treesit--defuns-around (point) regexp pred))
+               ;; If point is at the beginning of a defun, we
+               ;; prioritize that defun over the parent in nested
+               ;; mode.
+               (node (or (and (eq (treesit-node-start next) (point))
+                              next)
+                         parent)))
+    (if (eq treesit-defun-tactic 'top-level)
+        (treesit--top-level-defun node regexp pred)
+      node)))
+
 ;;; Activating tree-sitter
 
 (defun treesit-ready-p (language &optional quiet)
@@ -1924,7 +1950,16 @@ before calling this function."
     (keymap-set (current-local-map) "<remap> <beginning-of-defun>"
                 #'treesit-beginning-of-defun)
     (keymap-set (current-local-map) "<remap> <end-of-defun>"
-                #'treesit-end-of-defun)))
+                #'treesit-end-of-defun)
+    ;; `end-of-defun' will not work completely correctly in nested
+    ;; defuns due to its implementation.  However, many lisp programs
+    ;; use `beginning/end-of-defun', so we should still set
+    ;; `beginning/end-of-defun-function' so they still mostly work.
+    ;; This is also what `cc-mode' does: rebind user commands and set
+    ;; the variables.  In future we should update `end-of-defun' to
+    ;; work with nested defuns.
+    (setq-local beginning-of-defun-function #'treesit-beginning-of-defun)
+    (setq-local end-of-defun-function #'treesit-end-of-defun)))
 
 ;;; Debugging
 
diff --git a/lisp/window.el b/lisp/window.el
index a4a8421881..5dd5b80883 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -10561,26 +10561,23 @@ displaying that processes's buffer."
 (defvar-keymap other-window-repeat-map
   :doc "Keymap to repeat `other-window' key sequences.
 Used in `repeat-mode'."
+  :repeat t
   "o" #'other-window
   "O" (lambda ()
         (interactive)
         (setq repeat-map 'other-window-repeat-map)
         (other-window -1)))
-(put 'other-window 'repeat-map 'other-window-repeat-map)
 
 (defvar-keymap resize-window-repeat-map
   :doc "Keymap to repeat window resizing commands.
 Used in `repeat-mode'."
+  :repeat t
   ;; Standard keys:
   "^" #'enlarge-window
   "}" #'enlarge-window-horizontally
   "{" #'shrink-window-horizontally
   ;; Additional keys:
   "v" #'shrink-window)
-(put 'enlarge-window 'repeat-map 'resize-window-repeat-map)
-(put 'enlarge-window-horizontally 'repeat-map 'resize-window-repeat-map)
-(put 'shrink-window-horizontally 'repeat-map 'resize-window-repeat-map)
-(put 'shrink-window 'repeat-map 'resize-window-repeat-map)
 
 (defvar-keymap window-prefix-map
   :doc "Keymap for subcommands of \\`C-x w'."
diff --git a/lisp/winner.el b/lisp/winner.el
index c8354b18be..aed57aa037 100644
--- a/lisp/winner.el
+++ b/lisp/winner.el
@@ -330,12 +330,10 @@ You may want to include buffer names such as *Help*, 
*Apropos*,
 
 (defvar-keymap winner-repeat-map
   :doc "Keymap to repeat winner key sequences.  Used in `repeat-mode'."
+  :repeat t
   "<left>"  #'winner-undo
   "<right>" #'winner-redo)
 
-(put #'winner-undo 'repeat-map 'winner-repeat-map)
-(put #'winner-redo 'repeat-map 'winner-repeat-map)
-
 
 ;;;###autoload
 (define-minor-mode winner-mode
diff --git a/src/alloc.c b/src/alloc.c
index 2975754124..e7edc0595b 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -7693,7 +7693,7 @@ DEFUN ("memory-info", Fmemory_info, Smemory_info, 0, 0, 0,
 All values are in Kbytes.  If there is no swap space,
 last two values are zero.  If the system is not supported
 or memory information can't be obtained, return nil.
-If `default-directory’ is remote, return memory information of the
+If `default-directory' is remote, return memory information of the
 respective remote host.  */)
   (void)
 {



reply via email to

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