all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: quodlibetor <quodlibetor@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Auto-Prompt for Password and Raise Privilegies when needed
Date: Tue, 4 May 2010 07:00:28 -0700 (PDT)	[thread overview]
Message-ID: <b0553e6b-7750-4669-b36d-15655fb58193@o1g2000vbe.googlegroups.com> (raw)
In-Reply-To: 87bpcwsncr.fsf@fh-trier.de

> 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)

I think what Per was looking for was more something along the lines of

(defun edit-read-only-file-maybe ()
  (when (y-or-n-p "file is read-only, raise privileges to edit? ")
    (find-alternate-file
     (format "/sudo::%s" buffer-file-name))))

(add-hook 'first-edit-read-only-file-hook 'edit-read-only-file-maybe)

with the main problem being that `first-edit-read-only-file-hook'
doesn't exist, and there don't seem to be any analogs. Or at least I
can't find them.


  reply	other threads:[~2010-05-04 14:00 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
2010-05-04 14:00   ` quodlibetor [this message]
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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b0553e6b-7750-4669-b36d-15655fb58193@o1g2000vbe.googlegroups.com \
    --to=quodlibetor@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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.