Skip to content

Commit

Permalink
change(winny/find-current-buffer-as-root): replace with sudo-edit
Browse files Browse the repository at this point in the history
  • Loading branch information
winny- committed Dec 22, 2024
1 parent 783b0dd commit e4604f4
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions configuration.org
Original file line number Diff line number Diff line change
Expand Up @@ -830,16 +830,10 @@ Suppress =Save auth info to file ~/.authinfo? [y/n/N/e/?]=. See [[info:tramp#Pa
#+end_src
** Find the current buffer as root via TRAMP
#+BEGIN_SRC emacs-lisp
(defun winny/find-current-buffer-as-root ()
"Find the current buffer as root using TRAMP sudo."
(interactive)
(when (file-remote-p default-directory)
(error "Already a TRAMP buffer. Giving up"))
(let ((path (expand-file-name
(if (eq major-mode 'dired-mode)
default-directory ; Dired does not use buffer-file-name to represent a path
buffer-file-name))))
(find-alternate-file (concat "/sudo:root@localhost:" path))))
(use-package sudo-edit
:ensure t
:init
(defalias 'winny/find-current-buffer-as-root #'sudo-edit))
#+END_SRC

* Hex editing
Expand Down

0 comments on commit e4604f4

Please sign in to comment.