GNU bug report logs - #18009
24.4.50; Add hooks for `rename-file' and `delete-file'

Previous Next

Package: emacs;

Reported by: Drew Adams <drew.adams <at> oracle.com>

Date: Sat, 12 Jul 2014 22:33:01 UTC

Severity: wishlist

Tags: wontfix

Found in version 24.4.50

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 18009 in the body.
You can then email your comments to 18009 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#18009; Package emacs. (Sat, 12 Jul 2014 22:33:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Drew Adams <drew.adams <at> oracle.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 12 Jul 2014 22:33:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.4.50; Add hooks for `rename-file' and `delete-file'
Date: Sat, 12 Jul 2014 15:31:49 -0700 (PDT)
Please add a hook for each of these basic operations.  It is not unusual
to want to be able to carry out some action associated with
(successfully) renaming or deleting a file.  The hooks would be run at
the end of the operation, and only upon success.

One use case: Bookmark+ autofile bookmarks have the same name as their
files.  (There can be multiple bookmarks with the same name,
corresponding to files with the same name in different directories.)
With a hook it would be trivial to automatically rename or delete the
associated bookmark.

Adding hooks for these two functions would automatically take care of
derivative functions, such as `dired-rename-file' and `dired-do-rename'.

In GNU Emacs 24.4.50.1 (i686-pc-mingw32)
 of 2014-06-28 on ODIEONE
Bzr revision: 117431 rgm <at> gnu.org-20140628015517-eku6hj8mpgcvfnso
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --prefix=/c/Devel/emacs/snapshot/trunk
 --enable-checking=yes,glyphs 'CFLAGS=-O0 -g3'
 LDFLAGS=-Lc:/Devel/emacs/lib 'CPPFLAGS=-DGC_MCHECK=1
 -Ic:/Devel/emacs/include''




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18009; Package emacs. (Sat, 12 Jul 2014 22:40:02 GMT) Full text and rfc822 format available.

Message #8 received at 18009 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: 18009 <at> debbugs.gnu.org
Subject: RE: bug#18009: 24.4.50; Add hooks for `rename-file' and `delete-file'
Date: Sat, 12 Jul 2014 15:39:42 -0700 (PDT)
> One use case: Bookmark+ autofile bookmarks have the same name as their
> files.  (There can be multiple bookmarks with the same name,
> corresponding to files with the same name in different directories.)
> With a hook it would be trivial to automatically rename or delete the
> associated bookmark.

Besides that use case, which is specific to Bookmark+, it could be
useful to (optionally) automatically relocate any (i.e. vanilla)
bookmarks whose files were renamed.  Currently, such relocation is
entirely manual (command `bookmark-relocate').




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18009; Package emacs. (Sun, 13 Jul 2014 01:36:02 GMT) Full text and rfc822 format available.

Message #11 received at 18009 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: 18009 <at> debbugs.gnu.org
Subject: Re: bug#18009: 24.4.50; Add hooks for `rename-file' and `delete-file'
Date: Sat, 12 Jul 2014 21:35:56 -0400
You can use advice.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18009; Package emacs. (Sun, 13 Jul 2014 02:34:02 GMT) Full text and rfc822 format available.

Message #14 received at 18009 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Glenn Morris <rgm <at> gnu.org>, 18009 <at> debbugs.gnu.org
Subject: RE: bug#18009: 24.4.50; Add hooks for `rename-file' and `delete-file'
Date: Sat, 12 Jul 2014 19:32:51 -0700 (PDT)
> You can use advice.

I can.  I nevertheless request the enhancement.  For Elisp users generally.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18009; Package emacs. (Sun, 13 Jul 2014 08:14:02 GMT) Full text and rfc822 format available.

Message #17 received at 18009 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: 18009 <at> debbugs.gnu.org
Subject: Re: bug#18009: 24.4.50; Add hooks for `rename-file' and `delete-file'
Date: Sun, 13 Jul 2014 10:13:22 +0200
Drew Adams <drew.adams <at> oracle.com> writes:

> Please add a hook for each of these basic operations.

There's already the rename-file and delete-file file name handlers.

Andreas.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18009; Package emacs. (Sun, 13 Jul 2014 09:22:02 GMT) Full text and rfc822 format available.

Message #20 received at 18009 <at> debbugs.gnu.org (full text, mbox):

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Andreas Schwab <schwab <at> linux-m68k.org>
Cc: Drew Adams <drew.adams <at> oracle.com>, 18009 <at> debbugs.gnu.org
Subject: Re: bug#18009: 24.4.50; Add hooks for `rename-file' and `delete-file'
Date: Sun, 13 Jul 2014 11:21:33 +0200
Andreas Schwab <schwab <at> linux-m68k.org> writes:

> Drew Adams <drew.adams <at> oracle.com> writes:
>
>> Please add a hook for each of these basic operations.
>
> There's already the rename-file and delete-file file name handlers.

That's different. Drew does not want to replace rename-file and
delete-file implementations. He wants to run something afterwards.

> Andreas.

Best regards, Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18009; Package emacs. (Sun, 13 Jul 2014 09:27:02 GMT) Full text and rfc822 format available.

Message #23 received at 18009 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: Michael Albinus <michael.albinus <at> gmx.de>
Cc: Drew Adams <drew.adams <at> oracle.com>, 18009 <at> debbugs.gnu.org
Subject: Re: bug#18009: 24.4.50; Add hooks for `rename-file' and `delete-file'
Date: Sun, 13 Jul 2014 11:26:20 +0200
Michael Albinus <michael.albinus <at> gmx.de> writes:

> Andreas Schwab <schwab <at> linux-m68k.org> writes:
>
>> Drew Adams <drew.adams <at> oracle.com> writes:
>>
>>> Please add a hook for each of these basic operations.
>>
>> There's already the rename-file and delete-file file name handlers.
>
> That's different. Drew does not want to replace rename-file and
> delete-file implementations. He wants to run something afterwards.

You can do that with file name handlers.

Andreas.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18009; Package emacs. (Sun, 13 Jul 2014 09:33:02 GMT) Full text and rfc822 format available.

Message #26 received at 18009 <at> debbugs.gnu.org (full text, mbox):

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Andreas Schwab <schwab <at> linux-m68k.org>
Cc: Drew Adams <drew.adams <at> oracle.com>, 18009 <at> debbugs.gnu.org
Subject: Re: bug#18009: 24.4.50; Add hooks for `rename-file' and `delete-file'
Date: Sun, 13 Jul 2014 11:32:39 +0200
Andreas Schwab <schwab <at> linux-m68k.org> writes:

>>>> Please add a hook for each of these basic operations.
>>>
>>> There's already the rename-file and delete-file file name handlers.
>>
>> That's different. Drew does not want to replace rename-file and
>> delete-file implementations. He wants to run something afterwards.
>
> You can do that with file name handlers.

I'll still don't understand. File name handlers are intended to provide
a *different* implementation. Drew hasn't asked for this.

And even if he goes this way, he would loose existing file name
handlers, for example from Tramp.

> Andreas.

Best regards, Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18009; Package emacs. (Sun, 13 Jul 2014 09:39:02 GMT) Full text and rfc822 format available.

Message #29 received at 18009 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: Michael Albinus <michael.albinus <at> gmx.de>
Cc: Drew Adams <drew.adams <at> oracle.com>, 18009 <at> debbugs.gnu.org
Subject: Re: bug#18009: 24.4.50; Add hooks for `rename-file' and `delete-file'
Date: Sun, 13 Jul 2014 11:38:41 +0200
Michael Albinus <michael.albinus <at> gmx.de> writes:

> I'll still don't understand. File name handlers are intended to provide
> a *different* implementation.

Are they?

> And even if he goes this way, he would loose existing file name
> handlers, for example from Tramp.

There is not necessarily the case.

Andreas.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18009; Package emacs. (Sun, 13 Jul 2014 09:48:01 GMT) Full text and rfc822 format available.

Message #32 received at 18009 <at> debbugs.gnu.org (full text, mbox):

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Andreas Schwab <schwab <at> linux-m68k.org>
Cc: Drew Adams <drew.adams <at> oracle.com>, 18009 <at> debbugs.gnu.org
Subject: Re: bug#18009: 24.4.50; Add hooks for `rename-file' and `delete-file'
Date: Sun, 13 Jul 2014 11:46:57 +0200
Andreas Schwab <schwab <at> linux-m68k.org> writes:

> Michael Albinus <michael.albinus <at> gmx.de> writes:
>
>> I'll still don't understand. File name handlers are intended to provide
>> a *different* implementation.
>
> Are they?

Yes. And they are invoked only when the file *name* matches a given
regexp. Drew hasn't mentioned this.

>> And even if he goes this way, he would loose existing file name
>> handlers, for example from Tramp.
>
> There is not necessarily the case.

Of course, you could write a file name handler which would reinvoke
other file name handlers afterwards. But the more natural approach would
be to advice rename-file and delete-file. 

> Andreas.

Best regards, Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18009; Package emacs. (Sun, 13 Jul 2014 10:56:02 GMT) Full text and rfc822 format available.

Message #35 received at 18009 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: Michael Albinus <michael.albinus <at> gmx.de>
Cc: 18009 <at> debbugs.gnu.org
Subject: Re: bug#18009: 24.4.50; Add hooks for `rename-file' and `delete-file'
Date: Sun, 13 Jul 2014 12:55:17 +0200
Michael Albinus <michael.albinus <at> gmx.de> writes:

> Andreas Schwab <schwab <at> linux-m68k.org> writes:
>
>> Michael Albinus <michael.albinus <at> gmx.de> writes:
>>
>>> I'll still don't understand. File name handlers are intended to provide
>>> a *different* implementation.
>>
>> Are they?
>
> Yes. And they are invoked only when the file *name* matches a given
> regexp. Drew hasn't mentioned this.

Of course, you can write regexps that match any name.

Andreas.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18009; Package emacs. (Sat, 19 Jul 2014 02:35:02 GMT) Full text and rfc822 format available.

Message #38 received at 18009 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: 18009 <at> debbugs.gnu.org
Subject: Re: bug#18009: 24.4.50; Add hooks for `rename-file' and `delete-file'
Date: Fri, 18 Jul 2014 22:34:21 -0400
> Please add a hook for each of these basic operations.  It is not unusual
> to want to be able to carry out some action associated with
> (successfully) renaming or deleting a file.  The hooks would be run at
> the end of the operation, and only upon success.

It's not unreasonable, but these are rather low-level operations, I'm
not sure I want to run hooks from them.

> One use case: Bookmark+ autofile bookmarks have the same name as their
> files.  (There can be multiple bookmarks with the same name,
> corresponding to files with the same name in different directories.)
> With a hook it would be trivial to automatically rename or delete the
> associated bookmark.

Of course you can use an `advice' in the mean time, but maybe a better
long-term answer is the file-notification API so that your code would
know about renames not only when they're performed from the same Emacs
session but also from any other process.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18009; Package emacs. (Sat, 19 Jul 2014 16:16:02 GMT) Full text and rfc822 format available.

Message #41 received at 18009 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 18009 <at> debbugs.gnu.org
Subject: RE: bug#18009: 24.4.50; Add hooks for `rename-file' and `delete-file'
Date: Sat, 19 Jul 2014 09:15:23 -0700 (PDT)
> > Please add a hook for each of these basic operations.  It is not
> > unusual to want to be able to carry out some action associated with
> > (successfully) renaming or deleting a file.  The hooks would be run
> > at the end of the operation, and only upon success.
> 
> It's not unreasonable, but these are rather low-level operations, I'm
> not sure I want to run hooks from them.

I'm curious what difference that makes.  I suppose you're thinking that
if a hook does something awful then it could affect things widely.  Is
that it?

I guess I don't have a good counter argument, if so.  On the other
hand, the same thing would happen if someone advised the function.

Plus, there are hooks and there are hooks.  Some hooks have more
potential for wreaking havoc than others.  We have not created hooks
only for contexts that are benign or well isolated.  We have hooks
that, if abused, can lead to data corruption or loss.  I don't really
see why these hooks would be so different.

> > One use case: Bookmark+ autofile bookmarks have the same name as their
> > files.  (There can be multiple bookmarks with the same name,
> > corresponding to files with the same name in different directories.)
> > With a hook it would be trivial to automatically rename or delete the
> > associated bookmark.
> 
> Of course you can use an `advice' in the mean time, but maybe a better
> long-term answer is the file-notification API so that your code would
> know about renames not only when they're performed from the same Emacs
> session but also from any other process.

I will take a look at that; I'm not familiar with it.  The doc speaks
of a few restrictions and caveats, but it does sound worth trying.

Why did you mention "long-term" here? I wonder if I'm missing something.

That might well be something interesting for the use case I mentioned.
But I would still like to see the hooks added.  It is not the same
thing to want Emacs to do something when IT renames or deletes a file,
as opposed to hearing back from the operating system (when, exactly?)
that something was changed.  Associating an action with the act of
renaming or deleting makes sense to me, a priori.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18009; Package emacs. (Sun, 20 Feb 2022 13:09:02 GMT) Full text and rfc822 format available.

Message #44 received at 18009 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Drew Adams <drew.adams <at> oracle.com>, 18009 <at> debbugs.gnu.org
Subject: Re: bug#18009: 24.4.50; Add hooks for `rename-file' and `delete-file'
Date: Sun, 20 Feb 2022 14:07:52 +0100
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

>> Please add a hook for each of these basic operations.  It is not unusual
>> to want to be able to carry out some action associated with
>> (successfully) renaming or deleting a file.  The hooks would be run at
>> the end of the operation, and only upon success.
>
> It's not unreasonable, but these are rather low-level operations, I'm
> not sure I want to run hooks from them.

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

I think the conclusion here is that we don't want to add any hooks to
these functions, and the user can use file name handlers and/or advice
to alter the behaviour if they want to.

So I'm closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) wontfix. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 20 Feb 2022 13:09:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 18009 <at> debbugs.gnu.org and Drew Adams <drew.adams <at> oracle.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 20 Feb 2022 13:09:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18009; Package emacs. (Sun, 20 Feb 2022 21:09:01 GMT) Full text and rfc822 format available.

Message #51 received at 18009 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>, Stefan Monnier
 <monnier <at> iro.umontreal.ca>
Cc: "18009 <at> debbugs.gnu.org" <18009 <at> debbugs.gnu.org>
Subject: RE: [External] : Re: bug#18009: 24.4.50; Add hooks for `rename-file'
 and `delete-file'
Date: Sun, 20 Feb 2022 21:08:48 +0000
> I think the conclusion here is that we don't want to add any hooks to
> these functions, and the user can use file name handlers and/or advice
> to alter the behaviour if they want to.
> 
> So I'm closing this bug report.

Why is that your conclusion now?
There was no conclusion, let alone
such a conclusion, in the bug thread.

Closing with no reason given.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 21 Mar 2022 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 29 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.