Closed aurabindo closed 4 years ago
Just saw #10051 So I'll close this.
Reopening since the suggested fix in #10051 did not fix my problem. Did the way to change the default C style change in C-C++ layer ?
So this is not working as intended ?
The above layer variable should be nil
by default.
@syl20bnr I enable clang-format as mentioned in the Readme, and I also have the following in dotspacemacs/user-config
(setq-default
c-default-style "bsd"
c-basic-offset 4)
)
I am not enabling google style explicitly. But my above setting is not being respected as SPC j =
formats my C code with indentation of 2 rather than 4. What do I need to tweak to get this fixed ?
I bisected this down to 16fd3e85a4e0941c365722d28cbe81eef02a1305, which landed in develop sometime in December. It seem like the when
checks in c-c++/init-google-c-style
doesn't respect the layer variables correctly:
(defun c-c++/init-google-c-style ()
(use-package google-c-style
:if (or 'c-c++-enable-google-style 'c-c++-enable-google-newline)
:config (progn
(when 'c-c++-enable-google-style (add-hook 'c-mode-common-hook 'google-set-c-style))
(when 'c-c++-enable-google-newline (add-hook 'c-mode-common-hook 'google-make-newline-indent)))))
So:
(when 'c-c++-enable-google-style (print "FOO"))
prints "FOO", while:
(when c-c++-enable-google-style (print "FOO"))
does not and returns nil
. The variables are supposed to be evaluated and not quoted, I suppose?
To add to that:
c-mode-common-hook is a variable defined in ‘cc-vars.el’.
Its value is
(google-make-newline-indent google-set-c-style spacemacs//init-company-c-mode-common company-mode)
Original value was nil
This variable may be risky if used as a file-local variable.
It's clear that the functions have been added to the c-mode-common-hook
while c-c++-enable-google-style
and c-c++-enable-google-newline
are set to nil
.
@myme thank you for the fix, should be fixed in develop.
Confirmed, this fixes the issue for me.
I use these slice of code to modify the c-basic-indent
in google-c-style without exclude it,
(eval-after-load 'google-c-style
(dolist (v google-c-style)
(when (and (listp v) (eq (car v) 'c-basic-offset))
(setcdr v 4))))
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!
Description :octocat:
C-C++ Layer: not respecting c-basic-offset setting. My spacemacs config contains:
Reproduction guide :beetle:
Observed behaviour: :eyes: :broken_heart:
Offset defaults to default value of 2 in C-C++ mode
Expected behaviour: :heart: :smile:
offset must be set to the value specified in user-config()
System Info :computer:
Backtrace :paw_prints: