Since my .emacs.d
is a symbolic link of ~/dotfile/dot/.emacs.d
, recentf
keeps duplicated thing like
/Users/user/.emacs.d/init/init-editor.el
/Users/user/dotfile/dot/.emacs.d/init/init-editor.el
because some command/functions the symbolic link path and some use the real one.
How to let recentf
not to remember real path when there's a symbolic link of a parent directory ? The real path is so long, I prefer the short one.
I used
(defvar recentf--exclude-remote-regexp "\\/\\w*?:\\w*?@\\w*?:\\/")
(defun recentf//file-symbolic-link-in-recentf-list (file)
"Test whether there's a symbolic parent of FILE in `recentf-list'."
(cl-some (lambda (x)
(and (string= (file-truename x) file)
(not (string= x file))))
recentf-list))
(defun recentf//exclude-symbolic-vc-files (file)
"Exclude local FILE that has a symbolic parent in `recentf-list'."
;; Unless the file is local
(unless (string-match recentf--exclude-remote-regexp file)
(recentf//file-symbolic-link-in-recentf-list file)))
(add-to-list 'recentf-exclude #'recentf//exclude-symbolic-vc-files)
before, but this is a bit slow which take almost 2 second to handle with a recentf-list
in length of 500
.
Also I find that there's recentf-filename-handlers
which may be used to combine with directory-abbrev-alist
. But this require manually add all the mappings.
Any suggestions will be appreciated! Thanks!