24
votes

I have a TODO file that I load emacs up to use 90% of the time. When I load emacs though it defaults to loading the scratch buffer. I would like it to load the TODO file initially. I'm very new to Emacs and have tried searching round for ways to do this using the .emacs file but nothing has worked so far.

Here are my attempts:

1: Use find-file to get the file and switch-to-buffer to load it to the screen

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

2: Use pop-to-buffer to load the file instead

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

3: Save the desktop so it loads the next time

(desktop-save-mode 1)

None of these are working.

Here is my full .emacs file, as you can see it's barely used!

(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!"))
1
[+1] Very nice question which hasn't received the attention it deserves. Cheersrath

1 Answers

27
votes

In your startup file, you have this line:

'(initial-buffer-choice t))

as part of your "custom-set-variables" command. The documentation string for "initial-buffer-choice" is:

Buffer to show after starting Emacs. If the value is nil and inhibit-startup-screen' is nil, show the startup screen. If the value is string, visit the specified file or directory using find-file'. If t, open the `scratch' buffer.

So, the value that you've specified ('t') is causing the *scratch* buffer to be displayed after startup. Change this line to the following and your issue should be resolved:

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