[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Auto-Prompt for Password and Raise Privilegies when needed
From: |
Andreas Politz |
Subject: |
Re: Auto-Prompt for Password and Raise Privilegies when needed |
Date: |
Mon, 03 May 2010 23:10:28 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
Nordlöw <per.nordlow@gmail.com> writes:
>[...]
>
> Instead I really believe Emacs should use the Mac OS x way of thinking
> when opening and modifying files (using find-file and alikes) that are
> owned by other users.
>
> When we try to edit a file that is owned by another user but writable
> by the current user Emacs (through TRAMP) should ask for the password
> of the user owning the file and then reopen the file by adding TRAMP-
> sudo/su-prefix to the url.
>
> [...]
>
> The implement this we need a hook that is called every time the user
> tries to change the content of the file. How do define that function?
> I grepped for the string
>
> Buffer is read-only
>
> in the emacs cvs sources. This is printed each time we try to modify a
> buffer that is read-only. This is an internal string. Do we have to
> modify the builtins in this case? Or is there another way of solving
> this problem?
>
> Thanks in advance for any comments,
> Per Nordlöw
Sounds trivial. Though this may not scale well with other hooks.
(defun find-file-maybe-change-me ()
(when (not (file-writable-p buffer-file-name))
(find-alternate-file
(format "/sudo::%s" buffer-file-name))))
(add-hook 'find-file-hook 'find-file-maybe-change-me)
-ap