mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 10:30:25 -08:00
Add prog-fill-reindent-defun (bug#59664)
Introduce a new command that aims to reindent code in a defun, or fill a paragraph of text. The command uses treesit.el when available, otherwise falls back to using syntax-ppss and regexps. Treesit.el needs a new variable that is intended to be set by the major modes so that this and other future functions can know what kind of node we are looking at. * doc/emacs/programs.texi: Mention the new command. * etc/NEWS: Mention the new command. * lisp/progmodes/c-ts-mode.el (c++-ts-mode): Add regexp for the new variable. * lisp/progmodes/csharp-mode.el (csharp-ts-mode): Add regexp for the new variable. * lisp/progmodes/java-ts-mode.el (java-ts-mode): Add regexp for the new variable. * lisp/progmodes/js.el (js-ts-mode): Add regexp for the new variable. * list/progmodes/prog-mode.el (prog-mode-map): Bind the new command by default. (prog-fill-reindent-defun): New command. * lisp/progmodes/sh-script.el (bash-ts-mode): Add regexp for the new variable. * lisp/progmodes/typescript-ts-mode.el (typescript-ts-base-mode): Add regexp for the new variable. * lisp/treesit.el (treesit-text-type-regexp): New variable.
This commit is contained in:
parent
77d0793787
commit
b889eced44
10 changed files with 95 additions and 2 deletions
|
|
@ -3860,6 +3860,11 @@ Currently there are `js-mode' and `js-ts-mode'."
|
|||
(group (or (syntax comment-end)
|
||||
(seq (+ "*") "/")))))
|
||||
(setq-local comment-multi-line t)
|
||||
|
||||
(setq-local treesit-text-type-regexp
|
||||
(regexp-opt '("comment"
|
||||
"template_string")))
|
||||
|
||||
;; Electric-indent.
|
||||
(setq-local electric-indent-chars
|
||||
(append "{}():;," electric-indent-chars)) ;FIXME: js2-mode adds "[]*".
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue