all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Boruch Baum <boruch_baum@gmx.com>
To: Michael Albinus <michael.albinus@gmx.de>
Cc: Stefan Kangas <stefankangas@gmail.com>,
	Jean Louis <bugs@gnu.support>,
	Emacs-Devel List <emacs-devel@gnu.org>
Subject: Re: Friendlier dired experience [CODE INCLUDED]
Date: Thu, 5 Nov 2020 03:54:40 -0500	[thread overview]
Message-ID: <20201105085440.glvl6tzfnbtfssy5@E15-2016.optimum.net> (raw)
In-Reply-To: <87pn4sgaiy.fsf@gmx.de>

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=/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/.local/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=/tmp/file%20with%20space
>
> Calling "M-x diredc-trash-restore" restores it to "/tmp/file%20with%20space".

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)))))

--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0



  parent reply	other threads:[~2020-11-05  8:54 UTC|newest]

Thread overview: 95+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-03 10:43 Friendlier dired experience [CODE INCLUDED] Boruch Baum
2020-11-03 10:54 ` Jean Louis
2020-11-03 11:15   ` Boruch Baum
2020-11-03 11:32     ` Joost Kremers
2020-11-03 12:22       ` Boruch Baum
2020-11-03 16:07     ` Jean Louis
2020-11-03 17:12       ` Boruch Baum
2020-11-03 19:31         ` Jean Louis
2020-11-03 21:13           ` Boruch Baum
2020-11-04  8:10             ` Jean Louis
2020-11-04  8:54               ` Boruch Baum
2020-11-04  9:57                 ` Jean Louis
2020-11-04 10:39                   ` Jean Louis
2020-11-04 13:17                     ` Boruch Baum
2020-11-04 15:32                       ` Joost Kremers
2020-11-04 15:58                         ` Stefan Monnier
2020-11-04 17:23                         ` Jean Louis
2020-11-04 17:15                       ` Jean Louis
2020-11-04 15:28                 ` Eli Zaretskii
2020-11-03 11:24   ` Boruch Baum
2020-11-03 15:10 ` Stefan Kangas
2020-11-03 16:10   ` Jean Louis
2020-11-03 17:16     ` Boruch Baum
2020-11-03 17:59       ` Michael Albinus
2020-11-03 19:10         ` Boruch Baum
2020-11-03 19:49           ` Jean Louis
2020-11-04  6:08             ` Pankaj Jangid
2020-11-04 19:57           ` Michael Albinus
2020-11-04 20:18             ` Yuri Khan
2020-11-04 20:29               ` Michael Albinus
2020-11-05  8:54             ` Boruch Baum [this message]
2020-11-05 10:11               ` Jean Louis
2020-11-05 13:31               ` Eli Zaretskii
2020-11-04 19:28       ` Stefan Kangas
2020-11-04 19:39         ` Boruch Baum
2020-11-05 15:00           ` Stefan Kangas
2020-11-06  9:34             ` Boruch Baum
2020-11-04 18:07 ` Stefan Monnier
2020-11-04 18:32   ` Boruch Baum
2020-11-04 18:55     ` Stefan Monnier
2020-11-05  8:05       ` Arthur Miller
2020-11-05  9:22         ` Boruch Baum
2020-11-05 12:54           ` Arthur Miller
2020-11-05 13:34             ` Jean Louis
2020-11-05 14:38             ` Boruch Baum
2020-11-05 15:05               ` Stefan Monnier
2020-11-05 15:34                 ` Arthur Miller
2020-11-05 15:45                   ` Stefan Monnier
2020-11-05 16:18                     ` Adam Porter
2020-11-05 17:02                       ` Stefan Monnier
2020-11-05 17:09                         ` Drew Adams
2020-11-05 17:08                       ` Drew Adams
2020-11-05 16:19                     ` Arthur Miller
2020-11-05 17:56                       ` Jean Louis
2020-11-05 17:08                     ` Drew Adams
2020-11-06  9:15                 ` Boruch Baum
2020-11-06 14:14                   ` Stefan Monnier
2020-11-06 16:28                   ` Drew Adams
2020-11-06 19:43                     ` Adam Porter
2020-11-06 20:24                       ` Drew Adams
2020-11-06 20:57                         ` Adam Porter
2020-11-07  0:30                           ` Daniel Martín
2020-11-08  9:36                     ` Boruch Baum
2020-11-08 12:09                       ` Arthur Miller
2020-11-08 12:40                         ` Boruch Baum
2020-11-08 13:37                           ` Jean Louis
2020-11-08 16:48                             ` Drew Adams
2020-11-08 18:26                               ` on hyperlinks (bookmarks) Jean Louis
2020-11-08 19:47                                 ` Drew Adams
2020-11-08 20:26                                   ` Jean Louis
2020-11-08 13:45                           ` Friendlier dired experience [CODE INCLUDED] Arthur Miller
2020-11-08 16:48                       ` Drew Adams
2020-11-08 17:37                         ` Boruch Baum
2020-11-08 19:24                           ` Drew Adams
2020-11-05 15:29               ` Arthur Miller
2020-11-05 16:25                 ` Adam Porter
2020-11-05 16:47                   ` Arthur Miller
2020-11-05 18:00                   ` Jean Louis
2020-11-05 18:56                     ` Adam Porter
2020-11-05 19:33                       ` Jean Louis
2020-11-06  4:55                     ` Arthur Miller
2020-11-06  9:49                 ` Boruch Baum
2020-11-06  9:42             ` Boruch Baum
2020-11-05 14:21           ` Stefan Monnier
2020-11-05  9:56         ` Jean Louis
2020-11-05 17:07         ` Drew Adams
2020-11-08 19:46         ` Juri Linkov
2020-11-08 19:50           ` Sv: " arthur miller
2020-11-09 22:45 ` Mathias Dahl
2020-11-09 23:20   ` Stefan Monnier
2020-11-10  0:05     ` Drew Adams
2020-11-10  2:31     ` T.V Raman
2020-11-10  6:47       ` Jean Louis
2020-11-11 19:23   ` Juri Linkov
  -- strict thread matches above, loose matches on Subject: below --
2020-11-04 17:28 Boruch Baum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201105085440.glvl6tzfnbtfssy5@E15-2016.optimum.net \
    --to=boruch_baum@gmx.com \
    --cc=bugs@gnu.support \
    --cc=emacs-devel@gnu.org \
    --cc=michael.albinus@gmx.de \
    --cc=stefankangas@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.