diff options
| author | Juri Linkov | 2025-01-12 20:17:16 +0200 |
|---|---|---|
| committer | Juri Linkov | 2025-01-12 20:17:16 +0200 |
| commit | 2d2bc6f1bc678b21c46af26cf343e24acdb48b79 (patch) | |
| tree | 91d0d54f87c8e1f5fd0c6114c9325eeaac443d9d | |
| parent | 7648faedd3aeabadc66c67630809ef6178f4851a (diff) | |
| download | emacs-2d2bc6f1bc678b21c46af26cf343e24acdb48b79.tar.gz emacs-2d2bc6f1bc678b21c46af26cf343e24acdb48b79.zip | |
Add treesit-thing-settings to yaml-ts-mode and enable transpose-sexps
* lisp/treesit.el (treesit-major-mode-setup): Move setting of
'transpose-sexps-function' outside of 'treesit-thing-defined-p'
since 'treesit-transpose-sexps' doesn't depend on the 'sexp' thing.
* lisp/textmodes/yaml-ts-mode.el (yaml-ts-mode):
Add 'treesit-thing-settings' with the 'list' thing,
but use it only for list commands, not sexp commands (bug#73404).
| -rw-r--r-- | lisp/textmodes/yaml-ts-mode.el | 17 | ||||
| -rw-r--r-- | lisp/treesit.el | 5 |
2 files changed, 19 insertions, 3 deletions
diff --git a/lisp/textmodes/yaml-ts-mode.el b/lisp/textmodes/yaml-ts-mode.el index 957102950b4..defef096aa6 100644 --- a/lisp/textmodes/yaml-ts-mode.el +++ b/lisp/textmodes/yaml-ts-mode.el | |||
| @@ -167,7 +167,22 @@ boundaries. JUSTIFY is passed to `fill-paragraph'." | |||
| 167 | 167 | ||
| 168 | (setq-local fill-paragraph-function #'yaml-ts-mode--fill-paragraph) | 168 | (setq-local fill-paragraph-function #'yaml-ts-mode--fill-paragraph) |
| 169 | 169 | ||
| 170 | (treesit-major-mode-setup))) | 170 | ;; Navigation. |
| 171 | (setq-local treesit-thing-settings | ||
| 172 | `((yaml | ||
| 173 | (list ,(regexp-opt '("block_mapping_pair" | ||
| 174 | "flow_sequence")) | ||
| 175 | 'symbols)))) | ||
| 176 | |||
| 177 | (treesit-major-mode-setup) | ||
| 178 | |||
| 179 | ;; Use the `list' thing defined above to navigate only lists | ||
| 180 | ;; with `C-M-n', `C-M-p', `C-M-u', `C-M-d', but not sexps | ||
| 181 | ;; with `C-M-f', `C-M-b' neither adapt to 'show-paren-mode' | ||
| 182 | ;; that is problematic in languages without explicit | ||
| 183 | ;; opening/closing nodes. | ||
| 184 | (setq-local forward-sexp-function nil) | ||
| 185 | (setq-local show-paren-data-function 'show-paren--default))) | ||
| 171 | 186 | ||
| 172 | (derived-mode-add-parents 'yaml-ts-mode '(yaml-mode)) | 187 | (derived-mode-add-parents 'yaml-ts-mode '(yaml-mode)) |
| 173 | 188 | ||
diff --git a/lisp/treesit.el b/lisp/treesit.el index 056d96ad7ad..ac34edaf84d 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el | |||
| @@ -3593,9 +3593,10 @@ before calling this function." | |||
| 3593 | (setq-local add-log-current-defun-function | 3593 | (setq-local add-log-current-defun-function |
| 3594 | #'treesit-add-log-current-defun)) | 3594 | #'treesit-add-log-current-defun)) |
| 3595 | 3595 | ||
| 3596 | (setq-local transpose-sexps-function #'treesit-transpose-sexps) | ||
| 3597 | |||
| 3596 | (when (treesit-thing-defined-p 'sexp nil) | 3598 | (when (treesit-thing-defined-p 'sexp nil) |
| 3597 | (setq-local forward-sexp-function #'treesit-forward-sexp) | 3599 | (setq-local forward-sexp-function #'treesit-forward-sexp)) |
| 3598 | (setq-local transpose-sexps-function #'treesit-transpose-sexps)) | ||
| 3599 | 3600 | ||
| 3600 | (when (treesit-thing-defined-p 'list nil) | 3601 | (when (treesit-thing-defined-p 'list nil) |
| 3601 | (setq-local forward-sexp-function #'treesit-forward-sexp-list) | 3602 | (setq-local forward-sexp-function #'treesit-forward-sexp-list) |