1

Inexperienced programmer here - When I open Emacs (24.5) on Mac Mavericks 10.9, I am getting a delay between the Emacs GUI opening and the init file being loaded. There is a white screen, which appears to do nothing for ~7 seconds.

Could this be a result of something in my init file (which otherwise loads without error), or must it originate from something in my PATH or .bash_profile?

I have an alias set to open emacs from the Terminal:

alias="open /Path/To/Emacs-x86_64-10_9"

Any other ideas what this might be our how I can debug the pause?

EDIT1

Here is the output of etc/hosts, @phils having pointed out it may be the cause.

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
#127.0.0.1      localhost
255.255.255.255 broadcasthost
::1             localhost
fe80::1%lo0     localhost
n1k31t4
  • 669
  • 8
  • 18
  • If it's your init file, you can test that by starting Emacs with `emacs -q` to prevent it from processing that file. Otherwise, is [this](http://stackoverflow.com/a/23621608/324105) the problem? – phils Jan 04 '16 at 08:43
  • @phils - I can't say I completely understand that post - I have updated my OP with the contents of the `/etc/hosts` file, hoping it means something to you and others. – n1k31t4 Jan 04 '16 at 08:55
  • @DexterMorgan as for starting emacs with the `-q` option: open your terminal app (Terminal.app) and enter `emacs -q` at the prompt. Does this make things load quickly? – elethan Jan 04 '16 at 12:55
  • @elethan - I actually get the message saying the `-q` flag is invalid. I have done this before though so it must be something to do with the alias I mentioned, or possibly a problem with my $PATH? Even opening a file using `open file.txt -a /path_to_emacs -q` is returning the same error. – n1k31t4 Jan 04 '16 at 13:16
  • Do you use a custom theme? What happens if you exclude it? – Lindydancer Jan 04 '16 at 13:55
  • @Lindydancer - this didn't change anything, still a long pause with a white screen for ~7 seconds before the init file begins to load. The way it appears it makes me think it is a problem like phil mentioned above with his link, regarding Emacs not finding the correct domain. There are no error messages given anywhere and nothing out of the ordinary mentioned in the *Messages* buffer of Emacs after loading. Also the fact that launching with `-q` isn't working points more towards a system problem rather than an init-file issue. I am, however, stumped! – n1k31t4 Jan 04 '16 at 14:35
  • Ok, I managed to run emacs with the `-q` flag and it opens quickly as expected. So the problem may be in the init file - but does this mean it **must** be there? It loads without error though, so not sure what the issue could be - does the `-q` flag prevent anything else during startup, aoart from the init file being read? – n1k31t4 Jan 04 '16 at 15:04
  • If the problem disappears with emacs -q, it is almost certainly a problem with your init file. You can test this by copying your original init to a safe place, and using a subset (i.e., the first half) in its place. If the problem goes away, you know its in the second half of the init file. Otherwise, its in the first half. Repeat until you find the lines that cause the problem. – Tyler Jan 04 '16 at 16:11
  • 1
    An upper-case `-Q` combines a few other options, but lower-case `-q` is equivalent to `--no-init-file` and doesn't prevent any other start-up activities, so this does look like an init file issue. See `C-h i g (emacs) Initial Options` for details on the available command-line options. – phils Jan 04 '16 at 20:02
  • @Tyler - Thanks for the comments, everyone. I finally had time to 'chunk through' my init file. Turned out - to my embarrassement - I was installing `pdftools` every time Emacs started. I must have inadvertently uncommented those lines out at some point. – n1k31t4 Jan 08 '16 at 08:32

1 Answers1

3

A bit of added information for your init file processing time:

Put this at the very start of your init file:

(defvar my-init-load-start (current-time))

and this at the very end:

;; Display the time taken to start Emacs.
(let ((my-init-time (time-to-seconds (time-since my-init-load-start))))
  (add-hook 'after-init-hook
            `(lambda ()
               (message "Init time was %.2fs (%.2fs in %s)."
                        (time-to-seconds (time-since before-init-time))
                        ,my-init-time
                        (file-name-nondirectory user-init-file)))))

After starting Emacs, look for that timing message in the echo area, or else switch to the *Messages* buffer with C-he to find it in the log.

phils
  • 48,657
  • 3
  • 76
  • 115