unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: master 7a5f2b79e9: ; * lisp/dired.el (dired-mouse-drag): Create local copy if file is remote.
       [not found] ` <20220330062106.D045CC01684@vcs2.savannah.gnu.org>
@ 2022-03-30  7:38   ` Michael Albinus
  2022-03-30  7:49     ` Po Lu
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Albinus @ 2022-03-30  7:38 UTC (permalink / raw)
  To: emacs-devel; +Cc: Po Lu

Po Lu via Mailing list for Emacs changes <emacs-diffs@gnu.org> writes:

Hi,

>     ; * lisp/dired.el (dired-mouse-drag): Create local copy if file is remote.
>
> +              (let ((filename (with-selected-window (posn-window
> +                                                     (event-end event))
> +                                (dired-file-name-at-point))))
> +                (when filename
> +                  ;; In theory x-dnd-username combined with a proper
> +                  ;; file URI containing the hostname of the remote
> +                  ;; server could be used here instead of creating a
> +                  ;; local copy of the remote file, but no program
> +                  ;; actually implements file DND according to the
> +                  ;; spec.
> +                  (when (file-remote-p filename)
> +                    (setq filename (file-local-copy filename)))
> +                  (gui-backend-set-selection 'XdndSelection filename)
> +                  (x-begin-drag '("text/uri-list"
> +                                  "text/x-dnd-username")
> +                                (if (eq 'dired-mouse-drag-files 'link)
> +                                    'XdndActionLink
> +                                  'XdndActionCopy)
> +                                nil nil t)))

Reading the code, it looks to me like you need to remove the local copy
later. Otherwise, it will trash your temp directory.

Best regards, Michael.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: master 7a5f2b79e9: ; * lisp/dired.el (dired-mouse-drag): Create local copy if file is remote.
  2022-03-30  7:38   ` master 7a5f2b79e9: ; * lisp/dired.el (dired-mouse-drag): Create local copy if file is remote Michael Albinus
@ 2022-03-30  7:49     ` Po Lu
  2022-03-30  8:01       ` Michael Albinus
  0 siblings, 1 reply; 4+ messages in thread
From: Po Lu @ 2022-03-30  7:49 UTC (permalink / raw)
  To: Michael Albinus; +Cc: emacs-devel

Michael Albinus <michael.albinus@gmx.de> writes:

> Hi,
>
>>     ; * lisp/dired.el (dired-mouse-drag): Create local copy if file is remote.
>>
>> +              (let ((filename (with-selected-window (posn-window
>> +                                                     (event-end event))
>> +                                (dired-file-name-at-point))))
>> +                (when filename
>> +                  ;; In theory x-dnd-username combined with a proper
>> +                  ;; file URI containing the hostname of the remote
>> +                  ;; server could be used here instead of creating a
>> +                  ;; local copy of the remote file, but no program
>> +                  ;; actually implements file DND according to the
>> +                  ;; spec.
>> +                  (when (file-remote-p filename)
>> +                    (setq filename (file-local-copy filename)))
>> +                  (gui-backend-set-selection 'XdndSelection filename)
>> +                  (x-begin-drag '("text/uri-list"
>> +                                  "text/x-dnd-username")
>> +                                (if (eq 'dired-mouse-drag-files 'link)
>> +                                    'XdndActionLink
>> +                                  'XdndActionCopy)
>> +                                nil nil t)))
>
> Reading the code, it looks to me like you need to remove the local copy
> later. Otherwise, it will trash your temp directory.

Ah, thanks.  I always thought the old file would be removed
automatically after a while (i.e. when a new file is created).

The problem is that there's no way to know when the drop target has
finished opening the file, so the best solution is probably to remove
the old file when a new file is created.

WDYT?



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: master 7a5f2b79e9: ; * lisp/dired.el (dired-mouse-drag): Create local copy if file is remote.
  2022-03-30  7:49     ` Po Lu
@ 2022-03-30  8:01       ` Michael Albinus
  2022-03-30  8:28         ` Po Lu
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Albinus @ 2022-03-30  8:01 UTC (permalink / raw)
  To: Po Lu; +Cc: emacs-devel

Po Lu <luangruo@yahoo.com> writes:

>> Reading the code, it looks to me like you need to remove the local copy
>> later. Otherwise, it will trash your temp directory.
>
> Ah, thanks.  I always thought the old file would be removed
> automatically after a while (i.e. when a new file is created).
>
> The problem is that there's no way to know when the drop target has
> finished opening the file, so the best solution is probably to remove
> the old file when a new file is created.
>
> WDYT?

You must remember the file name of the "old" local copy, because it is
random.

--8<---------------cut here---------------start------------->8---
(file-local-copy "/ssh::.emacs")
=> "/tmp/tramp.k2vQK0"
--8<---------------cut here---------------end--------------->8---

An (undocumented) possibility would be to let-bind
tramp-temp-name-prefix to something else. Then you could easily identify
your own temp files.

--8<---------------cut here---------------start------------->8---
(let ((tramp-temp-name-prefix "my-own-prefix."))
  (file-local-copy "/ssh::.emacs"))
=> "/tmp/my-own-prefix.HDfgDZ"
--8<---------------cut here---------------end--------------->8---

Best regards, Michael.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: master 7a5f2b79e9: ; * lisp/dired.el (dired-mouse-drag): Create local copy if file is remote.
  2022-03-30  8:01       ` Michael Albinus
@ 2022-03-30  8:28         ` Po Lu
  0 siblings, 0 replies; 4+ messages in thread
From: Po Lu @ 2022-03-30  8:28 UTC (permalink / raw)
  To: Michael Albinus; +Cc: emacs-devel

Michael Albinus <michael.albinus@gmx.de> writes:

> You must remember the file name of the "old" local copy, because it is
> random.
>
> (file-local-copy "/ssh::.emacs")
> => "/tmp/tramp.k2vQK0"
>
>
> An (undocumented) possibility would be to let-bind
> tramp-temp-name-prefix to something else. Then you could easily identify
> your own temp files.
>
> (let ((tramp-temp-name-prefix "my-own-prefix."))
>   (file-local-copy "/ssh::.emacs"))
> => "/tmp/my-own-prefix.HDfgDZ"
>
> Best regards, Michael.

Thanks.



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-03-30  8:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <164862126656.8211.8114609736677843326@vcs2.savannah.gnu.org>
     [not found] ` <20220330062106.D045CC01684@vcs2.savannah.gnu.org>
2022-03-30  7:38   ` master 7a5f2b79e9: ; * lisp/dired.el (dired-mouse-drag): Create local copy if file is remote Michael Albinus
2022-03-30  7:49     ` Po Lu
2022-03-30  8:01       ` Michael Albinus
2022-03-30  8:28         ` Po Lu

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).