Discussion:
CC mode 5.33 does not work on Emacs 24.5.1 for Mac
Juha Nieminen
2016-09-05 07:34:57 UTC
Permalink
Hello. I'm using the following version of Emacs:

GNU Emacs 24.5.1 (x86_64-apple-darwin13.4.0, NS apple-appkit-1265.21)
of 2015-04-10 on builder10-9.porkrind.org

I downloaded CC Mode 5.33 from http://cc-mode.sourceforge.net/ and
followed the installation instructions.

On that note (although not the main reason to make this bug report),
trying to do a "M-x byte-recompile-directory RET /path/to/cc-mode RET"
as per the instructions only results in Emacs saying "Done (Total of 0
files compiled, 15 skipped)", and no .elc files appear in said
directory. (Although to be fair, the instructions actually prepend
that command with a "M-0", which I have no idea what it means. If I
press alt-0, or esc + 0, all it does is to give a very strange
message: "After 0 kbd macro iterations: Keyboard macro terminated by a
command ringing the bell". It has no effect on subsequent commands.)
Running the shell command did work, however, and it created the .elc
files.

After adding the directory to the load path, the new CC mode 5.33 is
loaded when I open a source code file ("M-x c-version" gives "Using CC
Mode version 5.33"). However, it does not work properly.

Immediately upon opening a source code file, it gives the error "File
mode specification error: (wrong-type-argument stringp nil)". The text
itself is also only partially colored (eg. some comment lines are
colored while others aren't). Trying to autoindent by pressing tab
gives the error "Wrong type argument: stringp, nil".

This is not caused by anything else I'm setting/loading in my .emacs
file, as the same behavior happens even if there is nothing else in
said file other than the add-to-list 'load-path command.

------------------------------------------------------------------------------
Alan Mackenzie
2016-09-06 08:22:18 UTC
Permalink
Hello, Juha.

Thanks for the email, and sorry you've been having trouble.
Post by Juha Nieminen
GNU Emacs 24.5.1 (x86_64-apple-darwin13.4.0, NS apple-appkit-1265.21)
of 2015-04-10 on builder10-9.porkrind.org
I downloaded CC Mode 5.33 from http://cc-mode.sourceforge.net/ and
followed the installation instructions.
On that note (although not the main reason to make this bug report),
trying to do a "M-x byte-recompile-directory RET /path/to/cc-mode RET"
as per the instructions only results in Emacs saying "Done (Total of 0
files compiled, 15 skipped)", and no .elc files appear in said
directory. (Although to be fair, the instructions actually prepend
that command with a "M-0", which I have no idea what it means.
Press and hold the "meta" key whilst typing a 0 (that's a zero, not an
upper case o). After having done that, do M-x byte-recompile-directory.
The meta key for "M-0" should be the same as the one used for M-x ...

The "M-0" acts as a modifier to the byte-recompile-directory, telling it
to recompile ALL .el files. Without that modifier, the command only
recompiles .el files for which there's already a .elc. Yes, I find this
a bit crazy, too. ;-). You can get full details about a command by
typing C-h f <name of command>.
Post by Juha Nieminen
If I press alt-0, or esc + 0, all it does is to give a very strange
message: "After 0 kbd macro iterations: Keyboard macro terminated by a
command ringing the bell". It has no effect on subsequent commands.)
It seems that, somehow, your M-0 has been bound to a different command
than the standard one. You can find out which command that is by typing
C-h c M-0. When I do that, I get "M-0 runs the command digit-argument".

As a workaround, C-u 0 might (?should) work.
Post by Juha Nieminen
Running the shell command did work, however, and it created the .elc
files.
Good!
Post by Juha Nieminen
After adding the directory to the load path, the new CC mode 5.33 is
loaded when I open a source code file ("M-x c-version" gives "Using CC
Mode version 5.33"). However, it does not work properly.
Immediately upon opening a source code file, it gives the error "File
mode specification error: (wrong-type-argument stringp nil)". The text
itself is also only partially colored (eg. some comment lines are
colored while others aren't). Trying to autoindent by pressing tab
gives the error "Wrong type argument: stringp, nil".
Something is failing, indeed.

Would you please set the variable `debug-on-error' to t by typing

M-x toggle-debug-on-error

(or there may be an option to do this from the menu, under <options>),
then try opening a source file again. This should create a backtrace.
Could you post that backtrace here, please. That should give more of a
clue to where the bug is.
Post by Juha Nieminen
This is not caused by anything else I'm setting/loading in my .emacs
file, as the same behavior happens even if there is nothing else in
said file other than the add-to-list 'load-path command.
OK, thanks, that's good to hear!
--
Alan Mackenzie (Nuremberg, Germany).

------------------------------------------------------------------------------
Alan Mackenzie
2016-09-06 18:26:29 UTC
Permalink
Hello, Juha
Post by Alan Mackenzie
Would you please set the variable `debug-on-error' to t by typing
M-x toggle-debug-on-error
Thanks for such a rapid reply!
Debugger entered--Lisp error: (wrong-type-argument stringp nil)
signal(wrong-type-argument (stringp nil))
c-syntactic-re-search-forward(nil nil t t) <=====================
c-forward-<>-arglist-recur(nil) <=====================
byte-code("\302 !\211 \207" [all-types c-record-found-types
c-forward-<>-arglist-recur] 2)
c-forward-<>-arglist(nil)
c-restore-<>-properties(1 1002 1001)
#[(fn) " eddeZ#\207" [fn] 5](c-restore-<>-properties)
mapc(#[(fn) " eddeZ#\207" [fn] 5] (c-depropertize-new-text
c-extend-font-lock-region-for-macros c-before-after-change-digit-quote
c-after-change-re-mark-raw-strings c-neutralize-syntax-in-and-mark-CPP
c-restore-<>-properties c-change-expand-fl-region))
c-common-init(c++-mode)
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 test.cc> "~/tmp/test.cc" nil nil
"~/tmp/test.cc" (14346868 16777218))
find-file-noselect("~/tmp/test.cc" nil nil t)
find-file("~/tmp/test.cc" t)
call-interactively(find-file nil nil)
command-execute(find-file)
The two lines I have marked near the top of the backtrace indicate the
problem. c-forward-<>-arglist-recur is calling
c-syntactic-re-search-forward with a first parameter set to nil. That
first parameter MUST be a string.

Looking at the source, there is only one call to
c-syntactic-re-search-forward in the other function, and its first
argument is the "variable" c-<>-notable-chars-re. The fact that this
"variable" is nil suggests that something has gone wrong with the mode
initialisation.

It feels to me like there is a ghost of the previous version of CC Mode
still haunting your Emacs - c-<>-notable-chars-re is new in CC Mode
5.33. Could it be that you are somehow loading files (perhaps with
"desktop") into Emacs before CC Mode 5.33 becomes active?

To test this out, would you please try the following: start Emacs like
this:

$ emacs -Q -L /path/to/CC-Mode

, and then try loading your C++ test file. If that works, we're half
way to solving the problem, if it doesn't work, we're only a quarter of
the way there. :-)

Please let me know how this goes. Thanks!
--
Alan Mackenzie (Nuremberg, Germany).

------------------------------------------------------------------------------
Alan Mackenzie
2016-09-13 09:16:58 UTC
Permalink
Hello, Juha.
Let's have a look at your .emacs!
As said, it happens even if there is nothing else in my .emacs file
(add-to-list 'load-path "~/software/cc-mode-5.33/")
I don't know how to find out what is interfering with cc-mode.
Could you possibly have a site-lisp.el which is interfering with the
loading of CC Mode? To test this, try starting Emacs from the command
line as:

$ emacs --no-site-file

. (This prevents site-lisp.el from being loaded, but still loads your
.emacs.) If this works OK, then find your site-lisp.el, and see what's
causing the old CC Mode to get loaded. All this stuff is documented in
the Emacs manual on the page "Init File".

Sorry I can only suggest this one thing for now.
On an additional note, I tried cc-mode 5.33 on emacs for Windows, and
there it seemed to work fine, even with all the other stuff in my
.emacs file.
Well, that's one good thing at least. :-)
--
Alan Mackenzie (Nuremberg, Germany).

------------------------------------------------------------------------------
Loading...