2011-08-16 20 views
17

Tengo un archivo TODO que cargo emacs para usar el 90% del tiempo. Cuando cargo emacs, se carga por defecto el buffer de scratch. Me gustaría cargar el archivo TODO inicialmente. Soy muy nuevo en Emacs y he tratado de buscar formas de hacerlo utilizando el archivo .emacs pero nada ha funcionado hasta ahora.Cómo cargar archivos en el búfer y cambiar al búfer en el inicio en Emacs

Éstos son mis intentos:

1: Uso encontrar en archivos para obtener el archivo y cambiar-to-buffer para cargarlo a la pantalla

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

2: Uso de pop-to-buffer para cargar el archivo en lugar

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

3: Guardar el escritorio para que se cargue la próxima vez

(desktop-save-mode 1) 

Ninguno de estos están funcionando.

Aquí está mi archivo .emacs completo, ¡como pueden ver, apenas se usa!

(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] Muy buena pregunta que no ha recibido la atención que merece. Saludos – rath

Respuesta

22

En el archivo de inicio, tiene esta línea:

'(initial-buffer-choice t)) 

como parte de su comando "-variables personalizadas-set". La cadena de documentación para "initial-buffer-choice" es:

Buffer para mostrar después de iniciar Emacs. Si el valor es nulo y inhibit-startup-screen' is nil, show the startup screen. If the value is string, visit the specified file or directory using find-file '. Si t, abra el búfer `scratch '.

Por lo tanto, el valor que ha especificado ('t') está causando que el buffer *scratch* se muestre después del inicio. Cambie esta línea a lo siguiente y su problema debería resolverse:

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

Gracias Zev. Eso funcionó un placer. He echado un vistazo a la documentación ahora y me doy cuenta de que hay algunos de los comandos iniciales que no sabía. Para cualquier persona interesada, la documentación se puede encontrar aquí: [enlace] (http://www.gnu.org/s/emacs/manual/html_node/elisp/Startup-Summary.html) – BebopSong

+3

Cómo iniciar Emacs y abrirlo dos ventanas, cada una de las cuales abre un archivo diferente? – qazwsx

+0

¡Gracias por el documento! @BebopSong – cyc115

Cuestiones relacionadas