From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Boruch Baum Newsgroups: gmane.emacs.devel Subject: Re: Friendlier dired experience [CODE INCLUDED] Date: Thu, 5 Nov 2020 03:54:40 -0500 Message-ID: <20201105085440.glvl6tzfnbtfssy5@E15-2016.optimum.net> References: <20201103104340.q34kqfita55w2u7h@E15-2016.optimum.net> <20201103171627.f33ud4xkwv6rqvcq@E15-2016.optimum.net> <87y2jifhjq.fsf@gmx.de> <20201103191043.42sdslilcmb47jg5@E15-2016.optimum.net> <87pn4sgaiy.fsf@gmx.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28634"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: NeoMutt/20180716 Cc: Stefan Kangas , Jean Louis , Emacs-Devel List To: Michael Albinus Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Nov 05 09:59:26 2020 Return-path: Envelope-to: ged-emacs-devel@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 1kab76-0007MV-KI for ged-emacs-devel@m.gmane-mx.org; Thu, 05 Nov 2020 09:59:24 +0100 Original-Received: from localhost ([::1]:56898 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kab75-00032M-B6 for ged-emacs-devel@m.gmane-mx.org; Thu, 05 Nov 2020 03:59:23 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33880) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kab39-0002JF-NX for emacs-devel@gnu.org; Thu, 05 Nov 2020 03:55:19 -0500 Original-Received: from mout.gmx.net ([212.227.17.20]:47897) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kab36-0003qr-S1 for emacs-devel@gnu.org; Thu, 05 Nov 2020 03:55:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1604566483; bh=+7gPrr6UoFs6IWIRXD1p70ycKo0349uzQbe78EhQjfc=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:References:In-Reply-To; b=PKBhNFaZrZOAgQHzi84dN24jhi7HV0OOUjGsjfX8XKkA8YukioFfCwwd3KW2J81ht AmyWY323EHLCp53P/DELA3pyStvnKXYo855+naluVUKcVlu91jd+Uh4UbMbEJGaHIa h2UwDzrEhBGOuw/mrvyfeWC1UstgO7JqtaewD4ig= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from E15-2016.optimum.net ([71.105.138.177]) by mail.gmx.com (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MqJmF-1jvzAP3W5L-00nOA8; Thu, 05 Nov 2020 09:54:43 +0100 Content-Disposition: inline In-Reply-To: <87pn4sgaiy.fsf@gmx.de> X-Provags-ID: V03:K1:e00rJhxy3UsW+nLwPenFx4vbkn79zY3TzqlneSjCAJ/gMzo7E3d skDmmXTwT+ST6xznlnKJUNTNr7/wDYKQZIGx/UavJpBM4ezLOP8A26nNNY17bH1wfJwieuJ MkIH9PHmHJLpWVwwUzcokJo7rYqp/Nrgocqw/wR4GMbWJtZzXXWRU6xG3maD7i1t6m+bnqt 8zclQeoIM0P9VQtkBQyBg== X-UI-Out-Filterresults: notjunk:1;V03:K0:26CaUXskPlQ=:GzNRC8TWFwjztTz1jW3j/h LulCghW+UE1wV1ivAWYS2Bf+yHkh2dTzfL82JNm9m7RrwbBtfhRU9v/Jz/XFGdBMoFz0YQmFJ YUSvBtNLxI28JZkldkdTDbmIjAQLDOfxKP4Fr/YscvwCLmuGpNti3eL4GTdAC6z0cufG4ikbB CaoS1o1l8AEjUwqcRefMGzvzgMyrhlSw5iM1nVC/EKY2p7aWdS0w3Vdy5p8CEBp86bmuMSOPr OJuyMglUlsoaFyz5bvSMvP2wHGz0fQSMNcFX6xH4t45Lql0XiwtJ0+FzFA/Qo1B3VZO/PLvTA U5h/G571aLDJY7dBmuKhhRZ75RN3beYSG7ybr0LtfC6qTs1s+HSQJHFxSaEueII79Qz7fwBEe h9BpWoLUIv10+cBow7KuvqQFrbkxFbM3d2yyn0TULZ8mMoH+OE8vs4fdSjtABkTBFnWtYrMpd BCSutuNvKH9kd1++bMKiDkKzWwzbSKRtR8PQjXrdUPHy1vAuou8TDfC7udEPP0l3c+0FP5Hs/ +dUHi3VVoXR4xMJuIRGU/r0IABAhl4u0Iyin9hx1vY2MAe78QSHrUyUoCwsg+kt1m+g1b3q4y gy4AMY1/TK/lxmEXidDWS1H/yh3B5K+bQpipNWmHQpMrqrOMjy0B7apQ0i9pZ3H02sxr9jcAe d2L3gLCCMw4bh7Fxil5CyRJd9Io4WkbVdg3xAp+oKyz0sdGxaFwJh0btpZ6QmwoBJ8j5w/Slh 4D8G8hoD4nUc3NOeP14ZQkUq700GeDKEsFkTxFIForHwLA54rb3aHmY2anNOUi2SdPVCdJuR Received-SPF: pass client-ip=212.227.17.20; envelope-from=boruch_baum@gmx.com; helo=mout.gmx.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/05 03:55:15 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:258713 Archived-At: On 2020-11-04 20:57, Michael Albinus wrote: > When I'm working in a remote buffer, "diredc-trash-info" does not > work. This is because you call shell-command, which runs the command on > the remote host. > > When I have trashed a file, say "/ssh:ford:/tmp/xxx", it appears as > "/home/albinus/.local/share/Trash/files/xxx", in the local trash can. > "/home/albinus/.local/share/Trash/info/xxx.trashinfo" contains the line > > Path=3D/ssh%3aford%3a/tmp/xxx > > as expected. However, "M-x diredc-trash-restore" returns with the error > > dired-rename-file: Renaming: No such file or directory, /home/albinus/.l= ocal/share/Trash/files/xxx, /ssh%3aford%3a/tmp/xxx > > I believe you must unhexlify the path in the .trashinfo. This is not > only because of Tramp. A local file "/tmp/file with space", trashed via > "M-x move-file-to-trash", has the entry > > Path=3D/tmp/file%20with%20space > > Calling "M-x diredc-trash-restore" restores it to "/tmp/file%20with%20sp= ace". I was surprised that this turned out so difficult for me to do. The very simple case for 8-bit ascii was easily handled by unhexlifying, but that simple case got me thinking about unicode file names. Sure enough, the trash meta-data for such file names are also hex encoded, but the standard elisp commands I could find wouldn't handle them. Have I overlooked something? The following code snippet performs two alternate techniques (url-unhex-string, stolen-from-emacs-w3m-url-decode-string) first for a simple case of a file name with an embedded space, and then on a unicode file name. Only the function shamelessly stolen from the emacs-w3m package worked for both cases. Tell me I've overlooked something, please. (cl-flet ((stolen-from-emacs-w3m-url-decode-string (str &optional coding regexp) (or regexp (setq regexp "%\\(?:\\([0-9a-f][0-9a-f]\\)\\|0d%0a\\)")) (let ((start 0) (case-fold-search t)) (with-temp-buffer (set-buffer-multibyte nil) (while (string-match regexp str start) (insert (substring str start (match-beginning 0)) (if (match-beginning 1) (string-to-number (match-string 1 str) 16) ?\n)) (setq start (match-end 0))) (insert (substring str start)) (decode-coding-string (buffer-string) (or (if (listp coding) (with-coding-priority coding (car (detect-coding-region (point-min) (point-max)))) coding) 'iso-8859-1)))))) (dolist (str '("hello%20world" "%d7%a9%d7%9c%d7%95%d7%9d%20%d7%a2%d7%95%d7%9c%d7%9d")) (insert (format "\n\nurl-unhex: %s\nw3m-url-decode: %s" (url-unhex-string str) (stolen-from-emacs-w3m-url-decode-string str))))) =2D- hkp://keys.gnupg.net CA45 09B5 5351 7C11 A9D1 7286 0036 9E45 1595 8BC0