GNU bug report logs -
#940
Is there a way to quit loading of ~/.emacs please?
Previous Next
Reported by: "Yiyi Hu" <yiyihu <at> gmail.com>
Date: Tue, 9 Sep 2008 07:00:03 UTC
Severity: wishlist
Tags: notabug, wontfix
Done: Glenn Morris <rgm <at> gnu.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 940 in the body.
You can then email your comments to 940 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#940
; Package
emacs
.
Full text and
rfc822 format available.
Acknowledgement sent to
"Yiyi Hu" <yiyihu <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
Full text and
rfc822 format available.
Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):
Hi, all. For now, I got a problem on how to do this.
Here is the sample ~/.emacs
(defun byte-compile-file-if-newer (src)
(let ((result (concat src ".elc")))
(when (file-newer-than-file-p src result)
(byte-compile-file src)
(load-file result))))
(byte-compile-file-if-newer "~/.emacs")
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(auto-compression-mode t)
'(column-number-mode t)
'(cperl-indent-level 4)
'(delete-selection-mode t)
'(display-battery-mode t)
'(display-time-24hr-format t)
'(display-time-day-and-date t)
'(display-time-mode t)
'(encoded-kbd-mode t)
'(gnus-nntp-server "news.readfreenews.net")
'(indent-tabs-mode nil)
'(inferior-lisp-program "sbcl")
'(inhibit-eol-conversion t)
'(inhibit-startup-screen t)
'(initial-scratch-message nil)
'(menu-bar-mode nil)
'(mouse-avoidance-mode (quote exile) nil (avoid)))
Is there a way to quit the loading after we compile the ~/.emacs and
load the ~/.emacs.elc file?
Ok, please don't bother talking about It's worthy or not for compiling
~/.emacs, I am talking a feature which *should* be supported by elisp
IMHO.
Yes, we can have a big condition around the rest of the ~/.emacs, But
that's not good practise. And If I do this, It will also confuse
things in M-x customize-group.
It's a bit like 'if' statements in emacs, 'if' is enough, but 'when'
and 'cond' statements is still there for supporting programming more
practically.
Also, I've ever done considering split ~/.emacs. To me, It's not a
good journey. There will be other problem when manage multiple start
up file.
I've tried add (return) to ~/.emacs, But there will be error as It's
not in a defun.
So, other possibility to quit the load of lib? Or enhance elisp by
adding a new 'keyword' or 'statement' to do this kind of job.
I also tried with (signal 'error nil) and (keyboard-quit), This worked
when you invoke emacs without any args. But when there is no
~/.emacs.elc file, and you invoke emacs with args, The passing args
won't be process by emacs.
I am using the newest emacs-cvs BTW.
Thanks.
Information forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#940
; Package
emacs
.
Full text and
rfc822 format available.
Acknowledgement sent to
"Juanma Barranquero" <lekktu <at> gmail.com>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
Full text and
rfc822 format available.
Message #10 received at 940 <at> emacsbugs.donarmstrong.com (full text, mbox):
On Tue, Sep 9, 2008 at 08:50, Yiyi Hu <yiyihu <at> 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
Information forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#940
; Package
emacs
.
Full text and
rfc822 format available.
Acknowledgement sent to
"Lennart Borgman (gmail)" <lennart.borgman <at> gmail.com>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
Full text and
rfc822 format available.
Message #15 received at 940 <at> emacsbugs.donarmstrong.com (full text, mbox):
Yiyi Hu wrote:
> (byte-compile-file-if-newer "~/.emacs")
...
> Is there a way to quit the loading after we compile the ~/.emacs and
> load the ~/.emacs.elc file?
>
> Ok, please don't bother talking about It's worthy or not for compiling
> ~/.emacs, I am talking a feature which *should* be supported by elisp
> IMHO.
There are many ways to do similar things and it is a bit hard to
understand what you really want. I can't imagine that it is the
behaviour you specified that you really want, or?
A simple way to do something similar is of course just to split .emacs.
Information forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#940
; Package
emacs
.
Full text and
rfc822 format available.
Acknowledgement sent to
Stefan Monnier <monnier <at> iro.umontreal.ca>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
Full text and
rfc822 format available.
Message #20 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):
> Is there a way to quit the loading after we compile the ~/.emacs and
> load the ~/.emacs.elc file?
Of course:
(defun byte-compile-file-if-newer (src)
(let ((result (concat src ".elc")))
(when (file-newer-than-file-p src result)
(byte-compile-file src)
(load-file result)
t)))
(unless (byte-compile-file-if-newer "~/.emacs")
... the rest of your .emacs...
)
-- Stefan
Information forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#940
; Package
emacs
.
Full text and
rfc822 format available.
Acknowledgement sent to
Stefan Monnier <monnier <at> iro.umontreal.ca>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
Full text and
rfc822 format available.
Information forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#940
; Package
emacs
.
Full text and
rfc822 format available.
Acknowledgement sent to
"Yiyi Hu" <yiyihu <at> gmail.com>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
Full text and
rfc822 format available.
Message #30 received at 940 <at> emacsbugs.donarmstrong.com (full text, mbox):
This is not a bug, Just a feature request for elisp language.
Ok, thanks for your replies, I'll explain this is *great* detail.
What I want to do is simple:
When emacs starts, It checks if ~/.emacs is newer than ~/.emacs.elc,
if it does, then it recompiles the ~/.emacs, and load ~/.emacs.elc on
the fly. But skip the rest of ~/.emacs, The reason why I want this
will be explained.
Here the story begins:
If I do something like:
(if (byte-compile-file-if-newer "~/.emacs") (load-file "~/.emacs.elc"))
Here is a situation depends on wether ~/.emacs.elc exists.
If ~/.emacs.elc exists and ever being compiled with a line (defalias
'perl-mode 'cperl-mode), and we remove
(defalias 'perl-mode 'cperl-mode) in ~/.emacs, then, cperl-mode will
still be in effect for the first time we start emacs use the new
~/.emacs, we have to restart emacs again or manually byte-compile the
~/.emacs. The reason which causes this is, the side effect created in
old ~/.emacs.elc will still in effect.
Why not use 'unless' statement version?
(unless (byte-compile-file-if-newer "~/.emacs")
remaining lisp code ...)
Because, This will confuse M-x customize-* series functions.
Eg, when you put (customize-set-variables ....) things within (unless
(byte-compile-file-if-newer "~/.emacs") )
When you do M-x customzie-variable <RET> again, It will crate another
list which is like (customize-set-variables ...) outside of the file
level (unless () ...) statement. If you think It's ok, Please check
the example above. (customize-set-variables ..) will take effect and
last a session.
Why not splitting ~/.emacs?
I did this, and It's not a happy journey. Eg, when change something, I
have to think wether I should put here or there, or within ~/.emacs.
At last, I choose using one ~/.emacs, Also, even if we split ~/.emacs,
we still need to recompiling ~/.emacs after we do customize-variable.
That's why I think the problem still exists.
I ever used (signal 'quit nil) to skiping loading the rest of
~/.emacs, It works fine except the time when we invoke emacs with file
name args. (signal 'quit nil) will cancel loading of files we
specified in args.
In fact, This is not a bug, Just a elisp language feature request.
Hope if we can have a function named (leave-load t) which we can
manually control when to stop loading the lisp source file.
How this function is used is as below:
(if (byte-compile-file-if-newer "~/.emacs")
(load-file "~/.emacs")
(leave-load t))
Then, the ~/.emacs.elc will always be populated, and processed. To me,
this is almost the _perfect_ version for auto byte-compile and loading
for ~/.emacs. :-)
And this language feature IMO, is useful for people who want to
control the library loading process.
If you have any questions, don't hesitate, I've been thinking on how
to make ~/.emacs auto re-compiling procedure perfect for 3 days.
Thanks for reading. ;-)
Severity set to `wishlist' from `normal'
Request was from
Glenn Morris <rgm <at> gnu.org>
to
control <at> emacsbugs.donarmstrong.com
.
(Tue, 09 Sep 2008 18:55:05 GMT)
Full text and
rfc822 format available.
Tags added: notabug
Request was from
Glenn Morris <rgm <at> gnu.org>
to
control <at> emacsbugs.donarmstrong.com
.
(Tue, 09 Sep 2008 18:55:05 GMT)
Full text and
rfc822 format available.
Information forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#940
; Package
emacs
.
Full text and
rfc822 format available.
Acknowledgement sent to
"Lennart Borgman (gmail)" <lennart.borgman <at> gmail.com>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
Full text and
rfc822 format available.
Message #39 received at 940 <at> emacsbugs.donarmstrong.com (full text, mbox):
Yiyi Hu wrote:
> Why not use 'unless' statement version?
> (unless (byte-compile-file-if-newer "~/.emacs")
> remaining lisp code ...)
> Because, This will confuse M-x customize-* series functions.
Just set custom-file to store customizations in another file.
> Why not splitting ~/.emacs?
> I did this, and It's not a happy journey. Eg, when change something, I
> have to think wether I should put here or there, or within ~/.emacs.
Not if you just put everything there.
But the main question is: Why do you want to compile absolutely
everything? I feel there must be some misunderstanding somewhere. How
much time to you win?
How many times do you start Emacs? I think most users just start Emacs
one they boot their computer.
Information forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#940
; Package
emacs
.
Full text and
rfc822 format available.
Acknowledgement sent to
"Yiyi Hu" <yiyihu <at> gmail.com>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
Full text and
rfc822 format available.
Message #44 received at 940 <at> emacsbugs.donarmstrong.com (full text, mbox):
The reason I request this feature is just trying to make elisp and
emacs more flexible.
With this or without this feature won't hurt emacs' perfections in my mind.
What I want is, if we can make best get better.
Compile ~/.emacs won't take much time, even I do byte-compile-file
within emacs, and bind it to a key doesn't spend much. It doesn't hurt
either when press this key every time I want to compile ~/.emacs. But
this is not the perfect sollution, The perfect sollution should be,
let computer do what we want.
You still have to specify custom-file within ~/.emacs and split
~/.emacs, don't you?
For ~/.emacs, I ever have really big ~/.emacs.d, because of copying
every interesting into ~/.emacs.d, and load it within ~/.emacs, As
time goes, It grew beyond my control, I can find what I want to change
easily. So, I choose to use only one ~/.emacs for better
maintainablity, and let ~/.emacs to compile itself on demand.
You didn't misunderstand anything, You just don't understand why
people sometimes will like to stick in polar direction. :-)
On Wed, Sep 10, 2008 at 6:10 AM, Lennart Borgman (gmail)
<lennart.borgman <at> gmail.com> wrote:
> Yiyi Hu wrote:
>> Why not use 'unless' statement version?
>> (unless (byte-compile-file-if-newer "~/.emacs")
>> remaining lisp code ...)
>> Because, This will confuse M-x customize-* series functions.
>
> Just set custom-file to store customizations in another file.
>
>> Why not splitting ~/.emacs?
>> I did this, and It's not a happy journey. Eg, when change something, I
>> have to think wether I should put here or there, or within ~/.emacs.
>
> Not if you just put everything there.
>
> But the main question is: Why do you want to compile absolutely
> everything? I feel there must be some misunderstanding somewhere. How
> much time to you win?
>
> How many times do you start Emacs? I think most users just start Emacs
> one they boot their computer.
>
Information forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#940
; Package
emacs
.
Full text and
rfc822 format available.
Acknowledgement sent to
"Yiyi Hu" <yiyihu <at> gmail.com>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
Full text and
rfc822 format available.
Message #49 received at 940 <at> emacsbugs.donarmstrong.com (full text, mbox):
Oh, sorry, I followed emacswiki and it says using M-x report-emacs-bug
<RET> is enough.
I'll write there.
thanks.
On Wed, Sep 10, 2008 at 2:42 PM, Nick Roberts <nickrob <at> snap.net.nz> wrote:
> Yiyi Hu writes:
> > This is not a bug, Just a feature request for elisp language.
> > Ok, thanks for your replies, I'll explain this is *great* detail.
>
> In that case could you use help-gnu-emacs instead of making a bug report
> which creates an unnecaessary audit trail.
>
> --
> Nick http://www.inet.net.nz/~nickrob
>
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#940
; Package
emacs
.
(Tue, 04 Oct 2011 19:33:02 GMT)
Full text and
rfc822 format available.
Message #52 received at 940 <at> debbugs.gnu.org (full text, mbox):
tags 940 wontfix
close 940
stop
"Yiyi Hu" wrote:
> Is there a way to quit the loading after we compile the ~/.emacs and
> load the ~/.emacs.elc file?
I understand what you are asking for (it's not just "load ~/.emacs.elc
if newer", which is bug#2577), but I don't see a need for such a
feature.
Added tag(s) wontfix.
Request was from
Glenn Morris <rgm <at> gnu.org>
to
control <at> debbugs.gnu.org
.
(Tue, 04 Oct 2011 19:33:02 GMT)
Full text and
rfc822 format available.
bug closed, send any further explanations to
940 <at> debbugs.gnu.org and "Yiyi Hu" <yiyihu <at> gmail.com>
Request was from
Glenn Morris <rgm <at> gnu.org>
to
control <at> debbugs.gnu.org
.
(Tue, 04 Oct 2011 19:33:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 02 Nov 2011 11:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 13 years and 230 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.