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: quodlibetor
Subject: Re: Auto-Prompt for Password and Raise Privilegies when needed
Date: Tue, 4 May 2010 07:00:28 -0700 (PDT)
User-agent: G2/1.0

> 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 via email to

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