[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-29 4b1714571c8 3/6: ; Fix byte-compile warnings in c-ts-mode.el
From: |
Yuan Fu |
Subject: |
emacs-29 4b1714571c8 3/6: ; Fix byte-compile warnings in c-ts-mode.el |
Date: |
Sun, 29 Jan 2023 03:13:07 -0500 (EST) |
branch: emacs-29
commit 4b1714571c8c6cf7ae2ee2602c66b7c903c45a4a
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>
; Fix byte-compile warnings in c-ts-mode.el
* lisp/progmodes/c-ts-mode.el:
(c-ts-mode--get-indent-style): Move down.
(c-ts-mode-set-style): Add docstring.
---
lisp/progmodes/c-ts-mode.el | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index 26ad61c975d..353c4c45479 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -114,15 +114,6 @@ the value of SYM in `c-ts-mode' and `c++-ts-mode' buffers
to VAL."
(loop (append res (list buffer)) (cdr buffers))
(loop res (cdr buffers))))))))
-(defun c-ts-mode--get-indent-style (mode)
- "Helper function to set indentation style.
-MODE is either `c' or `cpp'."
- (let ((style
- (if (functionp c-ts-mode-indent-style)
- (funcall c-ts-mode-indent-style)
- (alist-get c-ts-mode-indent-style (c-ts-mode--indent-styles
mode)))))
- `((,mode ,@style))))
-
(defcustom c-ts-mode-indent-style 'gnu
"Style used for indentation.
@@ -139,13 +130,28 @@ follows the form of `treesit-simple-indent-rules'."
:set #'c-ts-mode--indent-style-setter
:group 'c)
+(defun c-ts-mode--get-indent-style (mode)
+ "Helper function to set indentation style.
+MODE is either `c' or `cpp'."
+ (let ((style
+ (if (functionp c-ts-mode-indent-style)
+ (funcall c-ts-mode-indent-style)
+ (alist-get c-ts-mode-indent-style (c-ts-mode--indent-styles
mode)))))
+ `((,mode ,@style))))
+
(defun c-ts-mode-set-style ()
+ "Set the indent style of C/C++ modes globally.
+
+This changes the current indent style of every C/C++ buffer and
+the default C/C++ indent style in this Emacs session."
(interactive)
+ ;; FIXME: Should we use `derived-mode-p' here?
(or (eq major-mode 'c-ts-mode) (eq major-mode 'c++-ts-mode)
(error "Buffer %s is not a c-ts-mode (c-ts-mode-set-style)"
(buffer-name)))
(c-ts-mode--indent-style-setter
'c-ts-mode-indent-style
+ ;; NOTE: We can probably use the interactive form for this.
(intern
(completing-read
"Select style: "
- emacs-29 updated (56e8607dc99 -> 1970726e26a), Yuan Fu, 2023/01/29
- emacs-29 4b1714571c8 3/6: ; Fix byte-compile warnings in c-ts-mode.el,
Yuan Fu <=
- emacs-29 1970726e26a 6/6: Use treesit-subtree-stat to determine treesit--font-lock-fast-mode, Yuan Fu, 2023/01/29
- emacs-29 f50cb7d7c4b 2/6: ; Improve docstring of c-ts-mode--indent-style-setter, Yuan Fu, 2023/01/29
- emacs-29 a3003492ace 4/6: Move c-ts-mode--statement-offset to c-ts-common.el, Yuan Fu, 2023/01/29
- emacs-29 1c3ca3bb649 1/6: Fix <> syntax in rust-ts-mode, Yuan Fu, 2023/01/29
- emacs-29 382e018856a 5/6: Add treesit-subtree-stat, Yuan Fu, 2023/01/29