emacs-diffs
[Top][All Lists]
Advanced

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

master ccf3705892d: Merge from origin/emacs-29


From: Stefan Kangas
Subject: master ccf3705892d: Merge from origin/emacs-29
Date: Tue, 6 Dec 2022 00:46:34 -0500 (EST)

branch: master
commit ccf3705892d93159f655d3aab822ed62249e78dc
Merge: 2c8b09b06e7 717f8477284
Author: Stefan Kangas <stefankangas@gmail.com>
Commit: Stefan Kangas <stefankangas@gmail.com>

    Merge from origin/emacs-29
    
    717f8477284 ; Fix typo in js--treesit-imenu
    c26fe45cb80 Fix treesit-query-capture
    318bf42b410 Improve fontification of typescript-ts-mode (bug#59831)
    64271bbb7d9 Add back pair feature in json-ts-mode fontification (bug#...
    16b94888429 Fix mouse clicks on a non-selected frame
    ca0da3b83df ; Clarify description of display on the margins
---
 doc/lispref/display.texi             |  5 +++--
 lisp/mouse-drag.el                   | 19 +++++++++++++------
 lisp/progmodes/js.el                 |  2 +-
 lisp/progmodes/json-ts-mode.el       |  6 +++++-
 lisp/progmodes/typescript-ts-mode.el | 18 ++++++++++++++++--
 lisp/textmodes/css-mode.el           |  5 -----
 lisp/treesit.el                      |  7 +------
 src/treesit.c                        | 11 +++++++----
 8 files changed, 46 insertions(+), 27 deletions(-)

diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi
index 9d929950a7e..340aa400cfa 100644
--- a/doc/lispref/display.texi
+++ b/doc/lispref/display.texi
@@ -5467,8 +5467,9 @@ or an image descriptor.
 
   To display something in the margin @emph{in association with}
 certain buffer text, without altering or preventing the display of
-that text, put a @code{before-string} property on the text and put the
-margin display specification on the contents of the before-string.
+that text, put on that text an overlay with a @code{before-string}
+property, and put the margin display specification on the contents of
+the before-string.
 
   Note that if the string to be displayed in the margin doesn't
 specify a face, its face is determined using the same rules and
diff --git a/lisp/mouse-drag.el b/lisp/mouse-drag.el
index f515cc8aacf..81b699c0202 100644
--- a/lisp/mouse-drag.el
+++ b/lisp/mouse-drag.el
@@ -275,6 +275,7 @@ To test this function, evaluate:
         have-scrolled
         window-last-row
         col window-last-col
+         switch-frame-p
         (scroll-col-delta 0)
         ;; be conservative about allowing horizontal scrolling
         (col-scrolling-p (mouse-drag-should-do-col-scrolling)))
@@ -286,15 +287,21 @@ To test this function, evaluate:
       (setq track-mouse 'drag-dragging)
       (while (progn
               (setq event (read--potential-mouse-event)
-                    end (event-end event)
-                    row (cdr (posn-col-row end))
-                    col (car (posn-col-row end)))
-              (or (mouse-movement-p event)
-                  (eq (car-safe event) 'switch-frame)))
+                     switch-frame-p (eq (car-safe event) 'switch-frame))
+               ;; We want to skip switch-frame events and treat then
+               ;; as moves over a different window.  These events have
+               ;; no position spec, so all the posn-* accessor
+               ;; functions are likely to barf if passed such an
+               ;; event.
+               (or switch-frame-p
+                   (setq end (event-end event)
+                        row (cdr (posn-col-row end))
+                        col (car (posn-col-row end))))
+              (or (mouse-movement-p event) switch-frame-p))
        ;; Scroll if see if we're on the edge.
        ;; FIXME: should handle mouse-in-other window.
        (cond
-        ((not (eq start-window (posn-window end)))
+        ((or switch-frame-p (not (eq start-window (posn-window end))))
          t) ; wait for return to original window
         ((<= row 0) (mouse-drag-repeatedly-safe-scroll -1 0))
         ((>= row window-last-row) (mouse-drag-repeatedly-safe-scroll 1 0))
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index 90ab7cc924b..45dfef372cd 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -3734,7 +3734,7 @@ definition*\"."
          (var-tree (treesit-induce-sparse-tree
                     node "lexical_declaration" nil 1000)))
     `(("Class" . ,(js--treesit-imenu-1 class-tree))
-      ("Varieable" . ,(js--treesit-imenu-1 var-tree))
+      ("Variable" . ,(js--treesit-imenu-1 var-tree))
       ("Function" . ,(js--treesit-imenu-1 func-tree)))))
 
 ;;; Main Function
diff --git a/lisp/progmodes/json-ts-mode.el b/lisp/progmodes/json-ts-mode.el
index 101e873cf6e..8ea582ad8fa 100644
--- a/lisp/progmodes/json-ts-mode.el
+++ b/lisp/progmodes/json-ts-mode.el
@@ -93,6 +93,10 @@
    :override t
    '((escape_sequence) @font-lock-escape-face)
    :language 'json
+   :feature 'pair
+   :override t ; Needed for overriding string face on keys.
+   '((pair key: (_) @font-lock-variable-name-face))
+   :language 'json
    :feature 'error
    :override t
    '((ERROR) @font-lock-warning-face))
@@ -156,7 +160,7 @@ the subtrees."
   ;; Font-lock.
   (setq-local treesit-font-lock-settings json-ts-mode--font-lock-settings)
   (setq-local treesit-font-lock-feature-list
-              '((constant number string)
+              '((constant number pair string)
                 (escape-sequence)
                 (bracket delimiter error)))
 
diff --git a/lisp/progmodes/typescript-ts-mode.el 
b/lisp/progmodes/typescript-ts-mode.el
index 48ac1169fe8..3da690567e2 100644
--- a/lisp/progmodes/typescript-ts-mode.el
+++ b/lisp/progmodes/typescript-ts-mode.el
@@ -213,7 +213,14 @@ Argument LANGUAGE is either `typescript' or `tsx'."
       parameters:
       [(_ (identifier) @font-lock-variable-name-face)
        (_ (_ (identifier) @font-lock-variable-name-face))
-       (_ (_ (_ (identifier) @font-lock-variable-name-face)))]))
+       (_ (_ (_ (identifier) @font-lock-variable-name-face)))])
+
+     (return_statement (identifier) @font-lock-variable-name-face)
+
+     (binary_expression left: (identifier) @font-lock-variable-name-face)
+     (binary_expression right: (identifier) @font-lock-variable-name-face)
+
+     (arguments (identifier) @font-lock-variable-name-face))
 
    :language language
    :override t
@@ -282,7 +289,14 @@ Argument LANGUAGE is either `typescript' or `tsx'."
    :language language
    :override t
    :feature 'property
-   `((pair value: (identifier) @font-lock-variable-name-face)
+   `((property_signature
+      name: (property_identifier) @font-lock-property-face)
+     (public_field_definition
+      name: (property_identifier) @font-lock-property-face)
+
+     (pair key: (property_identifier) @font-lock-variable-name-face)
+
+     (pair value: (identifier) @font-lock-variable-name-face)
 
      ((shorthand_property_identifier) @font-lock-property-face)
 
diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el
index b82886e3974..8a66986dc6f 100644
--- a/lisp/textmodes/css-mode.el
+++ b/lisp/textmodes/css-mode.el
@@ -1839,11 +1839,6 @@ can also be used to fill comments.
                 '((selector comment query keyword)
                   (property constant string)
                   (error variable function operator bracket)))
-    ;; Tree-sitter-css, for whatever reason, cannot reliably return
-    ;; the captured nodes in a given range (it instead returns the
-    ;; nodes preceding range).  Before this is fixed in
-    ;; tree-sitter-css, use this heuristic as a temporary fix.
-    (setq-local treesit--font-lock-query-expand-range (cons 80 80))
     (setq-local imenu-create-index-function #'css--treesit-imenu)
     (setq-local which-func-functions nil)
     (treesit-major-mode-setup)))
diff --git a/lisp/treesit.el b/lisp/treesit.el
index eee6eee0c7f..dbbf7ec18c3 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -545,12 +545,7 @@ This should be a cons cell (START . END).  When fontifying 
a
 buffer, Emacs will move the start of the query range backward by
 START amount, and the end of the query range by END amount.  Both
 START and END should be positive integers or 0.  This doesn't
-affect the fontified range.
-
-Sometimes, querying on some parser with a restricted range
-returns nodes not in that range but before it, which breaks
-fontification.  Major modes can adjust this variable as a
-temporarily fix.")
+affect the fontified range.")
 
 (defvar-local treesit-font-lock-feature-list nil
   "A list of lists of feature symbols.
diff --git a/src/treesit.c b/src/treesit.c
index 4b150059fac..343054ed53e 100644
--- a/src/treesit.c
+++ b/src/treesit.c
@@ -2507,14 +2507,17 @@ the query.  */)
   /* Set query range.  */
   if (!NILP (beg) && !NILP (end))
     {
-      EMACS_INT beg_byte = XFIXNUM (beg);
-      EMACS_INT end_byte = XFIXNUM (end);
+      EMACS_INT beg_byte = buf_charpos_to_bytepos (current_buffer,
+                                                  XFIXNUM (beg));
+      EMACS_INT end_byte = buf_charpos_to_bytepos (current_buffer,
+                                                  XFIXNUM (end));
       /* We never let tree-sitter run on buffers too large, so these
         assertion should never hit.  */
       eassert (beg_byte - visible_beg <= UINT32_MAX);
       eassert (end_byte - visible_beg <= UINT32_MAX);
-      ts_query_cursor_set_byte_range (cursor, (uint32_t) beg_byte - 
visible_beg,
-                                     (uint32_t) end_byte - visible_beg);
+      ts_query_cursor_set_byte_range (cursor,
+                                     (uint32_t) (beg_byte - visible_beg),
+                                     (uint32_t) (end_byte - visible_beg));
     }
 
   /* Execute query.  */



reply via email to

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