Merge from origin/emacs-29

973c1d24c6 ruby-ts-mode: Also don't reindent 'identifier' when insid...
a5651c0c40 ruby-ts-mode: Fix indentation inside empty if/unless/case...
0ec0a610ed * lisp/iimage.el (iimage-mode-buffer): Handle multiple re...
d11d7aee1a ; Fix memory leak in treesit.c
This commit is contained in:
Stefan Kangas 2023-02-09 06:30:12 +01:00
commit 1518fc5d7c
4 changed files with 31 additions and 4 deletions

View file

@ -118,8 +118,8 @@ Examples of image filename patterns to match:
file)
(with-silent-modifications
(save-excursion
(goto-char (point-min))
(dolist (pair iimage-mode-image-regex-alist)
(goto-char (point-min))
(while (re-search-forward (car pair) nil t)
(when (and (setq file (match-string (cdr pair)))
(setq file (locate-file file image-path)))

View file

@ -571,7 +571,7 @@ a statement container is a node that matches
;; Incomplete buffer state, better not reindent (bug#61017).
((and (parent-is "ERROR")
(or (node-is ,ruby-ts--class-or-module-regex)
(node-is "\\`def\\'")))
(node-is "\\`\\(?:def\\|identifier\\)\\'")))
no-indent 0)
;; if then else elseif notes:
@ -661,6 +661,13 @@ a statement container is a node that matches
((n-p-gp nil "body_statement" ,ruby-ts--method-regex) ;other statements
(ruby-ts--align-keywords ruby-ts--grand-parent-node) ruby-indent-level)
;; Quirk of the ruby parser: these "alignable" nodes don't
;; have the "container" child node when there are no
;; statements inside. Thus we have to have a separate rule
;; for the "empty if/unless/case/def" situation.
((match "\\`\\'" "\\`\\(?:if\\|unless\\|case\\|method\\)\\'")
(ruby-ts--align-keywords ruby-ts--parent-node) ruby-indent-level)
;; Chained calls:
;; if `ruby-align-chained-calls' is true, the first query
;; matches and the node is aligned under the first dot (.);

View file

@ -617,10 +617,14 @@ treesit_load_language (Lisp_Object language_symbol,
eassume (handle != NULL);
dynlib_error ();
TSLanguage *(*langfn) (void);
char *c_name = xstrdup (SSDATA (base_name));
treesit_symbol_to_c_name (c_name);
char *c_name;
if (found_override)
c_name = xstrdup (SSDATA (override_c_name));
else
{
c_name = xstrdup (SSDATA (base_name));
treesit_symbol_to_c_name (c_name);
}
langfn = dynlib_sym (handle, c_name);
xfree (c_name);
error = dynlib_error ();

View file

@ -122,6 +122,22 @@ The whitespace before and including \"|\" on each line is removed."
(funcall indent-line-function)
(should (= (current-indentation) ruby-indent-level))))
(ert-deftest ruby-ts-indent-empty-if-else ()
(skip-unless (treesit-ready-p 'ruby t))
(let* ((str "c = if foo
zz
else
zz
end
"))
(ruby-ts-with-temp-buffer str
(goto-char (point-min))
(dotimes (_ 2)
(re-search-forward "^ *zz")
(replace-match "")
(funcall indent-line-function)
(should (= (current-indentation) 6))))))
(ert-deftest ruby-ts-add-log-current-method-examples ()
(skip-unless (treesit-ready-p 'ruby t))
(let ((pairs '(("foo" . "#foo")