2011-08-16 180 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

相关问题