7

After a long debugging of my init.el file, it looks like the first line of the following elisp-code, i.e (custom-set-variablesis provoking an 'End of file during parsing' error) which I absolutely don't understand. If I comment this line, all is fine. I did not even enter this code myself, as it has been automatically added in init.el from the customize menu.

(custom-set-variables
'(global-hl-line-mode t)
'(ido-mode (quote buffer) nil (ido))
'(menu-bar-mode nil)
 (when (display-graphic-p)
 (tool-bar-mode -1)
 (scroll-bar-mode -1))

Here is the complete error message:

Warning (initialization): An error occurred while loading `/Users/me/.emacs.d/init.el':

End of file during parsing: /Users/me/.emacs.d/init.el

Any help would be appreciated ! Thanks

  • If the file is large, you can use M-x check-parens to jump to the offending section. If the file is short, or you are looking at a short section of code, then there are methods to highlight matching parentheses to visually see where a parentheses is misplaced or missing. Here is a link to my own variation of highlight-parentheses-mode: stackoverflow.com/a/23998965/2112489 – lawlist Sep 11 '16 at 15:58
  • Please don't use custom-set-variables in your own Elisp code. This is meant to be auto-generated only. Don't copy&paste it. Look for equivalent code using setq or something like that. – Stefan Sep 12 '16 at 19:49
13

The "end of file during parsing" error means that you have not closed a paren.

To debug this, you should

  1. Do M-x check-parens RET to pinpoint the location of the current error.
  2. Enable show-paren-mode to see which paren matches your current one - this will help you with on-going code maintenance.
  3. Use C-M-f/C-M-b to navigate by balanced parens; if you get an error, this is where your open parent which was not closed is.
  4. Use TAB to indent each line and see if the new indentation conforms to your expectations.

The other answer correctly explains what the actual error is in your case.

4

A closing parentheses is missing in the example above. The when statment is not part of the custom-set-variables. The corrected code is as follows:

(custom-set-variables
  '(global-hl-line-mode t)
  '(ido-mode (quote buffer) nil (ido))
  '(menu-bar-mode nil))

(when (display-graphic-p)
  (tool-bar-mode -1)
  (scroll-bar-mode -1))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.