diff --git a/doc/emacs/modes.texi b/doc/emacs/modes.texi index 06f9929092c..0e4b15fb514 100644 --- a/doc/emacs/modes.texi +++ b/doc/emacs/modes.texi @@ -429,8 +429,11 @@ For example, one element normally found in the list has the form @code{(@t{"\\.c\\'"} . c-mode)}, and it is responsible for selecting C mode for files whose names end in @file{.c}. (Note that @samp{\\} is needed in Lisp syntax to include a @samp{\} in the string, which must -be used to suppress the special meaning of @samp{.} in regexps.) If -the element has the form @w{@code{(@var{regexp} @var{mode-function} +be used to suppress the special meaning of @samp{.} in regexps.) + +@cindex backup files, choosing a major mode +@cindex encrypted files, choosing a major mode +If the element has the form @w{@code{(@var{regexp} @var{mode-function} @var{flag})}} and @var{flag} is non-@code{nil}, then after calling @var{mode-function} (if it is non-@code{nil}), Emacs discards the suffix that matched @var{regexp} and searches the list again for diff --git a/etc/NEWS.29 b/etc/NEWS.29 index 9f735bec443..38f2db26a1a 100644 --- a/etc/NEWS.29 +++ b/etc/NEWS.29 @@ -53,29 +53,31 @@ yourself. Many libraries can be downloaded from the tree-sitter site: https://github.com/tree-sitter -To compile such a library, compile the files "scanner.c" and "parser.c" -(sometimes named "scanner.cc" and "parser.cc") in the "src" subdirectory -of the library's source tree using the C or C++ compiler, then link -these two files into a shared library named "libtree-sitter-LANG.so", -where LANG is the name of the language supported by the grammar as it -is expected by the Emacs major mode (for example, "c" for 'c-ts-mode', -"cpp" for 'c++-ts-mode', "python" for 'python-ts-mode', etc.). Then place -the shared library you've built in the same directory where you keep -the other shared libraries used by Emacs, or in the "tree-sitter" -subdirectory of your 'user-emacs-directory', or in a directory -mentioned in the variable 'treesit-extra-load-path'. - -You only need to install language grammar libraries required by the -Emacs modes you will use, as Emacs loads these libraries only when the -corresponding mode is turned on in some buffer for the first time in -an Emacs session. - Emacs provides a user command, 'treesit-install-language-grammar', that automates the download and build process of a grammar library. It prompts for the language, the URL of the language grammar's VCS repository, and then uses the installed C/C++ compiler to build the library and install it. +You can also do this manually. To compile such a library after +cloning its Git repository, compile the files "scanner.c" and +"parser.c" (sometimes named "scanner.cc" and "parser.cc") in the "src" +subdirectory of the library's source tree using the C or C++ compiler, +then link these two files into a shared library named +"libtree-sitter-LANG.so", where LANG is the name of the language +supported by the grammar as it is expected by the Emacs major mode +(for example, "c" for 'c-ts-mode', "cpp" for 'c++-ts-mode', "python" +for 'python-ts-mode', etc.). Then place the shared library you've +built in the same directory where you keep the other shared libraries +used by Emacs, or in the "tree-sitter" subdirectory of your +'user-emacs-directory', or in a directory mentioned in the variable +'treesit-extra-load-path'. + +You only need to install language grammar libraries required by the +Emacs modes you will use, as Emacs loads these libraries only when the +corresponding mode is turned on in some buffer for the first time in +an Emacs session. + +++ ** Emacs can be built with built-in support for accessing SQLite databases. This uses the popular sqlite3 library, and can be disabled by using diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index 2e8d335f151..2de7395f765 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el @@ -1927,7 +1927,7 @@ If the result is do-end block, it will always be multiline." (end-of-line) (unless (if (and (re-search-backward "\\(?:[^#]\\)\\({\\)\\|\\(\\_\\)") - (progn + (let ((ruby-use-smie (and ruby-use-smie (consp smie-grammar)))) (goto-char (or (match-beginning 1) (match-beginning 2))) (setq beg (point)) (with-suppressed-warnings ((obsolete ruby-forward-sexp)) diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el index 66b50a4b540..f0337775d51 100644 --- a/lisp/progmodes/ruby-ts-mode.el +++ b/lisp/progmodes/ruby-ts-mode.el @@ -648,9 +648,6 @@ a statement container is a node that matches parent 0) ((match "\\." "call") parent ruby-indent-level) - ;; ruby-indent-after-block-in-continued-expression - ((match "begin" "assignment") parent ruby-indent-level) - ;; method parameters -- four styles: ;; 1) With paren, first arg on same line: ((and (query "(method_parameters \"(\" _ @indent)") @@ -680,7 +677,9 @@ a statement container is a node that matches ((and (query "(argument_list \"(\" _ @indent)") (node-is ")")) ruby-ts--parent-call-or-bol 0) - ((query "(argument_list \"(\" _ @indent)") + ((or (query "(argument_list \"(\" _ @indent)") + ;; No arguments yet; NODE is nil in that case. + (match "\\`\\'" "argument_list")) ruby-ts--parent-call-or-bol ruby-indent-level) ;; 3) No paren, ruby-parenless-call-arguments-indent is t ((and ruby-ts--parenless-call-arguments-indent-p (parent-is "argument_list")) @@ -704,10 +703,9 @@ a statement container is a node that matches ;; ruby-mode does not touch these... ((match "bare_string" "string_array") no-indent 0) - ;; hash and array other than assignments. Note that the - ;; first sibling is the "{" or "[". There is a special - ;; case where the hash is an argument to a method. These - ;; need to be processed first. + ;; hash and array. Note that the first sibling is the "{" + ;; or "[". There is a special case where the hash is an + ;; argument to a method. These need to be processed first. ((and ruby-ts--same-line-hash-array-p (match "}" "hash")) first-sibling 0) diff --git a/lisp/treesit.el b/lisp/treesit.el index 7aeff3b8b49..9d622de5580 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -1102,10 +1102,12 @@ See `treesit-simple-indent-presets'.") (string-match-p parent-t (treesit-node-type parent))) (or (null grand-parent-t) - (string-match-p - grand-parent-t - (treesit-node-type - (treesit-node-parent parent)))))))) + (and + (treesit-node-parent parent) + (string-match-p + grand-parent-t + (treesit-node-type + (treesit-node-parent parent))))))))) (cons 'no-node (lambda (node &rest _) (null node))) (cons 'parent-is (lambda (type) (lambda (_n parent &rest _) diff --git a/test/lisp/progmodes/ruby-ts-mode-tests.el b/test/lisp/progmodes/ruby-ts-mode-tests.el index d34c235e82b..18e3e60a04a 100644 --- a/test/lisp/progmodes/ruby-ts-mode-tests.el +++ b/test/lisp/progmodes/ruby-ts-mode-tests.el @@ -110,6 +110,18 @@ The whitespace before and including \"|\" on each line is removed." | 42 | end"))) + +(ert-deftest ruby-ts-indent-call-no-args () + (skip-unless (treesit-ready-p 'ruby t)) + (ruby-ts-with-temp-buffer + "variable = foo( + +)" + (goto-char (point-min)) + (forward-line 1) + (funcall indent-line-function) + (should (= (current-indentation) ruby-indent-level)))) + (ert-deftest ruby-ts-add-log-current-method-examples () (skip-unless (treesit-ready-p 'ruby t)) (let ((pairs '(("foo" . "#foo")