2014-04-16 24 views
3

我在windows上,根據thisstartup.el用於emacs的啓動。但是當我在這個文件中設置代碼時(在我的情況下爲C:\Users\frountch\Progs\emacs24\share\emacs\24.3.50\lisp\startup.el,刪除.elc文件後),它不會被執行。startup.el真的用了嗎?

比如我改變defun normal-top-level來自:

(defun normal-top-level() 
    "Emacs calls this function when it first starts up. 
It sets `command-line-processed', processes the command-line, 
reads the initialization files, etc. 
It is the default value of the variable `top-level'." 

    (if command-line-processed 
     (message "Back to top level.") 

(devar myload (load-path)) 
(devar myload2 nil) 
(defun normal-top-level() 
    "fuuuuuuu" 
    (setq myload2 (load-path)) 
    (if command-line-processed 
     (message "Back to top level.") 

之後,沒有定義myloadmyload2

更糟的是,如果我刪除startup.elstartup.elc,emacs仍然可以啓動!

startup.el真的使用?我如何檢查?

如果我定義

(defun normal-top-level() 
"fuuuuu" 
    (message "fuuu" 
) 
) 
startup.el

startup.elc還是刪除),當我C-h f,幫助窗口仍顯示

正常頂層是`啓動編譯Lisp函數.el」。

(正常頂級)

當它第一次啓動Emacs的調用這個函數。它設置爲 command-line-processed', processes the command-line, reads the initialization files, etc. It is the default value of the variable 頂層'。

但是當我點擊'startup.el'.它打開我的defun(與fuuu)!?

這是一個特定於Win $的問題嗎?是二進制內真正的啓動?

版本是24.3.50.1

回答

3

startup.el在標準的Emacs二進制不被使用。請注意,Startup Summary不建議這樣做。它沒有說源庫startup.el實際上是在啓動過程中加載的。它只是聲明在啓動時調用了在startup.el中定義的函數。

startup.el是在編譯過程中「轉儲」到Emacs二進制文件中的重要核心庫之一,可縮短啓動時間並提高性能。因此,編譯後的Emacs二進制文件不會加載源庫startup.el,而是從Emacs二進制文件的數據部分讀取其編譯的字節碼。

然而,startup.el中的代碼是Emacs二進制文件的一部分,並且在啓動時進行了評估。儘管您無法通過在預編譯的Emacs發行版中修改startup.el來直接檢查此問題,但您可以通過閱讀Emacs的源代碼或通過修補源代碼爲startup.el的源代碼構建Emacs來輕鬆進行驗證。

這不是特定於Windows。在這方面,Emacs在所有支持的操作系統上表現相同。請注意0​​不打算由用戶修改。使用~/.emacs.d/init.el來配置和定製您的Emacs。

+0

謝謝,我很放心。但是你所說的是,在「normal-top-level-add-to-load-path」做任何事情之前,沒有辦法改變'normal-top-level'或者print'load-path',除了「duping」 /重建Emacs?真是太遺憾了...... – frountch

+0

@frountch你爲什麼要改變'正常頂級'?你可以在那個函數中做什麼,你不能在'init.el'中做什麼? – lunaryorn