unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Emacs does not detect a buffered file got deleted
@ 2016-08-08  3:33 路客
  2016-08-08  8:02 ` Andreas Schwab
  0 siblings, 1 reply; 6+ messages in thread
From: 路客 @ 2016-08-08  3:33 UTC (permalink / raw)
  To: Emacs developers

[-- Attachment #1: Type: text/plain, Size: 1101 bytes --]

Hi all:

When editing a file in Emacs and switching git branches, sometimes
a file will be removed but Emacs won't detect it. Unlike modified
files it will ask me to revert, deleted files are not. Is it
intentional? After a while I found this behavior exists from the very
beginning trace back to 1991-01-14 RMS's original code in filelock.c,
function "lockfile":

{
  register Lisp_Object subject_buf = Fget_file_buffer (fn);
  if (!NULL (subject_buf)
      && NULL (Fverify_visited_file_modtime (subject_buf))
      && !NULL (Ffile_exists_p (fn))) /// <<<<<< HERE <<<<<<<<<
    call1 (intern ("ask-user-about-supersession-threat"), fn);
}

It then later changed by Jim Blandy on 1992-01-13 to change "NULL"
to "NILP":

  if (!NILP (subject_buf)
      && NILP (Fverify_visited_file_modtime (subject_buf))
      && !NILP (Ffile_exists_p (fn)))  /// <<<<<<< HERE <<<<<<<<<
    call1 (intern ("ask-user-about-supersession-threat"), fn);


Should we now consider remove the last condition
"&& !NILP (Ffile_exists_p (fn))"
to make Emacs able to detect file deletion?

Thanks.


-- 
Best regards,
Luke Lee

[-- Attachment #2: Type: text/html, Size: 1470 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Emacs does not detect a buffered file got deleted
  2016-08-08  3:33 Emacs does not detect a buffered file got deleted 路客
@ 2016-08-08  8:02 ` Andreas Schwab
  2016-08-08  8:55   ` 路客
  0 siblings, 1 reply; 6+ messages in thread
From: Andreas Schwab @ 2016-08-08  8:02 UTC (permalink / raw)
  To: 路客; +Cc: Emacs developers

On Mo, Aug 08 2016, 路客 <luke.yx.lee@gmail.com> wrote:

> When editing a file in Emacs and switching git branches, sometimes
> a file will be removed but Emacs won't detect it. Unlike modified
> files it will ask me to revert, deleted files are not. Is it
> intentional?

There is nothing to revert from.  A buffer visiting a non-existing file
isn't an error condition, saving it will not lose anything.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Emacs does not detect a buffered file got deleted
  2016-08-08  8:02 ` Andreas Schwab
@ 2016-08-08  8:55   ` 路客
  2016-08-08 14:55     ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: 路客 @ 2016-08-08  8:55 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Emacs developers

[-- Attachment #1: Type: text/plain, Size: 1215 bytes --]

Yes, I understood that. My intention is to notify the user about the
deletion but not
really want to revert the file. Emacs provide other options other than
reverting. A
"revert" here might mean "close this buffer". However,this might need
further
modification to notify the user about the deletion instead of the normal
modification
notification. Using the original `ask-user-about-supersession-threat' might
be a bit
confusing if file is deleted. What do you think?




2016-08-08 16:02 GMT+08:00 Andreas Schwab <schwab@suse.de>:

> On Mo, Aug 08 2016, 路客 <luke.yx.lee@gmail.com> wrote:
>
> > When editing a file in Emacs and switching git branches, sometimes
> > a file will be removed but Emacs won't detect it. Unlike modified
> > files it will ask me to revert, deleted files are not. Is it
> > intentional?
>
> There is nothing to revert from.  A buffer visiting a non-existing file
> isn't an error condition, saving it will not lose anything.
>
> Andreas.
>
> --
> Andreas Schwab, SUSE Labs, schwab@suse.de
> GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
> "And now for something completely different."
>



-- 
Best regards,
Luke Lee

[-- Attachment #2: Type: text/html, Size: 1925 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Emacs does not detect a buffered file got deleted
  2016-08-08  8:55   ` 路客
@ 2016-08-08 14:55     ` Eli Zaretskii
  2016-08-09  1:02       ` 路客
  0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2016-08-08 14:55 UTC (permalink / raw)
  To: 路客; +Cc: schwab, emacs-devel

> From: 路客 <luke.yx.lee@gmail.com>
> Date: Mon, 8 Aug 2016 16:55:55 +0800
> Cc: Emacs developers <emacs-devel@gnu.org>
> 
> Yes, I understood that. My intention is to notify the user about the deletion but not 
> really want to revert the file. Emacs provide other options other than reverting. A 
> "revert" here might mean "close this buffer". However,this might need further 
> modification to notify the user about the deletion instead of the normal modification
> notification. Using the original `ask-user-about-supersession-threat' might be a bit
> confusing if file is deleted. What do you think?

Emacs doesn't do anything like that anywhere else, AFAIK.  Not even
auto-revert mode does something like that for deleted files.  I'm not
sure I see good reasons to do anything in this particular case.

Let me turn the table and ask you what kind of trouble you saw with
buffers whose files were deleted by Git (or any other VCS)?  Why would
you like Emacs to do something special in this case?  An extra buffer
is a non-issue in Emacs.

Thanks.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Emacs does not detect a buffered file got deleted
  2016-08-08 14:55     ` Eli Zaretskii
@ 2016-08-09  1:02       ` 路客
  2016-08-10  0:52         ` Jiege Chen
  0 siblings, 1 reply; 6+ messages in thread
From: 路客 @ 2016-08-09  1:02 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Andreas Schwab, Emacs developers

[-- Attachment #1: Type: text/plain, Size: 2221 bytes --]

Nope, it's not an issue at all; it's just for user-convenience. Whether
convenient or not is of course personal but some modern editors like
notepad++, ultraedit ... already doing this for some time. VIM does not
detect that either, but gvim did give us a warning about file no longer
there. Here I'm just trying to match some modern editor behavior. One
sample issue is that when switching between git branches I sometimes find
I'm still editing a file that's already not there
(moved/deleted/included-into-other-file by others), till I do "git status"
or "git add" and then find out the fact.

Of course it won't be difficult to add an extra mode to do that but I'm
just thinking it should be easier to fix it from the origin. Remove that
test condition and modify `ask-user-about-supersession-threat' to detect
file deletion.

Well, if no one think it's a good idea I will draw back my proposal then
and patch it in my own local system, or maybe a minor mode then. Thanks!

2016-08-08 22:55 GMT+08:00 Eli Zaretskii <eliz@gnu.org>:

> > From: 路客 <luke.yx.lee@gmail.com>
> > Date: Mon, 8 Aug 2016 16:55:55 +0800
> > Cc: Emacs developers <emacs-devel@gnu.org>
> >
> > Yes, I understood that. My intention is to notify the user about the
> deletion but not
> > really want to revert the file. Emacs provide other options other than
> reverting. A
> > "revert" here might mean "close this buffer". However,this might need
> further
> > modification to notify the user about the deletion instead of the normal
> modification
> > notification. Using the original `ask-user-about-supersession-threat'
> might be a bit
> > confusing if file is deleted. What do you think?
>
> Emacs doesn't do anything like that anywhere else, AFAIK.  Not even
> auto-revert mode does something like that for deleted files.  I'm not
> sure I see good reasons to do anything in this particular case.
>
> Let me turn the table and ask you what kind of trouble you saw with
> buffers whose files were deleted by Git (or any other VCS)?  Why would
> you like Emacs to do something special in this case?  An extra buffer
> is a non-issue in Emacs.
>
> Thanks.
>



-- 
Best regards,
Luke Lee

[-- Attachment #2: Type: text/html, Size: 2908 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Emacs does not detect a buffered file got deleted
  2016-08-09  1:02       ` 路客
@ 2016-08-10  0:52         ` Jiege Chen
  0 siblings, 0 replies; 6+ messages in thread
From: Jiege Chen @ 2016-08-10  0:52 UTC (permalink / raw)
  To: emacs-devel

On the contrary, I prefer the GNU Emacs way. Please make this as the
default if you create a new defcustom.

路客 <luke.yx.lee@gmail.com> wrote:
> Nope, it's not an issue at all; it's just for user-convenience. Whether
> convenient or not is of course personal but some modern editors like
> notepad++, ultraedit ... already doing this for some time. VIM does not
> detect that either, but gvim did give us a warning about file no longer
> there. Here I'm just trying to match some modern editor behavior. One
> sample issue is that when switching between git branches I sometimes find
> I'm still editing a file that's already not there
> (moved/deleted/included-into-other-file by others), till I do "git status"
> or "git add" and then find out the fact.
> 
> Of course it won't be difficult to add an extra mode to do that but I'm
> just thinking it should be easier to fix it from the origin. Remove that
> test condition and modify `ask-user-about-supersession-threat' to detect
> file deletion.
> 
> Well, if no one think it's a good idea I will draw back my proposal then
> and patch it in my own local system, or maybe a minor mode then. Thanks!
> 
> 2016-08-08 22:55 GMT+08:00 Eli Zaretskii <eliz@gnu.org>:
> 
>>> From: 路客 <luke.yx.lee@gmail.com>
>>> Date: Mon, 8 Aug 2016 16:55:55 +0800
>>> Cc: Emacs developers <emacs-devel@gnu.org>
>>> 
>>> Yes, I understood that. My intention is to notify the user about the
>> deletion but not
>>> really want to revert the file. Emacs provide other options other than
>> reverting. A
>>> "revert" here might mean "close this buffer". However,this might need
>> further
>>> modification to notify the user about the deletion instead of the normal
>> modification
>>> notification. Using the original `ask-user-about-supersession-threat'
>> might be a bit
>>> confusing if file is deleted. What do you think?
>> 
>> Emacs doesn't do anything like that anywhere else, AFAIK.  Not even
>> auto-revert mode does something like that for deleted files.  I'm not
>> sure I see good reasons to do anything in this particular case.
>> 
>> Let me turn the table and ask you what kind of trouble you saw with
>> buffers whose files were deleted by Git (or any other VCS)?  Why would
>> you like Emacs to do something special in this case?  An extra buffer
>> is a non-issue in Emacs.
>> 
>> Thanks.
>> 
> 
> 
> 



-- 
Jiegec




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-08-10  0:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-08  3:33 Emacs does not detect a buffered file got deleted 路客
2016-08-08  8:02 ` Andreas Schwab
2016-08-08  8:55   ` 路客
2016-08-08 14:55     ` Eli Zaretskii
2016-08-09  1:02       ` 路客
2016-08-10  0:52         ` Jiege Chen

Code repositories for project(s) associated with this public inbox

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

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