From: Thorsten Jolitz <tjolitz@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: How to change and save a read-only file?
Date: Sat, 29 Jun 2013 13:04:19 +0200 [thread overview]
Message-ID: <874nchi3f0.fsf@gmail.com> (raw)
In-Reply-To: CAM3-KjbrVSvKkV6j4dXDTXFDUN-=77ahFGL9AGRkped+5dia0Q@mail.gmail.com
[-- Attachment #1: Type: text/plain, Size: 1923 bytes --]
Marius Hofert <marius.hofert@math.ethz.ch> writes:
Hi,
> What's the 'correct' approach to easily edit (change + save) such files?
not sure whats the 'correct' approach, but there is tramp which allows
you to do something like:
1. find-file as root
,---------------
| C-x C-f /sudo:
`---------------
and then asks for a password
,-----------------------------------
| Password for /sudo:root@localhost:
`-----------------------------------
to let you subsequently edit the file as root
2. or reopen dired buffer with sudo and thus open end edit files from
that buffer as root
,-------------------------------------------------------------------------------
| C-c C-s runs the command dired-toggle-sudo, which is an interactive autoloaded
| compiled Lisp function in `dired-toggle-sudo.el'.
|
| It is bound to C-c C-s.
|
| (dired-toggle-sudo &optional SUDO-USER)
|
| Reopen current file or dired buffer with sudo.
|
| If SUDO-USER is nil assume root.
|
| If called with `universal-argument' (C-u), ask for username.
`-------------------------------------------------------------------------------
But I finally ended up to write a separate minimal init.el file and a
small batch script that allow me to quickly open a root instance of
emacs when I need it that warns me about being root while editing that I
exit when I'm done with editing:
,---------------------------------------------
| -rwxr-xr-x 1 me users 125 26. Apr 09:44 esu
`---------------------------------------------
with content:
,------------------------------------------------------
| #!/bin/sh
| # start emacs as root
|
| exec sudo emacs -Q -bg black -fg wheat --no-splash -l
| /home/me/.emacs.d/emacs-ESU-script.el
`------------------------------------------------------
emacs-ESU-script.el:
(it starts up pretty fast, but makes editing convenient, and has a nice
red warning at the top of the buffer about editing as root)
[-- Attachment #2: Script for Emacs as root --]
[-- Type: application/emacs-lisp, Size: 5843 bytes --]
[-- Attachment #3: Type: text/plain, Size: 22 bytes --]
--
cheers,
Thorsten
next prev parent reply other threads:[~2013-06-29 11:04 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-29 9:14 How to change and save a read-only file? Marius Hofert
2013-06-29 9:20 ` Peter Dyballa
2013-06-29 11:04 ` Thorsten Jolitz [this message]
2013-06-29 11:16 ` Jude DaShiell
[not found] <mailman.2780.1372497288.22516.help-gnu-emacs@gnu.org>
2013-06-29 13:10 ` Emanuel Berg
2013-06-29 13:30 ` Emanuel Berg
2013-07-01 22:35 ` Richard Copley
[not found] ` <mailman.14.1372718151.12400.help-gnu-emacs@gnu.org>
2013-07-01 23:42 ` Emanuel Berg
2013-07-19 12:36 ` Emanuel Berg
-- strict thread matches above, loose matches on Subject: below --
2013-11-20 3:27 Emanuel Berg
2013-11-20 14:22 ` Kevin Rodgers
[not found] ` <mailman.6640.1384957268.10748.help-gnu-emacs@gnu.org>
2013-11-20 16:24 ` Emanuel Berg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=874nchi3f0.fsf@gmail.com \
--to=tjolitz@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).