gpt4 book ai didi

emacs - 如何在 Emacs 中将文件加载到缓冲区并在启动时切换到缓冲区

转载 作者:行者123 更新时间:2023-12-03 12:14:15 26 4
gpt4 key购买 nike

我有一个 TODO 文件,我加载 emacs 以使用 90% 的时间。当我加载 emacs 时,它默认加载暂存缓冲区。我希望它最初加载 TODO 文件。我对 Emacs 很陌生,并尝试过使用 .emacs 文件来寻找方法,但到目前为止没有任何效果。

这是我的尝试:

1:使用 find-file 获取文件并 switch-to-buffer 将其加载到屏幕

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

2:改为使用pop-to-buffer加载文件
(pop-to-buffer (find-file "c:/Users/Seb/Documents/Emacs/TODO_List.org"))

3:保存桌面以便下次加载
(desktop-save-mode 1)

这些都不起作用。

这是我的完整 .emacs 文件,您可以看到它几乎没有使用!
(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!"))

最佳答案

在您的启动文件中,您有以下行:

'(initial-buffer-choice t))

作为“自定义设置变量”命令的一部分。 “initial-buffer-choice”的文档字符串是:

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.



因此,您指定的值 ('t') 导致了 *scratch*启动后要显示的缓冲区。将此行更改为以下内容,您的问题应该得到解决:
'(initial-buffer-choice "c:/Users/Seb/Documents/Emacs/TODO_List.org"))

关于emacs - 如何在 Emacs 中将文件加载到缓冲区并在启动时切换到缓冲区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7083181/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com