tag:blogger.com,1999:blog-3992530807750384868.post5611080369015051953..comments2022-03-28T08:42:20.497+03:00Comments on emacs-fu: editing with root-privileges -- once moreUnknownnoreply@blogger.comBlogger9125tag:blogger.com,1999:blog-3992530807750384868.post-24912368718188428982013-03-25T22:25:23.412+02:002013-03-25T22:25:23.412+02:00I use "sudoedit". As David pointed out ...I use "sudoedit". As David pointed out in a previous comment, if your $VISUAL and $EDITOR are set to emacsclient -t and -c respectively, it works beautifully. Vichonoreply@blogger.comtag:blogger.com,1999:blog-3992530807750384868.post-6643126312470264412013-03-20T13:02:55.929+02:002013-03-20T13:02:55.929+02:00Thanks Anonymous of "a little bit complicated...Thanks Anonymous of "a little bit complicated stuff". Great idea. I've copied it over to .emacs.C. Baxterhttp://www.colin-baxter.com/noreply@blogger.comtag:blogger.com,1999:blog-3992530807750384868.post-17268365907579538982013-03-18T20:58:06.656+02:002013-03-18T20:58:06.656+02:00Even if you're on a terminal there's no re...Even if you're on a terminal there's no reason to use vi. I use a simple alias<br /><br /> alias E='sudo -e'<br /><br />Of course your $EDITOR variable has to be pointing to emacslient, but I'm sure it is already...<br />Davidhttps://www.blogger.com/profile/06187169068996230184noreply@blogger.comtag:blogger.com,1999:blog-3992530807750384868.post-56780001215141389772013-03-18T16:43:34.882+02:002013-03-18T16:43:34.882+02:00I run into the same problem all the time and end u...I run into the same problem all the time and end up reverting to vi. Using your idea I came up with this which I will try to stick to using.<br /><br />(defun stw-find-file-as-root ()<br /> (interactive)<br /> (find-file (concat "/sudo::" (buffer-file-name))))<br /><br />Thanks for the idea!Steve Walkerhttp://stephenwalker.comnoreply@blogger.comtag:blogger.com,1999:blog-3992530807750384868.post-58836835655768227212013-03-18T12:42:26.250+02:002013-03-18T12:42:26.250+02:00This comment has been removed by the author.ArneBabhttps://www.blogger.com/profile/16449390422848764481noreply@blogger.comtag:blogger.com,1999:blog-3992530807750384868.post-47104389313196556942013-03-18T12:42:11.617+02:002013-03-18T12:42:11.617+02:00I have the same reflex, though with nano instead o...I have the same reflex, though with nano instead of vi.<br /><br />Let’s see if your code helps me overcome it. Thanks a lot!ArneBabhttps://www.blogger.com/profile/16449390422848764481noreply@blogger.comtag:blogger.com,1999:blog-3992530807750384868.post-52322877110208916792013-03-18T03:39:36.917+02:002013-03-18T03:39:36.917+02:00Awesome; thanks!Awesome; thanks!jrmhttps://www.blogger.com/profile/04031473903180491281noreply@blogger.comtag:blogger.com,1999:blog-3992530807750384868.post-76961101302442337022013-03-18T03:39:13.124+02:002013-03-18T03:39:13.124+02:00This comment has been removed by the author.jrmhttps://www.blogger.com/profile/04031473903180491281noreply@blogger.comtag:blogger.com,1999:blog-3992530807750384868.post-54277276400548627612013-03-17T20:41:16.003+02:002013-03-17T20:41:16.003+02:00i use a little bit complicated stuff:
(defcustom...i use a little bit complicated stuff:<br /><br /><br />(defcustom find-file-root-prefix "/sudo::"<br /> "Tramp root prefix to use.")<br /><br /><br />(defadvice find-file-noselect <br /> (before add-root-prefix (filename &optional nowarn rawfile wildcards))<br /> "Add tramp prefix to filename"<br /> (and (bound-and-true-p root-prefix)<br /> (yes-or-no-p "Use root privileges? ")<br /> (setq filename (concat root-prefix filename))))<br /><br />(ad-activate 'find-file-noselect)<br /><br />(defun find-file-as-root ()<br /> "Find file using root privileges"<br /> (interactive)<br /> (let ((root-prefix find-file-root-prefix))<br /> (call-interactively (if ido-mode 'ido-find-file 'find-file))))<br /><br />(defun find-current-as-root ()<br /> "Reopen current file as root"<br /> (interactive)<br /> (set-visited-file-name (concat find-file-root-prefix (buffer-file-name)))<br /> (setq buffer-read-only nil))<br /><br />(global-set-key (kbd "M-s C-x C-f") 'find-file-as-root)<br />(global-set-key (kbd "M-s C-x C-v") 'find-current-as-root)<br /><br />// see <a rel="nofollow">https://github.com/a13/emacs.d/blob/master/lib/mine.el</a>Anonymousnoreply@blogger.com