Fixed the =c-c++-default-mode-for-headers= should not affect the default behavior for Emacs > 26.1+

This commit is contained in:
sunlin7 2019-08-16 07:21:00 +08:00 committed by smile13241324
parent 5f308b0306
commit 53f1445ecc
4 changed files with 12 additions and 7 deletions

View File

@ -1143,7 +1143,10 @@ Other:
(thanks to Fangrui Song and Codruț Constantin Gușoi)
- Added =org-babel= support (thanks to Michael Rohleder)
- Added debugger integration via =dap= layer
- Added detecting ".ccls" for ccls powered projects.
- Added detecting ".ccls" for ccls powered projects
- Fixed the =c-c++-default-mode-for-headers= should not affect the default
behavior that opening a .h file will turn C or C++ mode depending on
language used in Emacs > 26.1+ (thanks to Lin Sun)
- Key bindings:
- ~SPC m = =~ clang-format current region or buffer (thanks to Dela Anthonio)
- ~SPC m = f~ clang-format current function (thanks to Dela Anthonio)

View File

@ -74,8 +74,9 @@ file.
*Note:* [[https://github.com/tuhdo/semantic-refactor][semantic-refactor]] is only available for Emacs 24.4+
** Default mode for header files
By default header files are opened in =c-mode=, you can open them in =c++-mode=
by setting the variable =c-c++-default-mode-for-headers= to =c++-mode=.
Mode for header files is auto detected by `c-or-c++-mode' in Emacs > 26.1+.
Older Emacs will open header files in =c-mode= by default, you can open them in
=c++-mode= by setting the variable =c-c++-default-mode-for-headers= as follow.
#+BEGIN_SRC emacs-lisp
(setq-default dotspacemacs-configuration-layers

View File

@ -51,8 +51,8 @@
"If non-nil, automatically format code with ClangFormat on
save. Clang support has to be enabled for this to work.")
(defvar c-c++-default-mode-for-headers 'c-mode
"Default mode to open header files. Can be `c-mode' or `c++-mode'.")
(defvar c-c++-default-mode-for-headers (when (not (functionp 'c-or-c++-mode)) 'c-mode)
"Default mode to open header files. Can be `c-mode' or `c++-mode', or `c-or-c++-mode' for Emacs > 26+.")
(defvar c-c++-adopt-subprojects nil
"When non-nil, projectile will remember project root when visiting files in subprojects")

View File

@ -51,8 +51,9 @@
:defer t
:init
(progn
(add-to-list 'auto-mode-alist
`("\\.h\\'" . ,c-c++-default-mode-for-headers))
(when c-c++-default-mode-for-headers
(add-to-list 'auto-mode-alist
`("\\.h\\'" . ,c-c++-default-mode-for-headers)))
(when c-c++-enable-auto-newline
(add-hook 'c-mode-common-hook 'spacemacs//c-toggle-auto-newline)))
:config