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: Sun, 26 Jun 2022 00:49:33 -0400 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="0000000000003ed80c05e2528842" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17433"; mail-complaints-to="usenet@ciao.gmane.io" To: 56229@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jun 26 06:50:15 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 1o5KDv-0004Oh-1T for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 26 Jun 2022 06:50:15 +0200 Original-Received: from localhost ([::1]:45054 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o5KDt-0002Zt-Gc for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 26 Jun 2022 00:50:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45078) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o5KDj-0002XS-75 for bug-gnu-emacs@gnu.org; Sun, 26 Jun 2022 00:50:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:52626) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o5KDi-00013s-Tx for bug-gnu-emacs@gnu.org; Sun, 26 Jun 2022 00:50:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1o5KDi-0000c9-Qc for bug-gnu-emacs@gnu.org; Sun, 26 Jun 2022 00:50:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Zachary Kanfer Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 26 Jun 2022 04:50:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 56229 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.16562189902335 (code B ref -1); Sun, 26 Jun 2022 04:50:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 26 Jun 2022 04:49:50 +0000 Original-Received: from localhost ([127.0.0.1]:46523 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o5KDV-0000bb-PQ for submit@debbugs.gnu.org; Sun, 26 Jun 2022 00:49:50 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:52062) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o5KDU-0000bT-5g for submit@debbugs.gnu.org; Sun, 26 Jun 2022 00:49:48 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45064) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o5KDT-0002Fb-UB for bug-gnu-emacs@gnu.org; Sun, 26 Jun 2022 00:49:47 -0400 Original-Received: from mail-yw1-x1133.google.com ([2607:f8b0:4864:20::1133]:40840) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o5KDS-0000x9-6f for bug-gnu-emacs@gnu.org; Sun, 26 Jun 2022 00:49:47 -0400 Original-Received: by mail-yw1-x1133.google.com with SMTP id 00721157ae682-317a66d62dfso57874557b3.7 for ; Sat, 25 Jun 2022 21:49:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=wnXJGuO9pFlK6RZ6NR7MzCb9LebcqYpdKNr+Q0rL0dA=; b=a/hqgmL7+bTa6yj5qW/s9xBVCag3WgnePZSRRbd+7bxcZbjuBZfC0uYKhGsbjN8xeQ R0yivbtqaC+Kt9dlOM6ZmbC31DFX4du6SoZ1zseUdPoutn+VJFLzUokJyN4xpZGsqTca o68SFq+kgh++NvuYuyJteiIHh/nS70T9BMqKRRLejJDvDbVyVawzaiW2yGDiMpgLjVUx L4Hm5fTbF5RXwlQOX71J7Qm1SdtvAJ3dVqNxS+iYaqsls6Cy+pIvWzt8mxAJYMX75+Ui PTsOLz8rVKXz23TQws1FlXPyvxWpPiONVQbdgrep/CpZvIJbC1wjkhGdd2Xge09NRtoM FFtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=wnXJGuO9pFlK6RZ6NR7MzCb9LebcqYpdKNr+Q0rL0dA=; b=w8/kdsVu5h1WhuhiISAKkHT9sobeoxhtYKWNQkThORXl0PTGwlvBTRQ0DrzuqWB0AG w+Z2uPYEm5wR+mSYJacBaW6qExFMyu8jYHkLAhlB5jTcw99+TtNl/kEnvVfKO3fOPD5R jPyLbTB4p2tysdklsdL2yieXysYcticQj368xdQm5SgUgkOub4DOZm4Qh5eTLmvLq0rv nBH/twEiCaDFVTLot7O1xnStKQPiDwKx8RvsN4ZXrWqtUavWqiM1jE9DEDnazHjx4j/L H1j+PdDU9SqJzSLwVDNf/yiOa7slXGJrpAL+fcDY58RoKA3E2+dspRWu0OsjugPb6DqU 2mWw== X-Gm-Message-State: AJIora9toWMJPOegl2+AvI2OgAl95t22GEFuFa+fwuXm2NBBJB+UXC4D DUCELLaH/AJBD/1q2B3TctLd9WspR2L6W+vMIAI9c79Y X-Google-Smtp-Source: AGRyM1sWa8OeOys3fBfrIL7pwJYR1NT31KTUUnlTIkC+AQ9pp4cBbVBcqnd5ykichXdnMPmV8qssPAtPq4dp/6i/uR8= X-Received: by 2002:a0d:dd4b:0:b0:318:31c0:ebf0 with SMTP id g72-20020a0ddd4b000000b0031831c0ebf0mr7338129ywe.328.1656218984547; Sat, 25 Jun 2022 21:49:44 -0700 (PDT) Received-SPF: pass client-ip=2607:f8b0:4864:20::1133; envelope-from=zkanfer@gmail.com; helo=mail-yw1-x1133.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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:235301 Archived-At: --0000000000003ed80c05e2528842 Content-Type: multipart/alternative; boundary="0000000000003ed80a05e2528840" --0000000000003ed80a05e2528840 Content-Type: text/plain; charset="UTF-8" There's currently no good way to move a file from one place to another. Emacs has #'write-file, which writes a buffer to a new location. But if the buffer was previously associated with a file, it leaves that old file there. There is #'rename-file, but there are some problems with it. 1. It is file-based. That is, it prompts twice: once for a file to move, and a second time for the file location to move to. It would be easier if we had a function that moved the current buffer. 2. It does not modify any buffers. After running #'rename-file, any buffers with the old file are left open associated with the *old* file. Saving one of these buffers results in the old location being written again. So, attached is a patch for an interactive function that prompts for a new location, then writes the current buffer to that location. Assuming it's successful, and the buffer previously was associated with a file, it deletes the old file. The result is to move the file from one location to another. Because it delegates to #'write-file, we get a lot of behavior for free, like ending up in a buffer associated with the new file. --0000000000003ed80a05e2528840 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
There's currently no good way to move a file from one = place to another.

Emacs has #'write-file, which writes a buffer = to a new location. But if the buffer was previously associated with a file,= it leaves that old file there.

There is #'rename-file, but ther= e are some problems with it.
1. It is file-based. That is, it prompts tw= ice: once for a file to move, and a second time for the file location to mo= ve to. It would be easier if we had a function that moved the current buffe= r.
2. It does not modify any buffers. After running #'rename-file, a= ny buffers with the old file are left open associated with the *old* file. = Saving one of these buffers results in the old location being written again= .

So, attached is a patch for an interactive function that prompts f= or a new location, then writes the current buffer to that location. Assumin= g it's successful, and the buffer previously was associated with a file= , it deletes the old file.

The result is to move the file from one l= ocation to another. Because it delegates to #'write-file, we get a lot = of behavior for free, like ending up in a buffer associated with the new fi= le.

--0000000000003ed80a05e2528840-- --0000000000003ed80c05e2528842 Content-Type: text/x-patch; charset="US-ASCII"; name="0001-Add-a-function-to-move-a-file.patch" Content-Disposition: attachment; filename="0001-Add-a-function-to-move-a-file.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_l4utxc8z0 RnJvbSA1NzA3OGJlNzJiYzE5ZWQ2OTNmYWE5YmRmMWEzOTQwODUzNGE5ZTYxIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBaYWNoYXJ5IEthbmZlciA8emthbmZlckBnbWFpbC5jb20+CkRh dGU6IFNhdCwgMjUgSnVuIDIwMjIgMDE6NDg6MzggLTA0MDAKU3ViamVjdDogW1BBVENIXSBBZGQg YSBmdW5jdGlvbiB0byBtb3ZlIGEgZmlsZS4KCiogbGlzcC9maWxlcy5lbCAobW92ZS1maW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Ugb2xkIGxvY2F0 aW9uLgogICAgICh2Yy1yZWZyZXNoLXN0YXRlKSkpCisKKyhkZWZ1biBtb3ZlLWZpbGUgKG5ldy1s b2NhdGlvbikKKyAgIk1vdmUgdGhlIGN1cnJlbnQgZmlsZSB0byBORVctTE9DQVRJT04uCisKK0lu dGVyYWN0aXZlbHksIHRoaXMgcHJvbXB0cyBmb3IgTkVXLUxPQ0FUSU9OLgorCitUaGlzIHdvcmtz IHdoZXRoZXIgb3Igbm90IHRoZSBidWZmZXIgd2FzIHByZXZpb3VzbHkgc2F2ZWQgdG8gYSBmaWxl LiIKKyAgKGludGVyYWN0aXZlIChsaXN0IChpZiBidWZmZXItZmlsZS1uYW1lCisgICAgICAgICAg ICAgICAgICAgICAgICAgKHJlYWQtZmlsZS1uYW1lICJNb3ZlIGZpbGUgdG86ICIpCisgICAgICAg ICAgICAgICAgICAgICAgIChyZWFkLWZpbGUtbmFtZSAiTW92ZSBmaWxlIHRvOiAiCisgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0LWRpcmVjdG9yeQorICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKGV4cGFuZC1maWxlLW5hbWUgKGZpbGUt bmFtZS1ub25kaXJlY3RvcnkgKGJ1ZmZlci1uYW1lKSkKKyAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQtZGlyZWN0b3J5KSkpKSkK KyAgKGxldCAoKG9sZC1sb2NhdGlvbiAoYnVmZmVyLWZpbGUtbmFtZSkpKQorICAgICh3cml0ZS1m aWxlIG5ldy1sb2NhdGlvbiB0KQorICAgICh3aGVuIChhbmQgb2xkLWxvY2F0aW9uCisgICAgICAg ICAgICAgICAoZmlsZS1leGlzdHMtcCBuZXctbG9jYXRpb24pKQorICAgICAgKGRlbGV0ZS1maWxl IG9sZC1sb2NhdGlvbikpKSkKKwogDAogKGRlZnVuIGZpbGUtZXh0ZW5kZWQtYXR0cmlidXRlcyAo ZmlsZW5hbWUpCiAgICJSZXR1cm4gYW4gYWxpc3Qgb2YgZXh0ZW5kZWQgYXR0cmlidXRlcyBvZiBm aWxlIEZJTEVOQU1FLgotLSAKMi4yNS4xCgo= --0000000000003ed80c05e2528842--