summaryrefslogtreecommitdiff
path: root/test/lisp/progmodes/c-ts-mode-resources
diff options
context:
space:
mode:
authorYuan Fu <casouri@gmail.com>2023-02-02 18:23:21 -0800
committerYuan Fu <casouri@gmail.com>2023-02-02 18:32:08 -0800
commitd963a8f1355a6d829af3f98182e66705c941e774 (patch)
tree23768d527db2dc85e9332c0443b2c6c53588782f /test/lisp/progmodes/c-ts-mode-resources
parent8a6bdf88b4b665916cf74dee3a30e9136a9b6df8 (diff)
downloademacs-d963a8f1355a6d829af3f98182e66705c941e774.tar.gz
emacs-d963a8f1355a6d829af3f98182e66705c941e774.tar.bz2
emacs-d963a8f1355a6d829af3f98182e66705c941e774.zip
Make c-ts-mode indent tests side-effect-free
Running indent tests changes the global value of c-ts-mode-indent-style. That's not good. This change fixes that. I also refactored the indent style functions a bit. * lisp/progmodes/c-ts-mode.el: (c-ts-mode--prompt-for-style): New function. (c-ts-mode-set-local-style): New function. (c-ts-mode-set-style): Use c-ts-mode--prompt-for-style. Use derived-mode-p when testing for major mode. Remove check of current buffer's major mode since it doesn't matter. * test/lisp/progmodes/c-ts-mode-resources/indent-bsd.erts: * test/lisp/progmodes/c-ts-mode-resources/indent.erts: Use c-ts-mode-set-local-style to set the indent style locally.
Diffstat (limited to 'test/lisp/progmodes/c-ts-mode-resources')
-rw-r--r--test/lisp/progmodes/c-ts-mode-resources/indent-bsd.erts6
-rw-r--r--test/lisp/progmodes/c-ts-mode-resources/indent.erts12
2 files changed, 9 insertions, 9 deletions
diff --git a/test/lisp/progmodes/c-ts-mode-resources/indent-bsd.erts b/test/lisp/progmodes/c-ts-mode-resources/indent-bsd.erts
index 07698077ffc..ba4f854baf8 100644
--- a/test/lisp/progmodes/c-ts-mode-resources/indent-bsd.erts
+++ b/test/lisp/progmodes/c-ts-mode-resources/indent-bsd.erts
@@ -1,9 +1,9 @@
Code:
(lambda ()
- (setq indent-tabs-mode nil)
- (setq c-ts-mode-indent-offset 2)
- (setq c-ts-mode-indent-style 'bsd)
(c-ts-mode)
+ (setq-local indent-tabs-mode nil)
+ (setq-local c-ts-mode-indent-offset 2)
+ (c-ts-mode-set-local-style 'bsd)
(indent-region (point-min) (point-max)))
Point-Char: |
diff --git a/test/lisp/progmodes/c-ts-mode-resources/indent.erts b/test/lisp/progmodes/c-ts-mode-resources/indent.erts
index 0ecbf922b15..3704f06d2ae 100644
--- a/test/lisp/progmodes/c-ts-mode-resources/indent.erts
+++ b/test/lisp/progmodes/c-ts-mode-resources/indent.erts
@@ -1,9 +1,9 @@
Code:
(lambda ()
- (setq indent-tabs-mode nil)
- (setq c-ts-mode-indent-offset 2)
- (setq c-ts-mode-indent-style 'gnu)
(c-ts-mode)
+ (setq-local indent-tabs-mode nil)
+ (setq-local c-ts-mode-indent-offset 2)
+ (c-ts-mode-set-local-style 'gnu)
(indent-region (point-min) (point-max)))
Point-Char: |
@@ -219,10 +219,10 @@ line 2
Code:
(lambda ()
- (setq indent-tabs-mode nil)
- (setq c-ts-mode-indent-offset 8)
- (setq c-ts-mode-indent-style 'linux)
(c-ts-mode)
+ (setq-local indent-tabs-mode nil)
+ (setq-local c-ts-mode-indent-offset 8)
+ (c-ts-mode-set-local-style 'linux)
(indent-region (point-min) (point-max)))
Name: Labels (Linux Style)