summary refs log tree commit diff stats
path: root/config.org
diff options
context:
space:
mode:
authorCase Duckworth2021-01-07 19:42:11 -0600
committerCase Duckworth2021-01-07 19:42:11 -0600
commitf540f1097d5fc2e768253296188f51514347eb78 (patch)
tree9a14878299fe33505cba941f11979eac3ac237ac /config.org
parentUpdate README (diff)
downloademacs-f540f1097d5fc2e768253296188f51514347eb78.tar.gz
emacs-f540f1097d5fc2e768253296188f51514347eb78.zip
Add sudo-edit
Diffstat (limited to 'config.org')
-rw-r--r--config.org33
1 files changed, 33 insertions, 0 deletions
diff --git a/config.org b/config.org index 8452876..d0e1078 100644 --- a/config.org +++ b/config.org
@@ -945,6 +945,39 @@ from [[https://www.reddit.com/r/emacs/comments/km9by4/weekly_tipstricketc_thread
945(cuss require-final-newline t) 945(cuss require-final-newline t)
946#+END_SRC 946#+END_SRC
947 947
948*** Edit files with =sudo=
949
950 #+BEGIN_SRC emacs-lisp
951 (straight-use-package 'sudo-edit)
952
953 (with-eval-after-load 'sudo-edit
954 (global-set-key acdw/map (kbd "C-r") #'sudo-edit))
955 #+end_src
956
957**** Don’t add =/sudo:= files to =recentf=, though
958
959I’ve pretty much cribbed this from [[https://github.com/ncaq/recentf-remove-sudo-tramp-prefix/][recentf-remove-sudo-tramp-prefix]] – it’s a small enough package that I can just include it completely here.
960
961#+BEGIN_SRC emacs-lisp
962 (defun recentf-remove-sudo-tramp-prefix (path)
963 "Remove sudo from PATH."
964 (require 'tramp)
965 (if (tramp-tramp-file-p path)
966 (let ((tx (tramp-dissect-file-name path)))
967 (if (string-equal "sudo" (tramp-file-name-method tx))
968 (tramp-file-name-localname tx)
969 path))
970 path))
971
972 (defun recentf-remove-sudo-tramp-prefix-from-recentf-list ()
973 (require 'recentf)
974 (setq recentf-list
975 (mapcar #'recentf-remove-sudo-tramp-prefix recentf-list)))
976
977 (advice-add 'recentf-cleanup
978 :before #'recentf-remove-sudo-tramp-prefix-from-recentf-list)
979#+end_src
980
948** Text editing 981** Text editing
949 982
950*** Operate visually on lines 983*** Operate visually on lines