; 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.
This commit is contained in:
parent
f50cb7d7c4
commit
4b1714571c
1 changed files with 15 additions and 9 deletions
|
@ -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 (append res (list buffer)) (cdr buffers))
|
||||||
(loop res (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
|
(defcustom c-ts-mode-indent-style 'gnu
|
||||||
"Style used for indentation.
|
"Style used for indentation.
|
||||||
|
|
||||||
|
@ -139,13 +130,28 @@ follows the form of `treesit-simple-indent-rules'."
|
||||||
:set #'c-ts-mode--indent-style-setter
|
:set #'c-ts-mode--indent-style-setter
|
||||||
:group 'c)
|
: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 ()
|
(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)
|
(interactive)
|
||||||
|
;; FIXME: Should we use `derived-mode-p' here?
|
||||||
(or (eq major-mode 'c-ts-mode) (eq major-mode 'c++-ts-mode)
|
(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)"
|
(error "Buffer %s is not a c-ts-mode (c-ts-mode-set-style)"
|
||||||
(buffer-name)))
|
(buffer-name)))
|
||||||
(c-ts-mode--indent-style-setter
|
(c-ts-mode--indent-style-setter
|
||||||
'c-ts-mode-indent-style
|
'c-ts-mode-indent-style
|
||||||
|
;; NOTE: We can probably use the interactive form for this.
|
||||||
(intern
|
(intern
|
||||||
(completing-read
|
(completing-read
|
||||||
"Select style: "
|
"Select style: "
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue