diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi index ba0d919549b..d0c8f3e90e8 100644 --- a/doc/lispref/functions.texi +++ b/doc/lispref/functions.texi @@ -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 diff --git a/doc/lispref/parsing.texi b/doc/lispref/parsing.texi index df81a805e67..36238c1e1d7 100644 --- a/doc/lispref/parsing.texi +++ b/doc/lispref/parsing.texi @@ -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 diff --git a/doc/lispref/variables.texi b/doc/lispref/variables.texi index 85a28c1d9c1..336a776bdc4 100644 --- a/doc/lispref/variables.texi +++ b/doc/lispref/variables.texi @@ -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. diff --git a/etc/refcards/orgcard.tex b/etc/refcards/orgcard.tex index 4b73a544e80..11e046fc0dd 100644 --- a/etc/refcards/orgcard.tex +++ b/etc/refcards/orgcard.tex @@ -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 diff --git a/lisp/filesets.el b/lisp/filesets.el index 639b108ac03..8e7ddab8c1c 100644 --- a/lisp/filesets.el +++ b/lisp/filesets.el @@ -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) diff --git a/lisp/language/sinhala.el b/lisp/language/sinhala.el index bf320506001..a5c379b3aae 100644 --- a/lisp/language/sinhala.el +++ b/lisp/language/sinhala.el @@ -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 diff --git a/lisp/org/ob-plantuml.el b/lisp/org/ob-plantuml.el index 3202c6e415d..febdb3964c6 100644 --- a/lisp/org/ob-plantuml.el +++ b/lisp/org/ob-plantuml.el @@ -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 diff --git a/lisp/org/org-element.el b/lisp/org/org-element.el index c5c92838050..34eb27b6465 100644 --- a/lisp/org/org-element.el +++ b/lisp/org/org-element.el @@ -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) diff --git a/lisp/org/org-macs.el b/lisp/org/org-macs.el index 4efa8ba6800..6ed901b7397 100644 --- a/lisp/org/org-macs.el +++ b/lisp/org/org-macs.el @@ -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 diff --git a/lisp/org/org-persist.el b/lisp/org/org-persist.el index dc9fe3a7103..59ef2ac27a0 100644 --- a/lisp/org/org-persist.el +++ b/lisp/org/org-persist.el @@ -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)))) diff --git a/lisp/org/org-version.el b/lisp/org/org-version.el index e5b0fbcf2a9..8eebdbe09b2 100644 --- a/lisp/org/org-version.el +++ b/lisp/org/org-version.el @@ -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) diff --git a/lisp/org/org.el b/lisp/org/org.el index 31915135efa..d1f63762e50 100644 --- a/lisp/org/org.el +++ b/lisp/org/org.el @@ -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) diff --git a/lisp/org/ox-beamer.el b/lisp/org/ox-beamer.el index 2590bd5fa72..10a2c803a00 100644 --- a/lisp/org/ox-beamer.el +++ b/lisp/org/ox-beamer.el @@ -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) diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 9102d428c92..94c1d9ac654 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -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 _) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 51d2dd74e2b..6e43cc2b01c 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -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") diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 44eda03f7ce..61bd94222ac 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -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 diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index ab3bf1b4ec0..211969140ab 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -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 diff --git a/lisp/term.el b/lisp/term.el index 81746e0c20d..d75a7d22aed 100644 --- a/lisp/term.el +++ b/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" ()) diff --git a/lisp/treesit.el b/lisp/treesit.el index 9f885985f3b..c6b9d8ff4bc 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -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)))) diff --git a/src/treesit.c b/src/treesit.c index b8de95ec691..c85038e70cf 100644 --- a/src/treesit.c +++ b/src/treesit.c @@ -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) diff --git a/test/lisp/progmodes/c-ts-mode-resources/indent-bsd.erts b/test/lisp/progmodes/c-ts-mode-resources/indent-bsd.erts index 74e34fe821b..fa65ba83a69 100644 --- a/test/lisp/progmodes/c-ts-mode-resources/indent-bsd.erts +++ b/test/lisp/progmodes/c-ts-mode-resources/indent-bsd.erts @@ -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; +=-=-= diff --git a/test/lisp/progmodes/js-resources/js-ts-indents.erts b/test/lisp/progmodes/js-resources/js-ts-indents.erts new file mode 100644 index 00000000000..2e34b23acef --- /dev/null +++ b/test/lisp/progmodes/js-resources/js-ts-indents.erts @@ -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) +}; +=-=-= diff --git a/test/lisp/progmodes/js-tests.el b/test/lisp/progmodes/js-tests.el index 5db92b08f8a..827d7bb8a99 100644 --- a/test/lisp/progmodes/js-tests.el +++ b/test/lisp/progmodes/js-tests.el @@ -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