diff options
author | Eli Zaretskii <eliz@gnu.org> | 2023-04-15 12:43:40 -0400 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2023-04-15 12:43:40 -0400 |
commit | 79b5d1022fd6131485743949ae44cbd79580d1e5 (patch) | |
tree | d70ba2aef4fb3bf73aa7b529b9c560b54c3c5c6a /lisp | |
parent | 0f7dea49d98889724316119ddf494923be15411b (diff) | |
parent | db8f207e52fc969e0dcf30e197bcfaa4fa1d2b6e (diff) | |
download | emacs-79b5d1022fd6131485743949ae44cbd79580d1e5.tar.gz |
Merge from origin/emacs-29
db8f207e52f Fix some cases of incomplete code's indentation [c/c++-ts...
589959fb09d project-search: Pipe the list of files through 'file-regu...
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/progmodes/c-ts-mode.el | 17 | ||||
-rw-r--r-- | lisp/progmodes/project.el | 5 |
2 files changed, 21 insertions, 1 deletions
diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index ece20e90a6f..600650aadc1 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -859,6 +859,18 @@ the semicolon. This function skips the semicolon." (goto-char (match-end 0))) (treesit-default-defun-skipper)) +(defun c-ts-base--before-indent (args) + (pcase-let ((`(,node ,parent ,bol) args)) + (when (null node) + (let ((smallest-node (treesit-node-at (point)))) + ;; "Virtual" closer curly added by the + ;; parser's error recovery. + (when (and (equal (treesit-node-type smallest-node) "}") + (equal (treesit-node-end smallest-node) + (treesit-node-start smallest-node))) + (setq parent (treesit-node-parent smallest-node))))) + (list node parent bol))) + (defun c-ts-mode-indent-defun () "Indent the current top-level declaration syntactically. @@ -933,6 +945,11 @@ the semicolon. This function skips the semicolon." ;; function_definitions, so we need to find the top-level node. (setq-local treesit-defun-prefer-top-level t) + ;; When the code is in incomplete state, try to make a better guess + ;; about which node to indent against. + (add-function :filter-args (local 'treesit-indent-function) + #'c-ts-base--before-indent) + ;; Indent. (when (eq c-ts-mode-indent-style 'linux) (setq-local indent-tabs-mode t)) diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index e7c0bd2069b..04c67710d71 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -1227,7 +1227,10 @@ To continue searching for the next match, use the command \\[fileloop-continue]." (interactive "sSearch (regexp): ") (fileloop-initialize-search - regexp (project-files (project-current t)) 'default) + regexp + ;; XXX: See the comment in project-query-replace-regexp. + (cl-delete-if-not #'file-regular-p (project-files (project-current t))) + 'default) (fileloop-continue)) ;;;###autoload |