Search code examples
emacsclojureelispemacs24

Emacs claims I'm quoting a lambda, but I'm not


I added this to my init.el in emacs:

(add-hook 'emacs-startup-hook
  (lambda ()
    (kill-buffer "*scratch*")
    (ido-mode t)
    (global-visual-line-mode 1)))

(add-hook 'clojure-mode-hook
 (lambda ()
    (rainbow-delimiters-mode 1)))

Now emacs automatically turns the word lambda into the symbol lambda but I don't know if that is the issue. When I startup emacs, it reports:

(lambda (line) ...) quoted with ' rather than with #'

But I am not quoting the lambda. If I remove the above lines of code, the error goes away.

Why does it give me that error?


Solution

  • This isn't a bug in your code, but in some code provided with Emacs that is called by one of the functions you're calling. It is quite possibly Emacs bug #11357.

    Your code is appropriate, except that as sds noted you're overcomplicating things with emacs-startup-hook. Most things can be done right when your .emacs is being loaded.

    (ido-mode t)
    (global-visual-line-mode 1)
    (add-hook 'emacs-startup-hook
      (lambda ()
        (kill-buffer "*scratch*")))
    

    The only reason I can think of to use emacs-startup-hook the way you did is if you frequently reload your .emacs and you frequently change ido-mode or global-visual-line-mode and don't want them to be reverted when you reload .emacs.

    For alternate ways of getting more out of Emacs than killing *scratch*, see Automatically closing the scratch buffer and Prevent unwanted buffers from opening.