2011-08-16 209 views
17

我有一個TODO文件,我可以在90%的時間內加載emacs。當我加載emacs雖然它默認加載臨時緩衝區。我希望它最初加載TODO文件。我對Emacs非常陌生,並且嘗試過使用.emacs文件搜索方法,但目前爲止沒有任何工作。如何將文件加載到緩衝區並在Emacs啓動時切換到緩衝區

這裏是我的嘗試:

1:使用查找文件獲取文件,並切換到緩衝器將其加載到屏幕

(switch-to-buffer (find-file "c:/Users/Seb/Documents/Emacs/TODO_List.org")) 

2:使用彈出到緩衝器加載該文件,而不是

(pop-to-buffer (find-file "c:/Users/Seb/Documents/Emacs/TODO_List.org")) 

3:所以它加載下一次保存在桌面

(desktop-save-mode 1) 

這些都不起作用。

這是我完整的.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. 
; '(inhibit-startup-buffer-menu t) 
'(inhibit-startup-screen t) 
'(initial-buffer-choice t)) 
(custom-set-faces 
    ;; custom-set-faces 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. 
) 

;; Set the current directory to the Emacs Documents dir 
(cd "C:/Users/Seb/Documents/Emacs") 

;; Open TODO list on start up 
(pop-to-buffer (find-file "c:/Users/Seb/Documents/Emacs/TODO_List.org")) 

;; Turn off the annoying tool bar at startup - to turn back on 
;; just type M-x tool-bar-mode 
(tool-bar-mode -1) 

;; Move the mouse when cursor is near 
(mouse-avoidance-mode 'cat-and-mouse) 

;; This enables saving the current desktop on shutdown. 
(desktop-save-mode 1) 

;; XML Pretty Print 
(defun xml-pretty-print (begin end) 
    "Pretty format XML markup in region. You need to have nxml-mode 
http://www.emacswiki.org/cgi-bin/wiki/NxmlMode installed to do 
this. The function inserts linebreaks to separate tags that have 
nothing but whitespace between them. It then indents the markup 
by using nxml's indentation rules." 
    (interactive "r") 
    (save-excursion 
     (nxml-mode) 
     (goto-char begin) 
     (while (search-forward-regexp "\>[ \\t]*\<" nil t) 
     (backward-char) (insert "\n")) 
     (indent-region begin end)) 
    (message "Ah, much better!")) 
+0

[+1]非常好的問題,它沒有得到應有的重視。歡呼聲 – rath

回答

22

在你的啓動文件,你有這樣一行:

'(initial-buffer-choice t)) 

爲你的「自定義設置變量」命令的一部分。 「initial-buffer-choice」的文檔字符串爲:

啓動Emacs後顯示的緩衝區。如果值爲零並且 inhibit-startup-screen' is nil, show the startup screen. If the value is string, visit the specified file or directory using find-file'。如果t,打開'暫存'緩衝區。

因此,在啓動後顯示您所指定的(「T」)是導致*scratch*緩衝值。將此行更改爲以下內容即可解決問題:

'(initial-buffer-choice "c:/Users/Seb/Documents/Emacs/TODO_List.org")) 
+2

謝謝Zev。這很有用。我現在看了一下文檔,意識到有一些我不知道的初始命令。對於任何感興趣的文檔可以在這裏找到:[鏈接](http://www.gnu.org/s/emacs/manual/html_node/elisp/Startup-Summary.html) – BebopSong

+3

如何啓動Emacs並讓它打開兩個窗口每個都打開一個不同的文件? – qazwsx

+0

感謝您的文檔! @BebopSong – cyc115

相關問題