如何让emacs从初始目录自动加载和保存桌面?

pat*_*idd 6 emacs

我通常有3-4个不同的项目,我一次工作.因此,我试图弄清楚如何从我打开emacs的文件夹中获取emacs加载桌面,并在退出该emacs实例时保存到该文件.

我见过的所有文档都描述了如何让emacs自动打开并从默认位置保存(这使得多个桌面无法实现),或者手动加载桌面并将其保存到特定目录(我现在正在做).

谢谢!

art*_*can 6

把它放到你的.emacs:

(setq your-own-path default-directory)
(if (file-exists-p
     (concat your-own-path ".emacs.desktop"))
    (desktop-read your-own-path))

(add-hook 'kill-emacs-hook
      `(lambda ()
        (desktop-save ,your-own-path t)))
Run Code Online (Sandbox Code Playgroud)

更新:v.2,按需忽略.

(setq your-own-path default-directory)
(if (file-exists-p
     (concat your-own-path ".emacs.desktop"))
    (if (y-or-n-p "Read .emacs.desktop and add hook?")
    (progn
      (desktop-read your-own-path)
      (add-hook 'kill-emacs-hook
            `(lambda ()
               (desktop-save ,your-own-path t))))))
Run Code Online (Sandbox Code Playgroud)