From: Eli Zaretskii Date: Sat, 16 Dec 2023 14:17:51 +0000 (-0500) Subject: Merge from origin/emacs-29 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=a1d3862c6240805bde997bb57f60fceb0fbccb85;p=emacs.git Merge from origin/emacs-29 bf4ccb0be07 ; * lisp/term.el (term--xterm-paste): Fix last change. 0d9e2e448d9 ; * doc/lispref/functions.texi (Function Documentation): ... 791cc5065da Fix shaping of Sinhala text efcbf0b5abf Add use cases of (fn) documentation facility. c3331cb3659 Fix pasting into terminal-mode on term.el 5be94e2bce5 Fix opening directory trees from Filesets menu 6b6e770a1f5 Eglot: Add ruff-lsp as an alternative Python server ed8a8a5ba16 Fix symbol name in Multisession Variables examples 400ef15bdc3 js-ts-mode: Fix font-lock rules conflict c165247c300 Add indentation rules for bracketless statements in js-ts... 7f1bd69cd19 Fix c-ts-mode bracketless indentation for BSD style (bug#... e23068cb9a1 Add missing indent rules in c-ts-mode (bug#66152) d2c4b926ac2 Fix treesit-default-defun-skipper (bug#66711) 9874561f39e Fix treesit-node-field-name and friends (bug#66674) eace9e11226 python-ts-mode: Highlight default parameters 23c06c7c308 Update to Org 9.6.13 --- a1d3862c6240805bde997bb57f60fceb0fbccb85 diff --cc lisp/org/ox-beamer.el index 2590bd5fa72,fe1f2ffa572..10a2c803a00 --- a/lisp/org/ox-beamer.el +++ b/lisp/org/ox-beamer.el @@@ -924,12 -924,13 +924,12 @@@ holding export options. "Support for editing Beamer oriented Org mode files." :lighter " Bm") -(when (fboundp 'font-lock-add-keywords) - (font-lock-add-keywords - 'org-mode - '((":\\(B_[a-z]+\\|BMCOL\\):" 1 'org-beamer-tag prepend)) - 'prepend)) +(font-lock-add-keywords + 'org-mode + '((":\\(B_[a-z]+\\|BMCOL\\):" 1 'org-beamer-tag prepend)) + 'prepend) - (defface org-beamer-tag '((t (:box (:line-width 1 :color grey40)))) + (defface org-beamer-tag '((t (:box (:line-width 1 :color "grey40")))) "The special face for beamer tags." :group 'org-export-beamer) diff --cc lisp/treesit.el index 9f885985f3b,8a07f5023a9..c6b9d8ff4bc --- a/lisp/treesit.el +++ b/lisp/treesit.el @@@ -392,88 -368,9 +393,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))) + (idx (treesit-node-index node t))) (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)