]> git.eshelyaron.com Git - emacs.git/commitdiff
Merge from origin/emacs-29
authorEli Zaretskii <eliz@gnu.org>
Sat, 30 Dec 2023 09:51:17 +0000 (04:51 -0500)
committerEli Zaretskii <eliz@gnu.org>
Sat, 30 Dec 2023 09:51:17 +0000 (04:51 -0500)
53031528725 Revert "Fix treesit-node-field-name and friends (bug#66674)"
fa0bb88302b ; * src/buffer.c (syms_of_buffer) <default-directory>: Do...
44517037aed ; Fix typo
ccf46acefd2 ; Fix last change.
c86b039dffc ; * etc/DEBUG: Improve advice for debugging native-compil...
9afba605bbc Explain status "r" in `epa-list-keys`
62714221968 ; * lisp/dired.el (dired--make-directory-clickable): Refo...
fcbb0044899 Fix mouse clicks on directory line in Dired
be8a7155b48 Fix 'split-root-window-right' and 'split-root-window-below'
eb19984c4db Mark icalendar.el as maintained by emacs-devel
03dc914fd37 ; Fix footnotes in ELisp Intro manual
ceacf753958 Fix usage of `setq-default' and offer more suggestions
2701da0eee5 Fix python-ts-mode triple quote syntax (bug#67262)
683c7c96871 Increment parser timestamp when narrowing changes (bug#67...
8ae42c825e1 ruby-ts-mode: Fix indentation for string_array closer
9cfa498e0ab treesit-major-mode-setup: Use 'treesit--syntax-propertize...
da2e440462b ruby-ts-mode: Fix an out-of-bounds error with heredoc at eob
6ea507296a7 Correctly refontify changed region in tree-sitter modes (...

12 files changed:
1  2 
doc/lispref/control.texi
doc/lispref/parsing.texi
etc/DEBUG
lisp/calendar/icalendar.el
lisp/dired.el
lisp/progmodes/python.el
lisp/progmodes/ruby-ts-mode.el
lisp/treesit.el
lisp/window.el
src/buffer.c
src/treesit.c
src/treesit.h

Simple merge
Simple merge
diff --cc etc/DEBUG
Simple merge
Simple merge
diff --cc lisp/dired.el
Simple merge
Simple merge
Simple merge
diff --cc lisp/treesit.el
index c6b9d8ff4bc465ef527a4137660edbf03a54d32c,264b95dc3a3908a89b0ef088832f6cfc2f4cc3c3..d4857dea72e998bdd4e1235bfd1086034e43c417
@@@ -393,88 -367,9 +392,88 @@@ If NAMED is non-nil, count named child 
  (defun treesit-node-field-name (node)
    "Return the field name of NODE as a child of its parent."
    (when-let ((parent (treesit-node-parent node))
-              (idx (treesit-node-index node t)))
+              (idx (treesit-node-index node)))
      (treesit-node-field-name-for-child parent idx)))
  
 +(defun treesit-node-get (node instructions)
 +  "Get things from NODE by INSTRUCTIONS.
 +
 +This is a convenience function that chains together multiple node
 +accessor functions together.  For example, to get NODE's parent's
 +next sibling's second child's text, call
 +
 +   (treesit-node-get node
 +     \\='((parent 1)
 +       (sibling 1 nil)
 +       (child 1 nil)
 +       (text nil)))
 +
 +INSTRUCTION is a list of INSTRUCTIONs of the form (FN ARG...).
 +The following FN's are supported:
 +
 +\(child IDX NAMED)    Get the IDX'th child
 +\(parent N)           Go to parent N times
 +\(field-name)         Get the field name of the current node
 +\(type)               Get the type of the current node
 +\(text NO-PROPERTY)   Get the text of the current node
 +\(children NAMED)     Get a list of children
 +\(sibling STEP NAMED) Get the nth prev/next sibling, negative STEP
 +                     means prev sibling, positive means next
 +
 +Note that arguments like NAMED and NO-PROPERTY can't be omitted,
 +unlike in their original functions."
 +  (declare (indent 1))
 +  (while (and node instructions)
 +    (pcase (pop instructions)
 +      ('(field-name) (setq node (treesit-node-field-name node)))
 +      ('(type) (setq node (treesit-node-type node)))
 +      (`(child ,idx ,named) (setq node (treesit-node-child node idx named)))
 +      (`(parent ,n) (dotimes (_ n)
 +                      (setq node (treesit-node-parent node))))
 +      (`(text ,no-property) (setq node (treesit-node-text node no-property)))
 +      (`(children ,named) (setq node (treesit-node-children node named)))
 +      (`(sibling ,step ,named)
 +       (dotimes (_ (abs step))
 +         (setq node (if (> step 0)
 +                        (treesit-node-next-sibling node named)
 +                      (treesit-node-prev-sibling node named)))))))
 +  node)
 +
 +(defun treesit-node-enclosed-p (smaller larger &optional strict)
 +  "Return non-nil if SMALLER is enclosed in LARGER.
 +SMALLER and LARGER can be either (BEG . END) or a node.
 +
 +Return non-nil if LARGER's start <= SMALLER's start and LARGER's
 +end <= SMALLER's end.
 +
 +If STRICT is t, compare with < rather than <=.
 +
 +If STRICT is \\='partial, consider LARGER encloses SMALLER when
 +at least one side is strictly enclosing."
 +  (unless (and (or (consp larger) (treesit-node-p larger))
 +               (or (consp smaller) (treesit-node-p smaller)))
 +    (signal 'wrong-type-argument '((or cons treesit-node))))
 +  (let ((larger-start (if (consp larger)
 +                          (car larger)
 +                        (treesit-node-start larger)))
 +        (larger-end (if (consp larger)
 +                        (cdr larger)
 +                      (treesit-node-end larger)))
 +        (smaller-start (if (consp smaller)
 +                           (car smaller)
 +                         (treesit-node-start smaller)))
 +        (smaller-end (if (consp smaller)
 +                         (cdr smaller)
 +                       (treesit-node-end smaller))))
 +    (pcase strict
 +      ('t (and (< larger-start smaller-start)
 +               (< smaller-end larger-end)))
 +      ('partial (and (or (not (eq larger-start smaller-start))
 +                         (not (eq larger-end smaller-end)))
 +                     (<= larger-start smaller-start
 +                         smaller-end larger-end)))
 +      (_ (<= larger-start smaller-start smaller-end larger-end)))))
 +
  ;;; Query API supplement
  
  (defun treesit-query-string (string query language)
diff --cc lisp/window.el
Simple merge
diff --cc src/buffer.c
Simple merge
diff --cc src/treesit.c
Simple merge
diff --cc src/treesit.h
Simple merge