Merge from origin/emacs-29
bf4ccb0be0
; * lisp/term.el (term--xterm-paste): Fix last change.0d9e2e448d
; * doc/lispref/functions.texi (Function Documentation): ...791cc5065d
Fix shaping of Sinhala textefcbf0b5ab
Add use cases of (fn) documentation facility.c3331cb365
Fix pasting into terminal-mode on term.el5be94e2bce
Fix opening directory trees from Filesets menu6b6e770a1f
Eglot: Add ruff-lsp as an alternative Python servered8a8a5ba1
Fix symbol name in Multisession Variables examples400ef15bdc
js-ts-mode: Fix font-lock rules conflictc165247c30
Add indentation rules for bracketless statements in js-ts...7f1bd69cd1
Fix c-ts-mode bracketless indentation for BSD style (bug#...e23068cb9a
Add missing indent rules in c-ts-mode (bug#66152)d2c4b926ac
Fix treesit-default-defun-skipper (bug#66711)9874561f39
Fix treesit-node-field-name and friends (bug#66674)eace9e1122
python-ts-mode: Highlight default parameters23c06c7c30
Update to Org 9.6.13
This commit is contained in:
commit
a1d3862c62
23 changed files with 211 additions and 64 deletions
|
@ -533,6 +533,40 @@ Instead, use the @code{advertised-calling-convention} declaration
|
|||
compiler emit a warning message when it compiles Lisp programs which
|
||||
use the deprecated calling convention.
|
||||
|
||||
@ifnottex
|
||||
The @code{(fn)} feature is typically used in the following situations:
|
||||
|
||||
@itemize @minus
|
||||
@item To spell out arguments and their purposes in a macro or a function. Example:
|
||||
|
||||
@example
|
||||
(defmacro lambda (&rest cdr)
|
||||
"@dots{}
|
||||
\(fn ARGS [DOCSTRING] [INTERACTIVE] BODY)"@dots{})
|
||||
@end example
|
||||
|
||||
@item To provide a more detailed description and names of arguments. Example:
|
||||
|
||||
@example
|
||||
(defmacro macroexp--accumulate (var+list &rest body)
|
||||
"@dots{}
|
||||
\(fn (VAR LIST) BODY@dots{})"
|
||||
(declare (indent 1))
|
||||
(let ((var (car var+list))
|
||||
(list (cadr var+list))
|
||||
@dots{})))
|
||||
@end example
|
||||
|
||||
@item To better explain the purpose of a @code{defalias}. Example:
|
||||
|
||||
@example
|
||||
(defalias 'abbrev-get 'get
|
||||
"@dots{}
|
||||
\(fn ABBREV PROP)")
|
||||
@end example
|
||||
@end itemize
|
||||
@end ifnottex
|
||||
|
||||
@cindex computed documentation string
|
||||
@kindex :documentation
|
||||
Documentation strings are usually static, but occasionally it can be
|
||||
|
|
|
@ -1071,8 +1071,8 @@ This function returns the field name of the @var{n}'th child of
|
|||
@var{node}. It returns @code{nil} if there is no @var{n}'th child, or
|
||||
the @var{n}'th child doesn't have a field name.
|
||||
|
||||
Note that @var{n} counts both named and anonymous children, and
|
||||
@var{n} can be negative, e.g., @minus{}1 represents the last child.
|
||||
Note that @var{n} counts named nodes only, and @var{n} can be
|
||||
negative, e.g., @minus{}1 represents the last child.
|
||||
@end defun
|
||||
|
||||
@defun treesit-node-child-count node &optional named
|
||||
|
|
|
@ -3002,7 +3002,7 @@ meant to be used, here's a small example:
|
|||
|
||||
@lisp
|
||||
@group
|
||||
(define-multisession-variable foo-var 0)
|
||||
(define-multisession-variable foo 0)
|
||||
(defun my-adder (num)
|
||||
(interactive "nAdd number: ")
|
||||
(setf (multisession-value foo)
|
||||
|
@ -3012,7 +3012,7 @@ meant to be used, here's a small example:
|
|||
@end lisp
|
||||
|
||||
@noindent
|
||||
This defines the variable @code{foo-var} and binds it to a special
|
||||
This defines the variable @code{foo} and binds it to a special
|
||||
multisession object which is initialized with the value @samp{0} (if
|
||||
the variable doesn't already exist from a previous session). The
|
||||
@code{my-adder} command queries the user for a number, adds this to
|
||||
|
@ -3035,7 +3035,7 @@ specified by @var{package-symbol}. The combination of
|
|||
@var{package-symbol} isn't given, this will default to the first
|
||||
``segment'' of the @var{name} symbol's name, which is the part of its
|
||||
name up to and excluding the first @samp{-}. For instance, if
|
||||
@var{name} is @code{foo-var} and @var{package-symbol} isn't given,
|
||||
@var{name} is @code{foo} and @var{package-symbol} isn't given,
|
||||
@var{package-symbol} will default to @code{foo}.
|
||||
|
||||
@cindex synchronized multisession variables
|
||||
|
@ -3043,7 +3043,7 @@ name up to and excluding the first @samp{-}. For instance, if
|
|||
Multisession variables can be @dfn{synchronized} if @var{bool} is
|
||||
non-@code{nil}. This means that if there're two concurrent Emacs
|
||||
instances running, and the other Emacs changes the multisession
|
||||
variable @code{foo-var}, the current Emacs instance will retrieve that
|
||||
variable @code{foo}, the current Emacs instance will retrieve that
|
||||
modified data when accessing the value. If @var{synchronized} is
|
||||
@code{nil} or missing, this won't happen, and the values in all
|
||||
Emacs sessions using the variable will be independent of each other.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
% Reference Card for Org Mode
|
||||
\def\orgversionnumber{9.6.11}
|
||||
\def\orgversionnumber{9.6.13}
|
||||
\def\versionyear{2023} % latest update
|
||||
\input emacsver.tex
|
||||
|
||||
|
|
|
@ -1648,7 +1648,17 @@ Assume MODE (see `filesets-entry-mode'), if provided."
|
|||
(filesets-entry-get-master entry)))))
|
||||
(cons entry (filesets-ingroup-cache-get entry))))
|
||||
(:tree
|
||||
(let* ((dirpatt (filesets-entry-get-tree entry))
|
||||
;; Warning: ENTRY here could be of at least two
|
||||
;; differente forms, either
|
||||
;; (NAME (:tree DIRECTORY PATTERN))
|
||||
;; or
|
||||
;; (DIRECTORY PATTERN)
|
||||
;; The latter happens when opening a tree fileset
|
||||
;; from the Filesets menu. We need to support both
|
||||
;; of these forms!
|
||||
(let* ((dirpatt (if (consp (nth 1 entry))
|
||||
(filesets-entry-get-tree entry)
|
||||
entry))
|
||||
(dir (nth 0 dirpatt))
|
||||
(patt (nth 1 dirpatt))
|
||||
(depth (or (filesets-entry-get-tree-max-level entry)
|
||||
|
|
|
@ -36,11 +36,11 @@
|
|||
composition-function-table
|
||||
'(#xD80 . #xDFF)
|
||||
(list (vector
|
||||
;; C:consonant, H:HALANT, J:ZWJ, v:vowel sign,
|
||||
;; C:consonant, H:HALANTA, J:ZWJ, v:vowel sign,
|
||||
;; V:independent vowel, a:ANUSVARA .. VISARGA
|
||||
(concat
|
||||
;; C(HJC)*v*H?a?, or
|
||||
"[\u0D9A-\u0DC6]\\(?:\u0DCA\u200D[\u0D9A-\u0DC6]\\)*[\u0DCF-\u0DDF\u0DF2-\u0DF3]*\u0DCA?[\u0D82-\u0D83]?\\|"
|
||||
;; C(HJ|JH)C)*v*H?a?, or
|
||||
"[\u0D9A-\u0DC6]\\(?:\\(\u0DCA\u200D\\|\u200D\u0DCA\\)[\u0D9A-\u0DC6]\\)*[\u0DCF-\u0DDF\u0DF2-\u0DF3]*\u0DCA?[\u0D82-\u0D83]?\\|"
|
||||
;; Va?, or
|
||||
"[\u0D85-\u0D96][\u0D82-\u0D83]?\\|"
|
||||
;; any other singleton characters
|
||||
|
|
|
@ -57,7 +57,7 @@ The JAR can be configured via `org-plantuml-jar-path'.
|
|||
|
||||
`plantuml' means to use the PlantUML executable.
|
||||
The executable can be configured via `org-plantuml-executable-path'.
|
||||
You can also configure extra arguments via `org-plantuml-executable-args'."
|
||||
You can also configure extra arguments via `org-plantuml-args'."
|
||||
:group 'org-babel
|
||||
:package-version '(Org . "9.4")
|
||||
:type 'symbol
|
||||
|
|
|
@ -5906,7 +5906,7 @@ If this warning appears regularly, please report the warning text to Org mode ma
|
|||
(org-element-property :begin element)
|
||||
(org-element-property :org-element--cache-sync-key element))
|
||||
(org-element-cache-reset)
|
||||
(throw 'quit nil))
|
||||
(throw 'org-element--cache-quit nil))
|
||||
(or (avl-tree-delete org-element--cache element)
|
||||
(progn
|
||||
;; This should not happen, but if it is, would be better to know
|
||||
|
@ -5919,7 +5919,7 @@ If this warning appears regularly, please report the warning text to Org mode ma
|
|||
(org-element-property :begin element)
|
||||
(org-element-property :org-element--cache-sync-key element))
|
||||
(org-element-cache-reset)
|
||||
(throw 'quit nil)))))
|
||||
(throw 'org-element--cache-quit nil)))))
|
||||
|
||||
;;;; Synchronization
|
||||
|
||||
|
@ -6382,6 +6382,10 @@ completing the request."
|
|||
;; We altered the tree structure. The tree
|
||||
;; traversal needs to be restarted.
|
||||
(setf (org-element--request-key request) key)
|
||||
;; Make sure that we restart tree traversal
|
||||
;; past already shifted elements (before the
|
||||
;; removed DATA).
|
||||
(setq start key)
|
||||
(setf (org-element--request-parent request) parent)
|
||||
;; Restart tree traversal.
|
||||
(setq node (org-element--cache-root)
|
||||
|
|
|
@ -1119,7 +1119,12 @@ Return width in pixels when PIXELS is non-nil."
|
|||
(setq pixel-width
|
||||
(if (get-buffer-window (current-buffer))
|
||||
(car (window-text-pixel-size
|
||||
nil (line-beginning-position) (point-max)))
|
||||
;; FIXME: 10000 because
|
||||
;; `most-positive-fixnum' ain't working
|
||||
;; (tests failing) and this call will be
|
||||
;; removed after we drop Emacs 28 support
|
||||
;; anyway.
|
||||
nil (line-beginning-position) (point-max) 10000))
|
||||
(let ((dedicatedp (window-dedicated-p))
|
||||
(oldbuffer (window-buffer)))
|
||||
(unwind-protect
|
||||
|
@ -1128,7 +1133,7 @@ Return width in pixels when PIXELS is non-nil."
|
|||
(set-window-dedicated-p nil nil)
|
||||
(set-window-buffer nil (current-buffer))
|
||||
(car (window-text-pixel-size
|
||||
nil (line-beginning-position) (point-max))))
|
||||
nil (line-beginning-position) (point-max) 10000)))
|
||||
(set-window-buffer nil oldbuffer)
|
||||
(set-window-dedicated-p nil dedicatedp)))))
|
||||
(unless pixels
|
||||
|
@ -1137,7 +1142,7 @@ Return width in pixels when PIXELS is non-nil."
|
|||
(setq symbol-width
|
||||
(if (get-buffer-window (current-buffer))
|
||||
(car (window-text-pixel-size
|
||||
nil (line-beginning-position) (point-max)))
|
||||
nil (line-beginning-position) (point-max) 10000))
|
||||
(let ((dedicatedp (window-dedicated-p))
|
||||
(oldbuffer (window-buffer)))
|
||||
(unwind-protect
|
||||
|
@ -1146,7 +1151,7 @@ Return width in pixels when PIXELS is non-nil."
|
|||
(set-window-dedicated-p nil nil)
|
||||
(set-window-buffer nil (current-buffer))
|
||||
(car (window-text-pixel-size
|
||||
nil (line-beginning-position) (point-max))))
|
||||
nil (line-beginning-position) (point-max) 10000)))
|
||||
(set-window-buffer nil oldbuffer)
|
||||
(set-window-dedicated-p nil dedicatedp)))))))
|
||||
(if pixels
|
||||
|
|
|
@ -481,9 +481,14 @@ MISC, if non-nil will be appended to the collection. It must be a plist."
|
|||
(unless (stringp associated)
|
||||
(setq associated (cadr associated)))
|
||||
(let* ((rtn `(:file ,associated))
|
||||
(inode (and (fboundp 'file-attribute-inode-number)
|
||||
(file-attribute-inode-number
|
||||
(file-attributes associated)))))
|
||||
(inode (and
|
||||
;; Do not store :inode for remote files - it may
|
||||
;; be time-consuming on slow connections or even
|
||||
;; fail completely when ssh connection is closed.
|
||||
(not (file-remote-p associated))
|
||||
(fboundp 'file-attribute-inode-number)
|
||||
(file-attribute-inode-number
|
||||
(file-attributes associated)))))
|
||||
(when inode (plist-put rtn :inode inode))
|
||||
rtn))
|
||||
((or (pred bufferp) `(:buffer ,_))
|
||||
|
@ -501,6 +506,10 @@ MISC, if non-nil will be appended to the collection. It must be a plist."
|
|||
(or (buffer-base-buffer associated)
|
||||
associated)))
|
||||
(setq inode (when (and file
|
||||
;; Do not store :inode for remote files - it may
|
||||
;; be time-consuming on slow connections or even
|
||||
;; fail completely when ssh connection is closed.
|
||||
(not (file-remote-p file))
|
||||
(fboundp 'file-attribute-inode-number))
|
||||
(file-attribute-inode-number
|
||||
(file-attributes file))))
|
||||
|
|
|
@ -5,13 +5,13 @@
|
|||
(defun org-release ()
|
||||
"The release version of Org.
|
||||
Inserted by installing Org mode or when a release is made."
|
||||
(let ((org-release "9.6.11"))
|
||||
(let ((org-release "9.6.13"))
|
||||
org-release))
|
||||
;;;###autoload
|
||||
(defun org-git-version ()
|
||||
"The Git version of Org mode.
|
||||
Inserted by installing Org or when a release is made."
|
||||
(let ((org-git-version "release_9.6.11"))
|
||||
(let ((org-git-version "release_9.6.13"))
|
||||
org-git-version))
|
||||
|
||||
(provide 'org-version)
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
;; URL: https://orgmode.org
|
||||
;; Package-Requires: ((emacs "26.1"))
|
||||
|
||||
;; Version: 9.6.11
|
||||
;; Version: 9.6.13
|
||||
|
||||
;; This file is part of GNU Emacs.
|
||||
;;
|
||||
|
@ -19985,7 +19985,7 @@ With argument N not nil or 1, move forward N - 1 lines first."
|
|||
(if (eq special 'reversed)
|
||||
(when (and (= origin bol) (eq last-command this-command))
|
||||
(goto-char refpos))
|
||||
(when (or (> origin refpos) (= origin bol))
|
||||
(when (or (> origin refpos) (<= origin bol))
|
||||
(goto-char refpos)))))
|
||||
((and (looking-at org-list-full-item-re)
|
||||
(memq (org-element-type (save-match-data (org-element-at-point)))
|
||||
|
@ -20000,7 +20000,7 @@ With argument N not nil or 1, move forward N - 1 lines first."
|
|||
(if (eq special 'reversed)
|
||||
(when (and (= (point) origin) (eq last-command this-command))
|
||||
(goto-char after-bullet))
|
||||
(when (or (> origin after-bullet) (= (point) origin))
|
||||
(when (or (> origin after-bullet) (>= (point) origin))
|
||||
(goto-char after-bullet)))))
|
||||
;; No special context. Point is already at beginning of line.
|
||||
(t nil))))
|
||||
|
@ -20055,7 +20055,7 @@ With argument N not nil or 1, move forward N - 1 lines first."
|
|||
(goto-char tags)
|
||||
(end-of-line)))
|
||||
(t
|
||||
(if (or (< origin tags) (= origin (line-end-position)))
|
||||
(if (or (< origin tags) (>= origin (line-end-position)))
|
||||
(goto-char tags)
|
||||
(end-of-line))))))
|
||||
((bound-and-true-p visual-line-mode)
|
||||
|
|
|
@ -929,7 +929,7 @@ holding export options."
|
|||
'((":\\(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)
|
||||
|
||||
|
|
|
@ -437,6 +437,8 @@ MODE is either `c' or `cpp'."
|
|||
((parent-is "preproc") c-ts-mode--anchor-prev-sibling 0)
|
||||
|
||||
((parent-is "function_definition") parent-bol 0)
|
||||
((parent-is "pointer_declarator") parent-bol 0)
|
||||
((parent-is "declaration") parent-bol 0)
|
||||
((parent-is "conditional_expression") first-sibling 0)
|
||||
((parent-is "assignment_expression") parent-bol c-ts-mode-indent-offset)
|
||||
((parent-is "concatenated_string") first-sibling 0)
|
||||
|
@ -514,13 +516,13 @@ MODE is either `c' or `cpp'."
|
|||
((node-is "labeled_statement") parent-bol c-ts-mode-indent-offset)
|
||||
((parent-is "labeled_statement") parent-bol c-ts-mode-indent-offset)
|
||||
((parent-is "compound_statement") parent-bol c-ts-mode-indent-offset)
|
||||
((parent-is "if_statement") parent-bol 0)
|
||||
((parent-is "else_clause") parent-bol 0)
|
||||
((parent-is "for_statement") parent-bol 0)
|
||||
((parent-is "while_statement") parent-bol 0)
|
||||
((parent-is "switch_statement") parent-bol 0)
|
||||
((parent-is "case_statement") parent-bol 0)
|
||||
((parent-is "do_statement") parent-bol 0)
|
||||
((match "compound_statement" "if_statement") standalone-parent 0)
|
||||
((match "compound_statement" "else_clause") standalone-parent 0)
|
||||
((match "compound_statement" "for_statement") standalone-parent 0)
|
||||
((match "compound_statement" "while_statement") standalone-parent 0)
|
||||
((match "compound_statement" "switch_statement") standalone-parent 0)
|
||||
((match "compound_statement" "case_statement") standalone-parent 0)
|
||||
((match "compound_statement" "do_statement") standalone-parent 0)
|
||||
,@common))))
|
||||
|
||||
(defun c-ts-mode--top-level-label-matcher (node parent &rest _)
|
||||
|
|
|
@ -216,7 +216,7 @@ chosen (interactively or automatically)."
|
|||
(vimrc-mode . ("vim-language-server" "--stdio"))
|
||||
((python-mode python-ts-mode)
|
||||
. ,(eglot-alternatives
|
||||
'("pylsp" "pyls" ("pyright-langserver" "--stdio") "jedi-language-server")))
|
||||
'("pylsp" "pyls" ("pyright-langserver" "--stdio") "jedi-language-server" "ruff-lsp")))
|
||||
((js-json-mode json-mode json-ts-mode)
|
||||
. ,(eglot-alternatives '(("vscode-json-language-server" "--stdio")
|
||||
("vscode-json-languageserver" "--stdio")
|
||||
|
|
|
@ -3463,6 +3463,11 @@ Check if a node type is available, then return the right indent rules."
|
|||
((parent-is "class_body") parent-bol js-indent-level)
|
||||
((parent-is ,switch-case) parent-bol js-indent-level)
|
||||
((parent-is "statement_block") parent-bol js-indent-level)
|
||||
((match "while" "do_statement") parent-bol 0)
|
||||
((match "else" "if_statement") parent-bol 0)
|
||||
((parent-is ,(rx (or (seq (or "if" "for" "for_in" "while" "do") "_statement")
|
||||
"else_clause")))
|
||||
parent-bol js-indent-level)
|
||||
|
||||
;; JSX
|
||||
,@(js-jsx--treesit-indent-compatibility-bb1f97b)
|
||||
|
@ -3566,16 +3571,6 @@ Check if a node type is available, then return the right indent rules."
|
|||
;; full namespace import (* as alias)
|
||||
(import_clause (namespace_import (identifier) @font-lock-variable-name-face)))
|
||||
|
||||
:language 'javascript
|
||||
:feature 'property
|
||||
'(((property_identifier) @font-lock-property-use-face
|
||||
(:pred js--treesit-property-not-function-p
|
||||
@font-lock-property-use-face))
|
||||
|
||||
(pair value: (identifier) @font-lock-variable-use-face)
|
||||
|
||||
((shorthand_property_identifier) @font-lock-property-use-face))
|
||||
|
||||
:language 'javascript
|
||||
:feature 'assignment
|
||||
'((assignment_expression
|
||||
|
@ -3596,6 +3591,12 @@ Check if a node type is available, then return the right indent rules."
|
|||
(jsx_self_closing_element name: (_) @font-lock-function-call-face)
|
||||
(jsx_attribute (property_identifier) @font-lock-constant-face))
|
||||
|
||||
:language 'javascript
|
||||
:feature 'property
|
||||
'(((property_identifier) @font-lock-property-use-face)
|
||||
(pair value: (identifier) @font-lock-variable-use-face)
|
||||
((shorthand_property_identifier) @font-lock-property-use-face))
|
||||
|
||||
:language 'javascript
|
||||
:feature 'number
|
||||
'((number) @font-lock-number-face
|
||||
|
@ -3647,14 +3648,6 @@ OVERRIDE is the override flag described in
|
|||
(setq font-beg (treesit-node-end child)
|
||||
child (treesit-node-next-sibling child)))))
|
||||
|
||||
(defun js--treesit-property-not-function-p (node)
|
||||
"Check that NODE, a property_identifier, is not used as a function."
|
||||
(not (equal (treesit-node-type
|
||||
(treesit-node-parent ; Maybe call_expression.
|
||||
(treesit-node-parent ; Maybe member_expression.
|
||||
node)))
|
||||
"call_expression")))
|
||||
|
||||
(defvar js--treesit-lhs-identifier-query
|
||||
(when (treesit-available-p)
|
||||
(treesit-query-compile 'javascript '((identifier) @id
|
||||
|
|
|
@ -1124,7 +1124,8 @@ fontified."
|
|||
name: (identifier) @font-lock-function-name-face)
|
||||
(class_definition
|
||||
name: (identifier) @font-lock-type-face)
|
||||
(parameters (identifier) @font-lock-variable-name-face))
|
||||
(parameters (identifier) @font-lock-variable-name-face)
|
||||
(parameters (default_parameter name: (identifier) @font-lock-variable-name-face)))
|
||||
|
||||
:feature 'function
|
||||
:language 'python
|
||||
|
|
11
lisp/term.el
11
lisp/term.el
|
@ -1393,10 +1393,15 @@ Entry to this mode runs the hooks on `term-mode-hook'."
|
|||
(interactive)
|
||||
(term-send-raw-string (current-kill 0)))
|
||||
|
||||
(defun term--xterm-paste ()
|
||||
(defun term--xterm-paste (event)
|
||||
"Insert the text pasted in an XTerm bracketed paste operation."
|
||||
(interactive)
|
||||
(term-send-raw-string (xterm--pasted-text)))
|
||||
(interactive "e")
|
||||
(unless (eq (car-safe event) 'xterm-paste)
|
||||
(error "term--xterm-paste must be found to xterm-paste event"))
|
||||
(let ((str (nth 1 event)))
|
||||
(unless (stringp str)
|
||||
(error "term--xterm-paste provided event does not contain paste text"))
|
||||
(term-send-raw-string str)))
|
||||
|
||||
(declare-function xterm--pasted-text "term/xterm" ())
|
||||
|
||||
|
|
|
@ -385,6 +385,7 @@ If NAMED is non-nil, collect named child only."
|
|||
"Return the index of NODE in its parent.
|
||||
If NAMED is non-nil, count named child only."
|
||||
(let ((count 0))
|
||||
;; TODO: Use next-sibling as it's more efficient.
|
||||
(while (setq node (treesit-node-prev-sibling node named))
|
||||
(cl-incf count))
|
||||
count))
|
||||
|
@ -392,7 +393,7 @@ If NAMED is non-nil, count named child only."
|
|||
(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)
|
||||
|
@ -2358,7 +2359,7 @@ the current line if the beginning of the defun is indented."
|
|||
(forward-line 1))
|
||||
;; Moving backward, but there are some whitespace (and only
|
||||
;; whitespace) between point and BOL: go back to BOL.
|
||||
((looking-back (rx (+ (or " " "\t")))
|
||||
((looking-back (rx bol (+ (or " " "\t")))
|
||||
(line-beginning-position))
|
||||
(beginning-of-line))))
|
||||
|
||||
|
|
|
@ -2063,9 +2063,8 @@ DEFUN ("treesit-node-field-name-for-child",
|
|||
Return nil if there's no Nth child, or if it has no field.
|
||||
If NODE is nil, return nil.
|
||||
|
||||
N counts all children, i.e., named ones and anonymous ones.
|
||||
|
||||
N could be negative, e.g., -1 represents the last child. */)
|
||||
Note that N counts named nodes only. Also, N could be negative, e.g.,
|
||||
-1 represents the last child. */)
|
||||
(Lisp_Object node, Lisp_Object n)
|
||||
{
|
||||
if (NILP (node))
|
||||
|
@ -2079,7 +2078,7 @@ N could be negative, e.g., -1 represents the last child. */)
|
|||
|
||||
/* Process negative index. */
|
||||
if (idx < 0)
|
||||
idx = ts_node_child_count (treesit_node) + idx;
|
||||
idx = ts_node_named_child_count (treesit_node) + idx;
|
||||
if (idx < 0)
|
||||
return Qnil;
|
||||
if (idx > UINT32_MAX)
|
||||
|
|
|
@ -91,3 +91,37 @@ main (int argc,
|
|||
}
|
||||
}
|
||||
=-=-=
|
||||
|
||||
Name: Bracketless Simple Statement (bug#66152)
|
||||
|
||||
=-=
|
||||
for (int i = 0; i < 5; i++)
|
||||
continue;
|
||||
|
||||
while (true)
|
||||
return 1;
|
||||
|
||||
do
|
||||
i++;
|
||||
while (true)
|
||||
|
||||
if (true)
|
||||
break;
|
||||
else
|
||||
break;
|
||||
=-=
|
||||
for (int i = 0; i < 5; i++)
|
||||
continue;
|
||||
|
||||
while (true)
|
||||
return 1;
|
||||
|
||||
do
|
||||
i++;
|
||||
while (true)
|
||||
|
||||
if (true)
|
||||
break;
|
||||
else
|
||||
break;
|
||||
=-=-=
|
||||
|
|
44
test/lisp/progmodes/js-resources/js-ts-indents.erts
Normal file
44
test/lisp/progmodes/js-resources/js-ts-indents.erts
Normal file
|
@ -0,0 +1,44 @@
|
|||
Code:
|
||||
(lambda ()
|
||||
(setq indent-tabs-mode nil)
|
||||
(setq js-indent-level 2)
|
||||
(js-ts-mode)
|
||||
(indent-region (point-min) (point-max)))
|
||||
|
||||
Name: Basic indentation
|
||||
|
||||
=-=
|
||||
const foo = () => {
|
||||
console.log("bar");
|
||||
if (x) {
|
||||
return y;
|
||||
} else if (y) {
|
||||
return u;
|
||||
}
|
||||
return baz.x()
|
||||
? true
|
||||
: false;
|
||||
}
|
||||
=-=-=
|
||||
|
||||
Name: Statement indentation without braces
|
||||
|
||||
=-=
|
||||
function bracketless_statements(x) {
|
||||
if (x == 0)
|
||||
console.log("if_statement");
|
||||
else if (x == 1)
|
||||
console.log("if_statement");
|
||||
else
|
||||
console.log("else_clause");
|
||||
for (let i = 0; i < 1; i++)
|
||||
console.log("for_statement");
|
||||
for (let _ of [true])
|
||||
console.log("for_in_statement");
|
||||
while (x-- > 0)
|
||||
console.log("while_statement");
|
||||
do
|
||||
console.log("do_statement");
|
||||
while (false)
|
||||
};
|
||||
=-=-=
|
|
@ -288,6 +288,12 @@ function bar() {
|
|||
;; end-of-defun should move point to eob.
|
||||
(should (eobp))))
|
||||
|
||||
;;;; Tree-sitter tests.
|
||||
|
||||
(ert-deftest js-ts-mode-test-indentation ()
|
||||
(skip-unless (treesit-ready-p 'javascript))
|
||||
(ert-test-erts-file (ert-resource-file "js-ts-indents.erts")))
|
||||
|
||||
(provide 'js-tests)
|
||||
|
||||
;;; js-tests.el ends here
|
||||
|
|
Loading…
Add table
Reference in a new issue