Refactor doom--recentf-file-truename-fn

This commit is contained in:
Henrik Lissner 2021-05-09 00:20:52 -04:00
parent 62d2f27510
commit 7332a6f798

View file

@ -286,14 +286,10 @@ or file path may exist now."
recentf-max-saved-items 200) ; default is 20 recentf-max-saved-items 200) ; default is 20
(defun doom--recentf-file-truename-fn (file) (defun doom--recentf-file-truename-fn (file)
(if (file-remote-p file) (if (or (not (file-remote-p file))
(if-let* ((tfile (and (bound-and-true-p tramp-mode) (equal "sudo" (file-remote-p file 'method)))
(tramp-tramp-file-p file) (abbreviate-file-name (file-truename (tramp-file-name-localname tfile)))
(tramp-dissect-file-name file))) file))
((string= (tramp-file-name-method tfile) "sudo")))
(abbreviate-file-name (file-truename (tramp-file-name-localname tfile)))
file)
(abbreviate-file-name (file-truename file))))
;; Resolve symlinks, strip out the /sudo:X@ prefix in local tramp paths, and ;; Resolve symlinks, strip out the /sudo:X@ prefix in local tramp paths, and
;; abbreviate $HOME -> ~ in filepaths (more portable, more readable, & saves ;; abbreviate $HOME -> ~ in filepaths (more portable, more readable, & saves