How can I open a file upon starting spacemacs (emacs)?

783 Views Asked by At

I want to open a few (or at least one) .org file(s) upon starting spacemacs and I can not achieve this. I suspect it would be the same lisp code for spacemacs and emacs.

Thus far I found this little snippet (find-file "~/todo.org") from this blog post

but it doesn't work when I put it down in the end of my .spacemacs file. I'm not sure if I should put it in init.el file because I think part of spacemacs philosophy is to just add everything to the .spacemacs file to make it easy.

2

There are 2 best solutions below

0
Drew On

Are you sure there is no buffer for that file, perhaps not displayed? (From your comment the answer to this is that the buffer is present but not displayed.)

Try with an init file that has only that find-file expression. If that works (displays the file buffer) then ensure that you put that expression last in your init file.

If that simple change (putting the sexp last) doesn't (also) work then bisect your init file to find out what other code there is interfering.

0
nonDucor On

You should add (find-file "your-file") inside the function dotspacemacs/user-config. Try adding it as the last line in the function (I tested it here and it worked).

To find the "correct" init.el file use the command SPC f e d (or M-x spacemacs/find-dotfile).