bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#940: Is there a way to quit loading of ~/.emacs please?


From: Juanma Barranquero
Subject: bug#940: Is there a way to quit loading of ~/.emacs please?
Date: Tue, 9 Sep 2008 15:52:43 +0200

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 via email to

[Prev in Thread] Current Thread [Next in Thread]