[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Patch for remote files in dnd.el

From: Jan Djärv
Subject: Re: Patch for remote files in dnd.el
Date: Wed, 06 Sep 2006 13:15:06 +0200
User-agent: Thunderbird (X11/20060808)

I think we should install this. On GNU/Linux neither Nautilus or Konqueror (file browsers for Gnome and KDE) puts the host name in files dropped. So there is basically no way a user can drop remote files onto Emacs in GNU/Linux. On W32 this restors the old behaviour of Emacs 21 AFAIK, so it is not a new feature.

        Jan D.

Richard Stallman wrote:
I don't want to add features that work only on proprietary systems.
Our goal is to replace those systems, not to enhance them.
This is a fine feature, but it needs to work on GNU/Linux before
we support it.

(Also, this feature is not urgent, and this is not the time for
new features.)

Jason Rumney wrote:
The following patch to dnd.el adds support for remote files via a new
variable dnd-open-remote-file-function.

On Windows, this defaults to the new function dnd-open-unc-file, on
other platforms it is nil, giving the old behavior. If other platforms
can receive remote files by drag and drop, then appropriate methods
for accessing them can be added (perhaps via tramp).

Any objections to installing this now?

*** dnd.el      05 Jun 2006 22:10:29 +0100      1.9
--- dnd.el      27 Jul 2006 23:14:05 +0100      
*** 59,64 ****
--- 59,78 ----
    :group 'dnd)
+ (defcustom dnd-open-remote-file-function
+   (if (eq system-type 'windows-nt)
+       'dnd-open-unc-file
+     nil)
+   "The function to call when opening a file on a remote machine.
+ The function will be called with two arguments; URI and ACTION. See
+ `dnd-open-file' for details.
+ If nil, then dragging remote files into Emacs will result in an error.
+ Predefined functions are `dnd-open-unc-file', which attempts to open
+ the file using its UNC name and is the default on MS-Windows."
+   :version "22.1"
+   :type 'function
+   :group 'dnd)
+ (defcustom dnd-open-file-other-window nil
    "If non-nil, always use find-file-other-window to open dropped files."
*** 158,163 ****
--- 172,195 ----
        (error "Can not read %s" uri))))
+ + (defun dnd-open-unc-file (uri action)
+   "Open a remote file using its unc path.
+ The file is opened in the current window, or a new window if
+ `dnd-open-file-other-window' is set. URI is the url for the file,
+ and must have the format file://hostname/file-name. ACTION is ignored.
+ //hostname/file-name is the unc path."
+   (let ((unc-file (if (string-match "^file:" uri)
+                     (substring uri 5))))
+     (if (and unc-file (file-readable-p unc-file))
+       (progn
+         (if dnd-open-file-other-window
+             (find-file-other-window unc-file)
+           (find-file unc-file))
+         'private)
+       (error "Invalid file url"))))
+ + (defun dnd-open-file (uri action)
    "Open a local or remote file.
  The file is opened in the current window, or a new window if
*** 169,175 ****
    ;; file.  Otherwise return nil.
    (let ((local-file (dnd-get-local-file-uri uri)))
      (if local-file (dnd-open-local-file local-file action)
!       (error "Remote files not supported"))))
(defun dnd-insert-text (window action text)
--- 201,209 ----
    ;; file.  Otherwise return nil.
    (let ((local-file (dnd-get-local-file-uri uri)))
      (if local-file (dnd-open-local-file local-file action)
!       (if dnd-open-remote-file-function
!         (funcall dnd-open-remote-file-function uri action)
!       (error "Remote files not supported")))))
(defun dnd-insert-text (window action text)

Emacs-devel mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]