rewrite find-file-sudo to fix opening some directories etc

This commit is contained in:
MitchMarq42 2023-03-11 19:53:05 -09:00
parent e338ec34af
commit 150c49903b

View File

@ -43,9 +43,10 @@
(expand-file-name "tramp-history" backup-directory))
:config
(defun find-file-sudo (&rest throwaway)
(unless (and buffer-file-name
(file-writable-p buffer-file-name))
(find-alternate-file (concat "/sudo:root@localhost:" buffer-file-name))))
(if buffer-file-name
(unless (or (file-writable-p buffer-file-name)
(file-directory-p buffer-file-name))
(find-alternate-file (format "/sudo::%s" buffer-file-name)))))
(advice-add #'find-file :after #'find-file-sudo))
;; Visualize whitespace. In a very chill and invisible way.
(use-package image-mode