refactor(cli): doctor: extract symlink check to function

This commit is contained in:
Henrik Lissner
2025-04-10 22:45:46 -04:00
parent fb0dc4cc85
commit cbdce0dc71
2 changed files with 36 additions and 29 deletions

View File

@ -184,20 +184,7 @@ in."
(format " (setq-default vterm-shell \"%s\")\n" shell-file-name)
(format " (setq-default explicit-shell-file-name \"%s\")\n" shell-file-name)))
(condition-case e
(when (featurep :system 'windows)
(let ((filea (expand-file-name "__testfile1" temporary-file-directory))
(fileb (expand-file-name "__testfile2" temporary-file-directory)))
(unwind-protect
(progn
(with-temp-file fileb)
(make-symbolic-link fileb filea)
(not (file-symlink-p filea)))
(delete-file filea)
(delete-file fileb))))
('file-error
(when (equal (cons (nth 1 e) (nth 2 e))
(cons "Making symbolic link" "Operation not permitted"))
(unless (doom-system-supports-symlinks-p)
(print! (warn "Symlinks are not enabled on this operating system"))
(explain! "In the near future, Doom will make extensive use of symlinks to save space "
"and simplify package and profile management. Without symlinks, much of it "
@ -212,7 +199,7 @@ in."
" unless Emacs itself is launched in administrator mode.\n"
" - Install Emacs in WSL 1/2; the native Linux environment it creates supports "
" symlinks out of the box and is the best option (as Emacs is generally more "
" stable, predictable, and faster there).\n\n")))))
" stable, predictable, and faster there).\n\n")))
(print! (start "Checking for stale elc files..."))
(elc-check-dir doom-core-dir)

View File

@ -110,5 +110,25 @@ Tries to be portable. Returns 1 if cannot be determined."
(cdr cpus)))))
1))))))
;;;###autoload
(defun doom-system-supports-symlinks-p ()
"Return non-nil if this system supports symlinks"
(condition-case e
(let ((filea (expand-file-name "__doom_testfile1" temporary-file-directory))
(fileb (expand-file-name "__doom_testfile2" temporary-file-directory)))
(unwind-protect
(progn
(with-temp-file fileb)
(make-symbolic-link fileb filea)
(and (file-symlink-p filea)
(file-equal-p filea fileb)))
(delete-file filea)
(delete-file fileb)))
(file-error
(if (equal (cons (nth 1 e) (nth 2 e))
(cons "Making symbolic link" "Operation not permitted"))
nil
(signal (car e) (cdr e))))))
(provide 'doom-lib '(system))
;;; system.el ends here