all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Juanma Barranquero" <lekktu@gmail.com>
To: "Yiyi Hu" <yiyihu@gmail.com>, 940@emacsbugs.donarmstrong.com
Subject: bug#940: Is there a way to quit loading of ~/.emacs please?
Date: Tue, 9 Sep 2008 15:52:43 +0200	[thread overview]
Message-ID: <f7ccd24b0809090652h445fa42ah8b4ab9cc3db93d00@mail.gmail.com> (raw)
In-Reply-To: <f469f8de0809082350n503279b0pe511fe1277e275ae@mail.gmail.com>

On Tue, Sep 9, 2008 at 08:50, Yiyi Hu <yiyihu@gmail.com> wrote:
> Is there a way to quit the loading after we compile the ~/.emacs and
> load the ~/.emacs.elc file?

If you can modify site-start.el, you can use something similar to this
code, which compiles the init source file only when the .elc exists
and is stale, or compiled with a newer Emacs (which could easily cause
trouble).

;; site-start.el
;;
(catch 'init-file
  (dolist (source-file '("~/.emacs.el" "~/.emacs" ;; ~/.emacs.elc
                         "~/_emacs.el" "~/_emacs" ;; ~/_emacs.elc (if
on Windows)
                         "~/.emacs.d/init.el"))   ;; ~/.emacs.d/init.elc
    (when (file-exists-p source-file)
      (require 'bytecomp)
      (let ((byte-file (byte-compile-dest-file source-file)))
        (unless (file-exists-p byte-file) (throw 'init-file nil))
        (when (or (time-less-p (nth 5 (file-attributes byte-file))
                               (nth 5 (file-attributes source-file)))
                  (with-temp-buffer
                    (insert-file-contents-literally byte-file nil 0 5)
                    (and (looking-at ";ELC")
                         (> (char-after 5) emacs-major-version))))
          (let* ((split-width-threshold nil) ;; 23.1+
                 (window (display-buffer (get-buffer-create "*Compile-Log*"))))
            (fit-window-to-buffer window)
            (set-window-dedicated-p window t)
            (unwind-protect
                 (or (byte-compile-file source-file)
                     (y-or-n-p-with-timeout
                      (format "Error bytecompiling %s; do you want to
load it? " source-file)
                      10 nil)
                     (setq init-file-user nil))
              (fit-window-to-buffer window)))))

 Juanma






  reply	other threads:[~2008-09-09 13:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-09  6:50 bug#940: Is there a way to quit loading of ~/.emacs please? Yiyi Hu
2008-09-09 13:52 ` Juanma Barranquero [this message]
2008-09-09 14:19 ` Lennart Borgman (gmail)
2008-09-09 18:24   ` Yiyi Hu
2008-09-09 22:10     ` Lennart Borgman (gmail)
2008-09-09 23:45       ` Yiyi Hu
     [not found]     ` <18631.27735.100063.263157@kahikatea.snap.net.nz>
2008-09-10  7:53       ` Yiyi Hu
2008-09-09 14:52 ` Stefan Monnier
2011-10-04 19:31 ` Glenn Morris

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f7ccd24b0809090652h445fa42ah8b4ab9cc3db93d00@mail.gmail.com \
    --to=lekktu@gmail.com \
    --cc=940@emacsbugs.donarmstrong.com \
    --cc=yiyihu@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.