From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.bugs Subject: bug#60460: 30.0.50; [FR] avoid putting remote files to local trash Date: Mon, 2 Jan 2023 06:40:44 +0300 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23288"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/2.2.9+54 (af2080d) (2022-11-21) Cc: Drew Adams , "60460@debbugs.gnu.org" <60460@debbugs.gnu.org> To: Ruijie Yu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jan 02 04:42:22 2023 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 1pCBiP-0005s2-Qg for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 02 Jan 2023 04:42:21 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pCBi9-0008JX-A4; Sun, 01 Jan 2023 22:42:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pCBi7-0008J8-9C for bug-gnu-emacs@gnu.org; Sun, 01 Jan 2023 22:42:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pCBi6-0003c6-St for bug-gnu-emacs@gnu.org; Sun, 01 Jan 2023 22:42:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pCBi6-0003KK-Gf for bug-gnu-emacs@gnu.org; Sun, 01 Jan 2023 22:42:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Jean Louis Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 02 Jan 2023 03:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60460 X-GNU-PR-Package: emacs Original-Received: via spool by 60460-submit@debbugs.gnu.org id=B60460.167263087612732 (code B ref 60460); Mon, 02 Jan 2023 03:42:02 +0000 Original-Received: (at 60460) by debbugs.gnu.org; 2 Jan 2023 03:41:16 +0000 Original-Received: from localhost ([127.0.0.1]:42193 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pCBhL-0003JH-Th for submit@debbugs.gnu.org; Sun, 01 Jan 2023 22:41:16 -0500 Original-Received: from stw1.rcdrun.com ([217.170.207.13]:46443) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pCBhJ-0003J9-TH for 60460@debbugs.gnu.org; Sun, 01 Jan 2023 22:41:14 -0500 Original-Received: from localhost ([::ffff:102.85.231.176]) (AUTH: PLAIN admin, TLS: TLS1.3,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 0000000000055D61.0000000063B2525A.00005873; Sun, 01 Jan 2023 20:41:13 -0700 Content-Disposition: inline In-Reply-To: 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:252309 Archived-At: * Ruijie Yu via "Bug reports for GNU Emacs, the Swiss army knife of text editors [2023-01-01 23:39]: > Similar to what we have for "recentf.el" today, we can have two > variables `delete-by-moving-to-trash-include' and > `delete-by-moving-to-trash-exclude', and make > `delete-by-moving-to-trash' a deprecated alias to > `delete-by-moving-to-trash-include'. In this case, we can have the > following logic: It is better keeping the variable `delete-by-moving-to-trash' as it is, and then just add different options: - If TRUE move all files to trash - If NIL, don't use trash - If 'local-only move only local files to trash - If FUNCTION filter files by FUNCTION I have not seen you closed the other bug, and that this one is active when I was answering first time, so here I repeat it: * Ruijie Yu via "Bug reports for GNU Emacs, the Swiss army knife of text editors [2023-01-01 11:37]: > I have been organizing my files lately over multiple devices using > tramp. One issue I find with my current setup is that since I set > `delete-by-moving-to-trash' to t, all files, even the remote ones, are > moved to my trash directory. Which does not make sense, and which should be user option. Look at this bug report: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=56511 Where Lars said: > As the doc string of move-file-to-trash says: > If the function `system-move-file-to-trash' is defined, call it > with FILENAME as an argument. > So just define a function that checks whether FILENAME is a Tramp > file name or not, and delete the file if it is, but trash otherwise. IMHO, in my opinion there will be always more users that know how to use M-x customize, but not know how to define functions. I don't think that decision to delete remote files to trash is user friendly in the first place, and that people using M-x customize are supposed to even understand "only when the function `system-move-file-to-trash' is not defined". Defined by who? What would that mean for somebody who is not Emacs Lisp programmer?! Probably nothing. User remains helpless here. Hide Trash Directory: Choice: Value Menu Directory: /home/data1/protected/tmp/Wastebasket/ State : SAVED and set. Directory for ‘move-file-to-trash’ to move files and directories to. Hide This directory is used only when the function ‘system-move-file-to-trash’ is not defined. Relative paths are interpreted relative to ‘default-directory’. If the value is nil, Emacs uses a freedesktop.org-style trashcan. I have define my `system-move-file-to-trash' as following, so the problem is solved individually. (defun system-move-file-to-trash (filename) "Delete only local files. This is custom local function as recommended by `move-file-to-trash'." (cond ((file-remote-p filename) (delete-file filename)) ((and trash-directory (not (string-prefix-p (directory-file-name (file-name-nondirectory (expand-file-name filename))) trash-directory))) (make-directory (file-name-as-directory trash-directory) t) (rename-file filename (file-name-as-directory trash-directory) t)) (t (when (y-or-n-p (format "Delete `%s'? ")) (delete-file filename))))) However, as you have found out, and I have found out, this problem is likely to be discovered over and over again by new Tramp users who wish to use Wastebasket. > This, unfortunately, harms my workflow because the files I wanted to > delete include some random multi-gig files, as well as many .git > directories, both of which greatly bottleneck my file-deletion process. > I also don't want to disable trashing globally, because I think putting > local files to trash (which do not introduce a significant delay) is > still a good idea. That is how I work as well. > 1. Allow the user to disable "moving to local trash" only for remote > files. I imagine this would entail allowing the user to set > `delete-by-moving-to-trash' to 'local, and modifying `delete-file', > `delete-directory', `dired-internal-do-deletions' among other functions > accordingly. Alternatively we can have a dedicated variable for this > purpose. Good ideas, I wish it could be adopted to become user friendly, one mouse click and customization and user can be sure that remote files will not be moved to local Trash. However we have to think that some users may be using only remote files and that Trash could eventually be remote as well, right? -- Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns In support of Richard M. Stallman https://stallmansupport.org/