简体   繁体   English

如何在启动 spacemacs (emacs) 时打开文件?

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

I want to open a few (or at least one) .org file(s) upon starting spacemacs and I can not achieve this.我想在启动 spacemacs 时打开一些(或至少一个).org 文件,但我无法做到这一点。 I suspect it would be the same lisp code for spacemacs and emacs.我怀疑 spacemacs 和 emacs 的 lisp 代码是一样的。

Thus far I found this little snippet (find-file "~/todo.org") from this blog post到目前为止,我从这篇博文中找到了这个小片段(find-file "~/todo.org")

but it doesn't work when I put it down in the end of my .spacemacs file.但是当我把它放在我的 .spacemacs 文件的末尾时它不起作用。 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.我不确定是否应该将它放在 init.el 文件中,因为我认为 spacemacs 理念的一部分是将所有内容添加到 .spacemacs 文件中以使其变得容易。

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.尝试使用只有find-file表达式的 init 文件。 If that works (displays the file buffer) then ensure that you put that expression last in your init file.如果可行(显示文件缓冲区),请确保将该表达式放在 init 文件的最后。

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.如果这个简单的更改(将 sexp 放在最后)不起作用(也),那么将您的 init 文件一分为二以找出有哪些其他代码干扰。

You should add (find-file "your-file") inside the function dotspacemacs/user-config .您应该在函数dotspacemacs/user-config添加(find-file "your-file") 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 fed (or Mx spacemacs/find-dotfile ).要找到“正确”的init.el文件,请使用SPC fed命令(或Mx spacemacs/find-dotfile )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM