diff options
| author | Yuan Fu | 2022-12-24 00:16:45 -0800 |
|---|---|---|
| committer | Yuan Fu | 2022-12-24 00:33:17 -0800 |
| commit | a42b20dd95e4ca522c090f9edf110dcd132b616f (patch) | |
| tree | f20bedc2a366cc6a2a34fd9ea147692814ba7252 /lisp/progmodes | |
| parent | e4e3634539920d14395b19121715c50b3f022909 (diff) | |
| download | emacs-a42b20dd95e4ca522c090f9edf110dcd132b616f.tar.gz emacs-a42b20dd95e4ca522c090f9edf110dcd132b616f.zip | |
; * lisp/progmodes/c-ts-mode.el: Add outline section headers.
Diffstat (limited to 'lisp/progmodes')
| -rw-r--r-- | lisp/progmodes/c-ts-mode.el | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 10f7bf58403..471d9a3dec0 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el | |||
| @@ -39,6 +39,8 @@ | |||
| 39 | (declare-function treesit-node-child-by-field-name "treesit.c") | 39 | (declare-function treesit-node-child-by-field-name "treesit.c") |
| 40 | (declare-function treesit-node-type "treesit.c") | 40 | (declare-function treesit-node-type "treesit.c") |
| 41 | 41 | ||
| 42 | ;;; Custom variables | ||
| 43 | |||
| 42 | (defcustom c-ts-mode-indent-offset 2 | 44 | (defcustom c-ts-mode-indent-offset 2 |
| 43 | "Number of spaces for each indentation step in `c-ts-mode'." | 45 | "Number of spaces for each indentation step in `c-ts-mode'." |
| 44 | :version "29.1" | 46 | :version "29.1" |
| @@ -91,6 +93,8 @@ follows the form of `treesit-simple-indent-rules'." | |||
| 91 | table) | 93 | table) |
| 92 | "Syntax table for `c++-ts-mode'.") | 94 | "Syntax table for `c++-ts-mode'.") |
| 93 | 95 | ||
| 96 | ;;; Indent | ||
| 97 | |||
| 94 | (defun c-ts-mode--indent-styles (mode) | 98 | (defun c-ts-mode--indent-styles (mode) |
| 95 | "Indent rules supported by `c-ts-mode'. | 99 | "Indent rules supported by `c-ts-mode'. |
| 96 | MODE is either `c' or `cpp'." | 100 | MODE is either `c' or `cpp'." |
| @@ -381,6 +385,8 @@ MODE is either `c' or `cpp'." | |||
| 381 | @c-ts-mode--fontify-defun) | 385 | @c-ts-mode--fontify-defun) |
| 382 | (:match "^DEFUN$" @fn))))) | 386 | (:match "^DEFUN$" @fn))))) |
| 383 | 387 | ||
| 388 | ;;; Font-lock helpers | ||
| 389 | |||
| 384 | (defun c-ts-mode--fontify-declarator (node override start end &rest args) | 390 | (defun c-ts-mode--fontify-declarator (node override start end &rest args) |
| 385 | "Fontify a declarator (whatever under the \"declarator\" field). | 391 | "Fontify a declarator (whatever under the \"declarator\" field). |
| 386 | For NODE, OVERRIDE, START, END, and ARGS, see | 392 | For NODE, OVERRIDE, START, END, and ARGS, see |
| @@ -473,6 +479,8 @@ For NODE, OVERRIDE, START, and END, see | |||
| 473 | (t 'font-lock-warning-face)) | 479 | (t 'font-lock-warning-face)) |
| 474 | override start end))) | 480 | override start end))) |
| 475 | 481 | ||
| 482 | ;;; Imenu | ||
| 483 | |||
| 476 | (defun c-ts-mode--imenu-1 (node) | 484 | (defun c-ts-mode--imenu-1 (node) |
| 477 | "Helper for `c-ts-mode--imenu'. | 485 | "Helper for `c-ts-mode--imenu'. |
| 478 | Find string representation for NODE and set marker, then recurse | 486 | Find string representation for NODE and set marker, then recurse |
| @@ -537,6 +545,8 @@ the subtrees." | |||
| 537 | (when var-index `(("Variable" . ,var-index))) | 545 | (when var-index `(("Variable" . ,var-index))) |
| 538 | (when func-index `(("Function" . ,func-index)))))) | 546 | (when func-index `(("Function" . ,func-index)))))) |
| 539 | 547 | ||
| 548 | ;;; Defun navigation | ||
| 549 | |||
| 540 | (defun c-ts-mode--end-of-defun () | 550 | (defun c-ts-mode--end-of-defun () |
| 541 | "`end-of-defun-function' of `c-ts-mode'." | 551 | "`end-of-defun-function' of `c-ts-mode'." |
| 542 | ;; A struct/enum/union_specifier node doesn't include the ; at the | 552 | ;; A struct/enum/union_specifier node doesn't include the ; at the |
| @@ -582,6 +592,8 @@ the semicolon. This function skips the semicolon." | |||
| 582 | (treesit-node-end node)) | 592 | (treesit-node-end node)) |
| 583 | (goto-char orig-point))) | 593 | (goto-char orig-point))) |
| 584 | 594 | ||
| 595 | ;;; Filling | ||
| 596 | |||
| 585 | (defun c-ts-mode--fill-paragraph (&optional arg) | 597 | (defun c-ts-mode--fill-paragraph (&optional arg) |
| 586 | "Fillling function for `c-ts-mode'. | 598 | "Fillling function for `c-ts-mode'. |
| 587 | ARG is passed to `fill-paragraph'." | 599 | ARG is passed to `fill-paragraph'." |
| @@ -646,6 +658,8 @@ ARG is passed to `fill-paragraph'." | |||
| 646 | ;; itself. | 658 | ;; itself. |
| 647 | t))) | 659 | t))) |
| 648 | 660 | ||
| 661 | ;;; Modes | ||
| 662 | |||
| 649 | (defvar-keymap c-ts-mode-map | 663 | (defvar-keymap c-ts-mode-map |
| 650 | :doc "Keymap for the C language with tree-sitter" | 664 | :doc "Keymap for the C language with tree-sitter" |
| 651 | :parent prog-mode-map | 665 | :parent prog-mode-map |