From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Zachary Kanfer Newsgroups: gmane.emacs.bugs Subject: bug#56229: title: add a function to move a file from one place to another Date: Mon, 27 Jun 2022 23:24:29 -0400 Message-ID: References: <87bkuffph1.fsf@gnus.org> <875ykne905.fsf@gnus.org> <87zghza0u8.fsf@gmail.com> <87ilom8rrh.fsf@gnus.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="000000000000bb255305e2799313" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1726"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 56229@debbugs.gnu.org, Visuwesh To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jun 28 05:26:23 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o61rq-0000Ab-Mh for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 28 Jun 2022 05:26:22 +0200 Original-Received: from localhost ([::1]:49776 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o61rp-0006tc-7q for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 27 Jun 2022 23:26:21 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57000) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o61rW-0006rk-5D for bug-gnu-emacs@gnu.org; Mon, 27 Jun 2022 23:26:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:59819) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o61rV-0004Dh-TJ for bug-gnu-emacs@gnu.org; Mon, 27 Jun 2022 23:26:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1o61rV-000398-Oz for bug-gnu-emacs@gnu.org; Mon, 27 Jun 2022 23:26:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Zachary Kanfer Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 28 Jun 2022 03:26:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56229 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 56229-submit@debbugs.gnu.org id=B56229.165638670111997 (code B ref 56229); Tue, 28 Jun 2022 03:26:01 +0000 Original-Received: (at 56229) by debbugs.gnu.org; 28 Jun 2022 03:25:01 +0000 Original-Received: from localhost ([127.0.0.1]:53712 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o61qT-00037D-Nk for submit@debbugs.gnu.org; Mon, 27 Jun 2022 23:25:01 -0400 Original-Received: from mail-yb1-f177.google.com ([209.85.219.177]:38754) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o61qI-00036q-Nm for 56229@debbugs.gnu.org; Mon, 27 Jun 2022 23:24:55 -0400 Original-Received: by mail-yb1-f177.google.com with SMTP id d5so20058672yba.5 for <56229@debbugs.gnu.org>; Mon, 27 Jun 2022 20:24:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=njyryt+gbR/2/HCPbrF11I2Vsi+Fad31IUnvjXjI/IY=; b=X8wj5Zvc/fPbVHUg4pVZ4zw4MGaTVF2/i9t81Yl7FG5TAZXO8IoZwVNL2ML8roSWCS mm6a7R36ty49QjWMJOAlVRvGiFJ4hhNZKU+/wmCCgY4X7jJFSAqCi9O8uHRGQFnbmZeJ TMtbBdqbp0X+AaXVAuTa2U4cnxg3t7R/3u9vzNgJ4e/jzaYPOeQP0qHg4uGbMSCMyU7Z dAD03iU9I4zdoF+I3tMvJd28Fqy3sA4RsGTsPGjkkN2u2zmEa1uyV3eOpfQqnyerX5un b4O6iNZbYpHUOuiSwq5hE5PkwjnrwZlLmsgNcLqaqAE3+NF2gTMLxuasKzye6yz/ZvER efww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=njyryt+gbR/2/HCPbrF11I2Vsi+Fad31IUnvjXjI/IY=; b=aO406CtKFNSPeF9TvVA35qwcj+D1tVroLUGN2yqBDrz7BHn4Oi6xFdlws4T6xbolNQ 1myiRWDy+gA0WvgcnQYMK2nlumAEqaYFP4+KYG96aB1/4pHpbHhVKK/6rKA0TnTsFd3n Ls7y5VRW+m4n6XuLfccDjm3MqAdeB06r6auzC72Igu6dkYsiZcn/bvi8U7xFPuI7t4ue 7CZuqnwZtuXuRAFLMAYdT7i1HoUVCXzc+mrF20WNiLXd6h7aAYqXopJeF+Z6jY2Ft+/8 mkegLzjvKVAdeNyvFy7c8YROzxFS2BbhsFk8h0Ksv17IdsILPG2WEsYM6aNL7U5EVb6A q9UQ== X-Gm-Message-State: AJIora/b3Q6dHL3I0hktIr9Xo2p5nTMLLyFFf6YGuE4lt2Ce1jD0EjHd Ua+Q8VeKBixiD24sn99WfPtx1XbusbL6srA+vNY= X-Google-Smtp-Source: AGRyM1u2eyIIk9uLOkgCX66/XHidUT7TfOloXutLhDO1ETe7O+e5m4CK6EM70LDXorYIiNTsQhWK39pk5FV5SxZH6bk= X-Received: by 2002:a05:6902:1543:b0:665:493b:e7f5 with SMTP id r3-20020a056902154300b00665493be7f5mr17062129ybu.322.1656386680967; Mon, 27 Jun 2022 20:24:40 -0700 (PDT) In-Reply-To: <87ilom8rrh.fsf@gnus.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:235509 Archived-At: --000000000000bb255305e2799313 Content-Type: multipart/alternative; boundary="000000000000bb255105e2799311" --000000000000bb255105e2799311 Content-Type: text/plain; charset="UTF-8" > > +** New command 'move-file'. > > +This command moves a file to a new location. > Should be updated. +1 > > + (let ((old-location (buffer-file-name))) > > + (write-file new-location t) > > + (when (and old-location > > + (file-exists-p new-location)) > > + (delete-file old-location)))) > > Probably want to check whether old-location exists? I was checking whether the new locations exists to ensure the write succeeded. If the write fails, I think we should leave the old file in place. #'delete-file does not error when given a nonexistent location, but I suppose it could do so in the future. So I don't think we *need* to check whether old-location exists, but it's certainly safer to do so. I'll add it! Attached is a patch with the changes. > Anyway, apparently there's something up with the copyright > assignment/disclaimer? Your entry in the file says "**NEEDS New > DISCLAIMER**" -- do you know what that's about? I had moved jobs, and was attempting to get my new company to sign the disclaimer. (My manager had not wanted it to get signed). I've since changed teams inside the company, and got the disclaimer signed. After sending the signed disclaimer a week or two ago, Craig Topham confirmed I was good to go -- perhaps something didn't get updated here? On Mon, Jun 27, 2022 at 3:55 AM Lars Ingebrigtsen wrote: > Zachary Kanfer writes: > > > I think `rename-visited-file' would fit in better especially since we > > already have `rename-file'; it also parallels dired's R command. > > Thanks. A couple of things: > > [...] > > > +** New command 'move-file'. > > +This command moves a file to a new location. > > Should be updated. > > > [...] > > > + (let ((old-location (buffer-file-name))) > > + (write-file new-location t) > > + (when (and old-location > > + (file-exists-p new-location)) > > + (delete-file old-location)))) > > Probably want to check whether old-location exists? > > Anyway, apparently there's something up with the copyright > assignment/disclaimer? Your entry in the file says "**NEEDS New > DISCLAIMER**" -- do you know what that's about? > > -- > (domestic pets only, the antidote for overdose, milk.) > bloggy blog: http://lars.ingebrigtsen.no > --000000000000bb255105e2799311 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
> > +** New command 'move-file'.
> > +This command moves a file to a new location.

> Should be updated.

+1

> > +=C2=A0 (let ((old-location (buffer-fil= e-name)))
> > +=C2=A0=C2=A0=C2=A0 (write-file new-location t)> > +=C2=A0=C2=A0=C2=A0 (when (and old-location
> > +=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 (file-exists-p new-location))
> > +=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 (delete-file old-location))))
>
> Probably want to ch= eck whether old-location exists?

I was checking w= hether the new locations exists to ensure the write succeeded. If the write= fails, I think we should leave the old file in place.

#'delete-file does not error when given a nonexistent location= , but I suppose it could do so in the future. So I don't think we *need= * to check whether old-location exists, but it's certainly safer to do = so. I'll add it!

Attached is a patch with = the changes.

> Anyway, apparently there's s= omething up with the copyright
> assignment/disclaimer?=C2=A0 Your en= try in the file says "**NEEDS New
> DISCLAIMER**" -- do you= know what that's about?

I had moved jobs, and= was attempting to get my new company to sign the disclaimer. (My manager h= ad not wanted it to get signed). I've since changed teams inside the co= mpany, and got the disclaimer signed. After sending the signed disclaimer a= week or two ago, Craig Topham confirmed I was good to go -- perhaps someth= ing didn't get updated here?

On Mon, Jun 27, 2022 at 3:55 AM L= ars Ingebrigtsen <la= rsi@gnus.org> wrote:
Zachary Kanfer <zkanfer@gmail.com> writes:

>=C2=A0 I think `rename-visited-file' would fit in better especially= since we
>=C2=A0 already have `rename-file'; it also parallels dired's R = command.

Thanks.=C2=A0 A couple of things:

[...]

> +** New command 'move-file'.
> +This command moves a file to a new location.

Should be updated.


[...]

> +=C2=A0 (let ((old-location (buffer-file-name)))
> +=C2=A0 =C2=A0 (write-file new-location t)
> +=C2=A0 =C2=A0 (when (and old-location
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(file-exists-p= new-location))
> +=C2=A0 =C2=A0 =C2=A0 (delete-file old-location))))

Probably want to check whether old-location exists?

Anyway, apparently there's something up with the copyright
assignment/disclaimer?=C2=A0 Your entry in the file says "**NEEDS New<= br> DISCLAIMER**" -- do you know what that's about?

--
(domestic pets only, the antidote for overdose, milk.)
=C2=A0 =C2=A0bloggy blog: http://lars.ingebrigtsen.no
--000000000000bb255105e2799311-- --000000000000bb255305e2799313 Content-Type: application/x-patch; name="0001-Add-a-function-to-rename-the-file-visited-by-the-cur.patch" Content-Disposition: attachment; filename="0001-Add-a-function-to-rename-the-file-visited-by-the-cur.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_l4xlnmb00 RnJvbSBiODA2NjY5NTc5N2MzMmM5OTQzMTEzMzY0ZWE0NWYxNDEyYzg5MzFkIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBaYWNoYXJ5IEthbmZlciA8emthbmZlckBnbWFpbC5jb20+CkRh dGU6IFNhdCwgMjUgSnVuIDIwMjIgMDE6NDg6MzggLTA0MDAKU3ViamVjdDogW1BBVENIXSBBZGQg YSBmdW5jdGlvbiB0byByZW5hbWUgdGhlIGZpbGUgdmlzaXRlZCBieSB0aGUgY3VycmVudAogYnVm ZmVyLgoKKiBsaXNwL2ZpbGVzLmVsIChyZW5hbWUtdmlzaXRlZC1maWxlKQotLS0KIGV0Yy9ORVdT ICAgICAgfCAgNCArKysrCiBsaXNwL2ZpbGVzLmVsIHwgMjAgKysrKysrKysrKysrKysrKysrKysK IDIgZmlsZXMgY2hhbmdlZCwgMjQgaW5zZXJ0aW9ucygrKQoKZGlmZiAtLWdpdCBhL2V0Yy9ORVdT IGIvZXRjL05FV1MKaW5kZXggNmMwNGFl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mVuYW1lIHRoZSBmaWxlIHZpc2l0ZWQgYnkgdGhlIGN1cnJlbnQgYnVm ZmVyIHRvIE5FVy1MT0NBVElPTi4KKworSW50ZXJhY3RpdmVseSwgdGhpcyBwcm9tcHRzIGZvciBO RVctTE9DQVRJT04uCisKK0lmIHRoZSBmaWxlIGhhcyBub3QgYmVlbiB2aXNpdGVkLCB0aGlzIHdy aXRlcyB0aGUgZmlsZSB0byBORVctTE9DQVRJT04uIgorICAoaW50ZXJhY3RpdmUgKGxpc3QgKGlm IGJ1ZmZlci1maWxlLW5hbWUKKyAgICAgICAgICAgICAgICAgICAgICAgICAocmVhZC1maWxlLW5h bWUgIlJlbmFtZSBmaWxlIHRvOiAiKQorICAgICAgICAgICAgICAgICAgICAgICAocmVhZC1maWxl LW5hbWUgIlJlbmFtZSBmaWxlIHRvOiAiCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICBkZWZhdWx0LWRpcmVjdG9yeQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgKGV4cGFuZC1maWxlLW5hbWUgKGZpbGUtbmFtZS1ub25kaXJlY3RvcnkgKGJ1ZmZl ci1uYW1lKSkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgIGRlZmF1bHQtZGlyZWN0b3J5KSkpKSkKKyAgKGxldCAoKG9sZC1sb2NhdGlvbiAo YnVmZmVyLWZpbGUtbmFtZSkpKQorICAgICh3cml0ZS1maWxlIG5ldy1sb2NhdGlvbiB0KQorICAg ICh3aGVuIChhbmQgb2xkLWxvY2F0aW9uCisgICAgICAgICAgICAgICAoZmlsZS1leGlzdHMtcCBv bGQtbG9jYXRpb24pCisgICAgICAgICAgICAgICAoZmlsZS1leGlzdHMtcCBuZXctbG9jYXRpb24p KQorICAgICAgKGRlbGV0ZS1maWxlIG9sZC1sb2NhdGlvbikpKSkKKwogDAogKGRlZnVuIGZpbGUt ZXh0ZW5kZWQtYXR0cmlidXRlcyAoZmlsZW5hbWUpCiAgICJSZXR1cm4gYW4gYWxpc3Qgb2YgZXh0 ZW5kZWQgYXR0cmlidXRlcyBvZiBmaWxlIEZJTEVOQU1FLgotLSAKMi4yNS4xCgo= --000000000000bb255305e2799313--