Search code examples
emacsspacemacs

spacemacs "file mode specification error"


I'm running an up-to-date version of spacemacs, on the master branch. In my init file, I've got a number of cc-mode settings, including (as part of c-offsets-alist) "(innamespace . 0)". I'm finding that when I open a C++ file, I get the error "File mode specification error: (void-function innamespace)".

Here's the full set of c-offsets-alist modifications:

(c-offsets-alist            . ((access-label . -3)
                                 (brace-list-close . 0)
                                 (brace-list-entry . 0)
                                 (brace-list-intro . +)
                                 (class-close . 0)
                                 (class-open . 0)
                                 (defun-block-intro . +)
                                 (defun-close . 0)
                                 (defun-open . 0)
                                 (inclass . +)
                                 (label . 0)
                                 (statement . 0)
                                 (statement-cont . *)
                                 (topmost-intro-cont . 0)
                                 (arglist-close . c-lineup-arglist)
                                 (block-open . 0)
                                 (case-label . +)
                                 (func-decl-cont . c-lineup-java-throws)
                                 (inexpr-class . 0)
                                 (inher-cont . c-lineup-java-inher)
                                 (inline-open . 0)
                                 (substatement-open . 0)
                                 (innamespace . 0)
                                 ))

Here's the backtrace from the debugger:

Debugger entered--Lisp error: (void-function innamespace)
  (innamespace 0)
  (lambda nil (innamespace 0))()
  run-hooks(change-major-mode-after-body-hook prog-mode-hook c-mode-common-hook c++-mode-hook)
  apply(run-hooks (change-major-mode-after-body-hook prog-mode-hook c-mode-common-hook c++-mode-hook))
  run-mode-hooks(c++-mode-hook)
  c++-mode()
  set-auto-mode-0(c++-mode nil)
  set-auto-mode()
  normal-mode(t)
  after-find-file(nil t)
  find-file-noselect-1(#<buffer geometry.cpp> "~/sandbox/cpp/geometry.cpp" nil nil "~/sandbox/cpp/geometry.cpp" (85065815 2049))
.
.
.

Interestingly, if I'm actually within a namespace, cc-mode honors my innamespace setting. I've even commented out the setting in my init file, and still get the error. Any ideas about how to deal with this?


Solution

  • It turned out that, not surprisingly, the problem wasn't where I was looking. In addition to the bundle of settings that included the c-offsets-alist values that I showed in my original question, there was a form that I don't remember adding:

      (setq c++-mode-hook
            '(lambda ()
               (innamespace 0)))
    

    I expect that I put it in carelessly - a copy and paste mishap, most likely. Let this be a cautionary tale - I should have caught this way before posting my question.