emacs-diffs
[Top][All Lists]
Advanced

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

master c53952164fe 2/2: Merge from origin/emacs-29


From: Po Lu
Subject: master c53952164fe 2/2: Merge from origin/emacs-29
Date: Mon, 30 Jan 2023 08:48:39 -0500 (EST)

branch: master
commit c53952164fe54fee41343fd4008f610f7a284d26
Merge: 48ed4228a75 f67a9a12b7b
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Merge from origin/emacs-29
    
    f67a9a12b7b Fix interactive use of `keymap-local-set' and `keymap-glo...
    dda4baa58b7 ; Fix build and startup without tree-sitter
---
 lisp/keymap.el                 | 13 ++++++-------
 lisp/progmodes/c-ts-common.el  |  1 +
 lisp/progmodes/rust-ts-mode.el |  1 +
 lisp/treesit.el                | 31 +++++++++++++++++--------------
 4 files changed, 25 insertions(+), 21 deletions(-)

diff --git a/lisp/keymap.el b/lisp/keymap.el
index 791221f2459..caabedd5aec 100644
--- a/lisp/keymap.el
+++ b/lisp/keymap.el
@@ -76,12 +76,9 @@ Note that if KEY has a local binding in the current buffer,
 that local binding will continue to shadow any global binding
 that you make with this function."
   (declare (compiler-macro (lambda (form) (keymap--compile-check key) form)))
-  (interactive
-   (let* ((menu-prompting nil)
-          (key (read-key-sequence "Set key globally: " nil t)))
-     (list key
-           (read-command (format "Set key %s to command: "
-                                 (key-description key))))))
+  (interactive "KSet key globally:\nCSet key %s globally to command: ")
+  (unless (stringp key)
+    (setq key (key-description key)))
   (keymap-set (current-global-map) key command))
 
 (defun keymap-local-set (key command)
@@ -94,10 +91,12 @@ KEY is a string that satisfies `key-valid-p'.
 The binding goes in the current buffer's local map, which in most
 cases is shared with all other buffers in the same major mode."
   (declare (compiler-macro (lambda (form) (keymap--compile-check key) form)))
-  (interactive "KSet key locally: \nCSet key %s locally to command: ")
+  (interactive "KSet key locally:\nCSet key %s locally to command: ")
   (let ((map (current-local-map)))
     (unless map
       (use-local-map (setq map (make-sparse-keymap))))
+    (unless (stringp key)
+      (setq key (key-description key)))
     (keymap-set map key command)))
 
 (defun keymap-global-unset (key &optional remove)
diff --git a/lisp/progmodes/c-ts-common.el b/lisp/progmodes/c-ts-common.el
index 2d4a0d41c2a..c13b01aae5c 100644
--- a/lisp/progmodes/c-ts-common.el
+++ b/lisp/progmodes/c-ts-common.el
@@ -50,6 +50,7 @@
 (declare-function treesit-node-start "treesit.c")
 (declare-function treesit-node-end "treesit.c")
 (declare-function treesit-node-type "treesit.c")
+(declare-function treesit-node-parent "treesit.c")
 
 ;;; Comment indentation and filling
 
diff --git a/lisp/progmodes/rust-ts-mode.el b/lisp/progmodes/rust-ts-mode.el
index 2812e39c101..e317793d211 100644
--- a/lisp/progmodes/rust-ts-mode.el
+++ b/lisp/progmodes/rust-ts-mode.el
@@ -37,6 +37,7 @@
 (declare-function treesit-node-child-by-field-name "treesit.c")
 (declare-function treesit-node-start "treesit.c")
 (declare-function treesit-node-type "treesit.c")
+(declare-function treesit-node-parent "treesit.c")
 
 (defcustom rust-ts-mode-indent-offset 4
   "Number of spaces for each indentation step in `rust-ts-mode'."
diff --git a/lisp/treesit.el b/lisp/treesit.el
index 202a383ed7d..059707b0123 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -88,6 +88,7 @@
 (declare-function treesit-search-forward "treesit.c")
 (declare-function treesit-subtree-stat "treesit.c")
 (declare-function treesit-induce-sparse-tree "treesit.c")
+(declare-function treesit-subtree-stat "treesit.c")
 
 (declare-function treesit-available-p "treesit.c")
 
@@ -560,20 +561,22 @@ omitted, default END to BEG."
 (defun treesit--font-lock-level-setter (sym val)
   "Custom setter for `treesit-font-lock-level'."
   (set-default sym val)
-  (named-let loop ((res nil)
-                   (buffers (buffer-list)))
-    (if (null buffers)
-        (mapc (lambda (b)
-                (with-current-buffer b
-                  (setq-local treesit-font-lock-level val)
-                  (treesit-font-lock-recompute-features)
-                  (treesit-font-lock-fontify-region (point-min) (point-max))))
-              res)
-      (let ((buffer (car buffers)))
-        (with-current-buffer buffer
-          (if (treesit-parser-list)
-              (loop (append res (list buffer)) (cdr buffers))
-            (loop res (cdr buffers))))))))
+  (and (treesit-available-p)
+       (named-let loop ((res nil)
+                        (buffers (buffer-list)))
+         (if (null buffers)
+             (mapc (lambda (b)
+                     (with-current-buffer b
+                       (setq-local treesit-font-lock-level val)
+                       (treesit-font-lock-recompute-features)
+                       (treesit-font-lock-fontify-region (point-min)
+                                                         (point-max))))
+                   res)
+           (let ((buffer (car buffers)))
+             (with-current-buffer buffer
+               (if (treesit-parser-list)
+                   (loop (append res (list buffer)) (cdr buffers))
+                 (loop res (cdr buffers)))))))))
 
 (defcustom treesit-font-lock-level 3
   "Decoration level to be used by tree-sitter fontifications.



reply via email to

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