2011-08-16 9 views
17

Ho un file TODO che carico emacs per utilizzare il 90% delle volte. Quando carico emacs, per impostazione predefinita, carica il buffer scratch. Vorrei caricare inizialmente il file TODO. Sono molto nuovo a Emacs e ho provato a cercare modi per farlo usando il file .emacs ma nulla ha funzionato finora.Come caricare il file nel buffer e passare al buffer all'avvio in Emacs

Qui sono i miei tentativi:

1: utilizzare la funzione Trova file per ottenere il file e switch-to-buffer per caricarlo alla schermata

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

2: Utilizzare pop-to-tampone per caricare il file invece

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

3: Salvare il desktop in modo carica la prossima volta

(desktop-save-mode 1) 

Nessuno di questi funziona.

Ecco il mio file .emacs completo, come potete vedere è appena usato!

(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] Molto bella la domanda che non ha ricevuto l'attenzione che merita. Saluti – rath

risposta

22

Nel file di avvio, si dispone di questa linea:

'(initial-buffer-choice t)) 

come parte del vostro comando "-variabili personalizzate-set". La stringa di documentazione per "scelta del buffer iniziale" è:

Buffer da mostrare dopo l'avvio di Emacs. Se il valore è zero e inhibit-startup-screen' is nil, show the startup screen. If the value is string, visit the specified file or directory using find-file '. Se t, apri il buffer "scratch".

Quindi, il valore specificato ('t') causa la visualizzazione del buffer *scratch* dopo l'avvio. Modifica questa riga come segue e il problema deve essere risolto:

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

Grazie, Zev. Ha funzionato a meraviglia. Ho dato un'occhiata alla documentazione ora e mi rendo conto che ci sono alcuni dei comandi iniziali che non sapevo. Per chiunque sia interessato, la documentazione può essere trovata qui: [link] (http://www.gnu.org/s/emacs/manual/html_node/elisp/Startup-Summary.html) – BebopSong

+3

Come avviare Emacs e aprirlo due finestre ciascuna delle quali apre un file diverso? – qazwsx

+0

Grazie per il doc! @BebopSong – cyc115

Problemi correlati