2011-08-16 14 views
17

私はemacsをロードして90%の時間を使うTODOファイルを持っています。 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の起動後に表示されるバッファです。値がnilで、 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

ありがとうございました。それは治療に効果があった。私は今ドキュメンテーションを見て、私が知らなかった最初のコマンドのいくつかがあることを認識しています。関心のある人のために、ドキュメントはここにあります:[リンク](http://www.gnu.org/s/emacs/manual/html_node/elisp/Startup-Summary.html) – BebopSong

+3

Emacsを起動してオープンにする方法それぞれ異なるファイルを開く2つのウィンドウ? – qazwsx

+0

ドキュメントありがとう! @BebopSong – cyc115

関連する問題