In my latest ubuntu box,

  1. When I type for example emacs ~/.bashrc, Emacs will start but not open .bashrc. This is true for any file I pass in. I've used Emacs for several years, and have never experienced this problem before.

  2. I added (global-font-lock-mode 1);; to my .emacs file, and Emacs does recognize it, for example. "(C++/; Abbrev)", but it won't do syntax highlighting.

If you can solve any of these problems, it will be very appreciated. The following is my machine's configuration:

uname -a
Linux 2.6.35-28-generic-pae #49-Ubuntu SMP Tue Mar 1 14:58:06 UTC 2011 i686 GNU/Linux

(global-font-lock-mode 1);;

migrated from stackoverflow.com Mar 27 '11 at 8:13

This question came from our site for professional and enthusiast programmers.

  • 1
    Better asked on askubuntu.com – Oded Mar 26 '11 at 21:22
  • 1
    What happens if you start emacs then use C-x C-f to open ~/.bashrc? Might give you a useful error message. – Tom Zych Mar 26 '11 at 21:27
  • 1
    Does the *Messages* buffer contain anything useful? – MatthewD Mar 27 '11 at 2:35
  • 1
    hi thanks a lot, it seems it is caused by the directory ~/.emacs.d, emacs actually complains upon startup :"~/.emacs.d already exists". So I removed ~/.emacs.d, and now everything works! (I can open files through command line argument and syntax highlighting also works now). @Tom, previously I can start emacs, and then use C-x C-f to open .bashrc, but cannot open by > emacs ~/.bashrc – Jus Mar 27 '11 at 5:13

I got the same problem. It was due to the fact I first used emacs with sudo. As a consequence the .emacs.d was created with super user right and I could not access it as a regular user.

By removing the .emacs.d created as root let emacs generate a new one with your user account.

  • 3
    or you can simply change owner sudo chown -hR <groupname>:<username> .emacs.d/ – logcat Aug 5 '13 at 6:11
  • 1
    Yep, this fixed the problem. It'd be great if emacs showed some information about this error... – José Tomás Tocino May 1 '14 at 15:03
  • There really ought to be some kind of diagnostic about this. This must happen a lot when emacs is used as a system administration tool. – Jules Dec 24 '17 at 11:45

You can have both ~/.emacs file and ~/.emacs.d/ directory, but Emacs will ignore ~/.emacs.d/init.el file. Emacs only evaluates ~/.emacs.d/init.el when there is no ~/.emacs. (Thanks, pyrocrasty).

See: The Emacs Initialization File @ GNU Emacs Manual.

  • That's not true at all. I used a ~/.emacs file for years and I certainly always had a ~/.emacs.d/ directory. There won't be any conflict unless you have a ~/.emacs file and a ~/.emacs.d/init.el file at the same time, and even then, Emacs will just ignore one (I believe it prioritizes ~/.emacs). – pyrocrasty May 16 '15 at 17:27
  • If you correct an error, in the future please don't strike it out, but just remove it entirely. Thanks. I left the comment stay so you can actually tell its posted that you corrected your answer. (They may upvote you or undo a downvote.) – slhck May 16 '15 at 17:44

initial-buffer-choice in startup.el allows initial file customization.

  • 2
    perhaps some context would be helpful. An example config? – JoshP Sep 28 '12 at 14:34

Your Answer

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