类似find-file ,下面能列出emacs打开过的文件目录吗
consult-recent-file
2 个赞
贴一段自己的配置,在 dired 调用会列出最近打开过的目录,在文件调用会列出打开过的文件(剔除掉目录),用 consult 做选择(为了图标好看,可以换成普通的 completing-read)
(defun my-open-recent ()
"Open recent directory in Dired or file otherwise."
(interactive)
(unless recentf-mode (recentf-mode 1))
(let* ((candidates (if (derived-mode-p 'dired-mode)
(delete-dups
(append (mapcar 'file-name-directory recentf-list)))
(mapcar #'abbreviate-file-name
(-filter (lambda (filename) (not (file-directory-p filename)))
recentf-list)))))
(find-file
(consult--read
candidates
:prompt "Find recent file: "
:sort nil
:require-match t
:category 'file
:state (consult--file-preview)
:history 'file-name-history
))))
如果是为了工程目录,可以去看看 project/projectile. project-switch-project
1 个赞
emacs 28 的 project-switch-project, project-find-file 就可以呀
1 个赞
如果你使用 consult ,可以试试这个 GitHub - karthink/consult-dir: Insert paths into the minibuffer prompt in Emacs
1 个赞