[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to change and save a read-only file?
From: |
Thorsten Jolitz |
Subject: |
Re: How to change and save a read-only file? |
Date: |
Sat, 29 Jun 2013 13:04:19 +0200 |
User-agent: |
Gnus/5.130002 (Ma Gnus v0.2) Emacs/24.3 (gnu/linux) |
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)
emacs-ESU-script.el
Description: Script for Emacs as root
--
cheers,
Thorsten