* file-precious-flag not taken seriously enough?
@ 2008-11-13 6:26 Karl Fogel
2008-11-13 15:26 ` Chong Yidong
0 siblings, 1 reply; 5+ messages in thread
From: Karl Fogel @ 2008-11-13 6:26 UTC (permalink / raw)
To: emacs-devel
In lisp/files.el:(basic-save-buffer-2), we have this code:
(let ((dir (file-name-directory buffer-file-name)))
(if (and file-precious-flag
(file-writable-p dir))
;; If file is precious, write temp name, then rename it.
;; This requires write access to the containing dir,
;; which is why we don't try it if we don't have that access.
(let ((realname buffer-file-name)
tempname succeed
(umask (default-file-modes))
(old-modtime (visited-file-modtime)))
[...continue on to write directly to the file...]
The documentation for `file-precious-flag' doesn't say anything about
it only applying if the containing directory is writeable. But that
seems to be how we treat it, in the conditional above.
Is this just a bug?
(Larger context: I'm implementing the `break-hardlinks-on-save' flag
as discussed in another thread, so am looking at where
`file-precious-flag' is used.)
-Karl
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: file-precious-flag not taken seriously enough?
2008-11-13 6:26 file-precious-flag not taken seriously enough? Karl Fogel
@ 2008-11-13 15:26 ` Chong Yidong
2008-11-14 14:43 ` Kevin Rodgers
0 siblings, 1 reply; 5+ messages in thread
From: Chong Yidong @ 2008-11-13 15:26 UTC (permalink / raw)
To: Karl Fogel; +Cc: emacs-devel
Karl Fogel <kfogel@red-bean.com> writes:
> (let ((dir (file-name-directory buffer-file-name)))
> (if (and file-precious-flag
> (file-writable-p dir))
> ;; If file is precious, write temp name, then rename it.
> ;; This requires write access to the containing dir,
> ;; which is why we don't try it if we don't have that access.
> (let ((realname buffer-file-name)
> tempname succeed
> (umask (default-file-modes))
> (old-modtime (visited-file-modtime)))
> [...continue on to write directly to the file...]
>
> The documentation for `file-precious-flag' doesn't say anything about
> it only applying if the containing directory is writeable. But that
> seems to be how we treat it, in the conditional above.
>
> Is this just a bug?
If the directory is not writable, there is no way to obey
file-precious-flag. That means that the only alternative is to signal
an error. Off the top of my head, I think it's better to fall back on
the usual file saving method instead, because that's almost always what
the user would want.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: file-precious-flag not taken seriously enough?
2008-11-13 15:26 ` Chong Yidong
@ 2008-11-14 14:43 ` Kevin Rodgers
2008-11-14 23:18 ` Karl Fogel
0 siblings, 1 reply; 5+ messages in thread
From: Kevin Rodgers @ 2008-11-14 14:43 UTC (permalink / raw)
To: emacs-devel
Chong Yidong wrote:
> Karl Fogel <kfogel@red-bean.com> writes:
>
>> (let ((dir (file-name-directory buffer-file-name)))
>> (if (and file-precious-flag
>> (file-writable-p dir))
>> ;; If file is precious, write temp name, then rename it.
>> ;; This requires write access to the containing dir,
>> ;; which is why we don't try it if we don't have that access.
>> (let ((realname buffer-file-name)
>> tempname succeed
>> (umask (default-file-modes))
>> (old-modtime (visited-file-modtime)))
>> [...continue on to write directly to the file...]
>>
>> The documentation for `file-precious-flag' doesn't say anything about
>> it only applying if the containing directory is writeable. But that
>> seems to be how we treat it, in the conditional above.
>>
>> Is this just a bug?
>
> If the directory is not writable, there is no way to obey
> file-precious-flag. That means that the only alternative is to signal
> an error. Off the top of my head, I think it's better to fall back on
> the usual file saving method instead, because that's almost always what
> the user would want.
In case the usual file saving method results in a problem (which
file-precious-flag was set to prevent), shouldn't there be a warning
message here to inform the user? Not to distract him/her, but so that
they can find a clue in the *Messages* buffer after something has gone
wrong.
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: file-precious-flag not taken seriously enough?
2008-11-14 14:43 ` Kevin Rodgers
@ 2008-11-14 23:18 ` Karl Fogel
2008-11-15 14:55 ` Stefan Monnier
0 siblings, 1 reply; 5+ messages in thread
From: Karl Fogel @ 2008-11-14 23:18 UTC (permalink / raw)
To: Kevin Rodgers; +Cc: emacs-devel
Kevin Rodgers <kevin.d.rodgers@gmail.com> writes:
> In case the usual file saving method results in a problem (which
> file-precious-flag was set to prevent), shouldn't there be a warning
> message here to inform the user? Not to distract him/her, but so that
> they can find a clue in the *Messages* buffer after something has gone
> wrong.
Or another option: at least flash a message that file-precious-flag is
going to be ignored, when that's the case.
However, for now I'm just going to change the file-precious-flag
documentation to indicate that it is advisory. This was all just stuff
I found on the way to making another change, which I'd still like to
make :-).
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: file-precious-flag not taken seriously enough?
2008-11-14 23:18 ` Karl Fogel
@ 2008-11-15 14:55 ` Stefan Monnier
0 siblings, 0 replies; 5+ messages in thread
From: Stefan Monnier @ 2008-11-15 14:55 UTC (permalink / raw)
To: Karl Fogel; +Cc: Kevin Rodgers, emacs-devel
>> In case the usual file saving method results in a problem (which
>> file-precious-flag was set to prevent), shouldn't there be a warning
>> message here to inform the user? Not to distract him/her, but so that
>> they can find a clue in the *Messages* buffer after something has gone
>> wrong.
> Or another option: at least flash a message that file-precious-flag is
> going to be ignored, when that's the case.
Yes, a message like "Dir read-only: ignoring file-precious-flag" sounds like
a good idea.
Stefan
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-11-15 14:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-13 6:26 file-precious-flag not taken seriously enough? Karl Fogel
2008-11-13 15:26 ` Chong Yidong
2008-11-14 14:43 ` Kevin Rodgers
2008-11-14 23:18 ` Karl Fogel
2008-11-15 14:55 ` Stefan Monnier
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.