help-gnu-emacs
[Top][All Lists]
Advanced

[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: Tue, 04 May 2010 16:17:03 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

quodlibetor <quodlibetor@gmail.com> writes:

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

What about view-mode-hook ?

-ap


reply via email to

[Prev in Thread] Current Thread [Next in Thread]