1

Recently, I often encounter errors like this:

Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)

I found that in some situations, the error is caused by expressions like this:

(= nil 4)    

I'm not sure whether this expression is intended to write like this, but it will work only if I change it to:

(eq nil 4)

However, (1) I need to replace all = to eq in that emacs lisp script (2) I'm not sure the codes should be modified like this.

I was wondering that whether I can write a few lines in the config file (.emacs) instead of modify on the source code to get things done. Does anyone have ideas about this?

martin
  • 1,102
  • 2
  • 12
  • 20
Hanfei Sun
  • 45,281
  • 39
  • 129
  • 237

1 Answers1

8

Don't do this.

You're going down the path of hiding errors in code. Figure out the root cause of why you're passing nil to = and fix that.

user229044
  • 232,980
  • 40
  • 330
  • 338
event_jr
  • 17,467
  • 4
  • 47
  • 62
  • Yes. @Firegun I saw you questions, you should figure out what exactly is going on. – Saddle Point Dec 28 '12 at 10:38
  • 1
    In other words, the bug is that the variable you are comparing to 4 should not be `nil` and you fix the bug by guarding against this earlier in the code, probably by reporting an error when the variable gets assigned, probably by a function which is assumed to return a value but which doesn't. – tripleee Dec 28 '12 at 10:59