mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-01 12:17:25 -05:00
refactor(cli): doctor: extract symlink check to function
This commit is contained in:
@ -184,20 +184,7 @@ in."
|
|||||||
(format " (setq-default vterm-shell \"%s\")\n" shell-file-name)
|
(format " (setq-default vterm-shell \"%s\")\n" shell-file-name)
|
||||||
(format " (setq-default explicit-shell-file-name \"%s\")\n" shell-file-name)))
|
(format " (setq-default explicit-shell-file-name \"%s\")\n" shell-file-name)))
|
||||||
|
|
||||||
(condition-case e
|
(unless (doom-system-supports-symlinks-p)
|
||||||
(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"))
|
|
||||||
(print! (warn "Symlinks are not enabled on this operating system"))
|
(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 "
|
(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 "
|
"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"
|
" unless Emacs itself is launched in administrator mode.\n"
|
||||||
" - Install Emacs in WSL 1/2; the native Linux environment it creates supports "
|
" - 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 "
|
" 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..."))
|
(print! (start "Checking for stale elc files..."))
|
||||||
(elc-check-dir doom-core-dir)
|
(elc-check-dir doom-core-dir)
|
||||||
|
@ -110,5 +110,25 @@ Tries to be portable. Returns 1 if cannot be determined."
|
|||||||
(cdr cpus)))))
|
(cdr cpus)))))
|
||||||
1))))))
|
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))
|
(provide 'doom-lib '(system))
|
||||||
;;; system.el ends here
|
;;; system.el ends here
|
||||||
|
Reference in New Issue
Block a user