unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Andreas Politz <politza@fh-trier.de>
To: help-gnu-emacs@gnu.org
Subject: Re: Auto-Prompt for Password and Raise Privilegies when needed
Date: Mon, 03 May 2010 23:10:28 +0200	[thread overview]
Message-ID: <87bpcwsncr.fsf@fh-trier.de> (raw)
In-Reply-To: 146fc610-6a5e-4607-b61d-248c926f1d67@b7g2000yqk.googlegroups.com

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


  reply	other threads:[~2010-05-03 21:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-03 16:50 Auto-Prompt for Password and Raise Privilegies when needed Nordlöw
2010-05-03 21:10 ` Andreas Politz [this message]
2010-05-04 14:00   ` quodlibetor
2010-05-04 14:17     ` Andreas Politz
2010-05-04 20:11       ` Andreas Politz
2010-05-04 14:56     ` Nordlöw
2010-05-05  4:14     ` Stefan Monnier
2010-05-05 20:25       ` Nordlöw

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=87bpcwsncr.fsf@fh-trier.de \
    --to=politza@fh-trier.de \
    --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).