views:

456

answers:

2

Hi, I've been getting this error in emacs whenever I type anything in certain buffers:

c-forward-sws: Wrong type argument: stringp, nil

It seems to be a syntax highlighting thing; I'm getting it in a buffer that's in sh-mode whenever I type anything -- even return on an empty line. I have also occasionally gotten it in a C++-mode buffer but I don't remember the specific line, nor can I reproduce it in such a mode.

I have not changed my .emacs lately (that I can recall).

Any ideas what the problem is? The function is defined in cc-engine.el but I'm having a hard time figuring out the context.

+2  A: 

To figure out the problem, you need to do a little more investigation. What you've provided isn't enough (unless the answerer has already seen the specific problem).

The first step is generally to set the variable debug-on-error to t. This will provide a stack trace with more information (generally telling you which expression inside the function is causing the problem).

If you can reliably reproduce the problem, then don't set the above variable, but instead go to the function definition (M-x find-function c-forward-sws RET), and set it up for debugging with M-x edebug-defun. Then do what causes the error and step through the code. The debugger is pretty intuitive if you're familiar with looking at lisp, and the documentation can be found on this info page.

At the very least, adding the stack trace might provide enough information to lead to an answer, though likely it'll take a test case to reproduce the problem...

Trey Jackson
I was hoping someone would have seen the specific problem before. Now that I have time to look at it more, I can't reproduce the problem, so I can't debug further. Oh well...
xzqx
+2  A: 

Chances are good that you have auto-fill-mode on and the auto-fill-function is c-do-auto-fill, which doesn't work so well for other languages. Either turn auto fil off (M-x auto-fill-mode) or change the value of the fill function.

You should be able to debug the entry to auto-fill-mode explicitly with M-x debug-on-entry RET auto-fill-mode and see what's invoking it. There's probably a hook that's turning it on, which will appear in the stack trace.

[Update]

I found that the global value of auto-fill-function was being set (it's supposed to always be buffer-local). The result is that all buffers default to using auto fill with that function. I haven't determined how the global value is being set, but it can be cleared up using (setq-default auto-fill-function nil).

0x4b
Thanks. If I see this again, I'll try it.
xzqx
I'm seeing this again, and this is exactly what is happening. I'm in fundamental fill mode, so I'm not sure why the auto-fill-function is c-do-auto-fill. In fact, this is true of any new buffer I open in fundamental mode, but just in this emacs session. Seems like somehow the emacs session got corrupted.
xzqx