unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Patch for remote files in dnd.el
@ 2006-07-27 22:22 Jason Rumney
  2006-07-28  7:25 ` Mathias Dahl
                   ` (5 more replies)
  0 siblings, 6 replies; 49+ messages in thread
From: Jason Rumney @ 2006-07-27 22:22 UTC (permalink / raw)
  Cc: emacs-devel


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 ----
  	  'private)
        (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)

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

end of thread, other threads:[~2006-09-15 11:01 UTC | newest]

Thread overview: 49+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-27 22:22 Patch for remote files in dnd.el Jason Rumney
2006-07-28  7:25 ` Mathias Dahl
2006-07-28 12:37   ` Jason Rumney
2006-08-01 12:10     ` Mathias Dahl
2006-07-28 10:44 ` Jan Djärv
2006-07-28 11:32   ` Jason Rumney
2006-07-28 13:34 ` Richard Stallman
2006-07-28 19:04   ` Jason Rumney
2006-07-28 22:20     ` Jason Rumney
2006-07-29 17:10       ` Stefan Monnier
2006-08-01  4:58         ` Jan Djärv
2006-08-08  9:38         ` Jan Djärv
2006-07-29  2:59     ` Richard Stallman
2006-09-06 11:15 ` Jan Djärv
2006-09-06 11:31   ` David Kastrup
2006-09-06 11:48     ` Jason Rumney
2006-09-06 11:59       ` David Kastrup
2006-09-06 12:06     ` Jan Djärv
2006-09-06 13:03       ` Reiner Steib
2006-09-06 14:25         ` Michael Albinus
2006-09-07  6:54           ` Richard Stallman
2006-09-07  7:40             ` Michael Albinus
2006-09-06 14:13       ` Michael Albinus
2006-09-07  6:54   ` Richard Stallman
2006-09-07  7:31 ` YAMAMOTO Mitsuharu
2006-09-07  8:12   ` Jason Rumney
2006-09-07  8:25     ` YAMAMOTO Mitsuharu
2006-09-07  8:56       ` Jan Djärv
2006-09-07 15:50       ` Stuart D. Herring
2006-09-08  0:56         ` YAMAMOTO Mitsuharu
2006-09-07  8:25     ` Jan Djärv
     [not found]       ` <f7ccd24b0609070236r224ce34fobb9ceb0856a3ec39@mail.gmail.com>
     [not found]         ` <44FFED66.2060806@swipnet.se>
2006-09-07 10:01           ` Jan Djärv
2006-09-07 14:13       ` Stefan Monnier
2006-09-07  8:32     ` David Kastrup
2006-09-07  8:49       ` Jason Rumney
2006-09-08 11:55         ` Richard Stallman
2006-09-08 12:43           ` Jason Rumney
2006-09-08 13:01           ` Jan Djärv
2006-09-08 16:45             ` Richard Stallman
2006-09-09  6:25               ` Jan Djärv
2006-09-08 11:55     ` Richard Stallman
2006-09-08 11:55   ` Richard Stallman
2006-09-07 23:47 ` KOBAYASHI Yasuhiro
2006-09-08  8:25   ` Jason Rumney
2006-09-08  9:09     ` YAMAMOTO Mitsuharu
2006-09-15  7:11   ` Jan Djärv
2006-09-15  9:22     ` Jason Rumney
2006-09-15  9:29       ` Jan Djärv
2006-09-15 11:01         ` Jason Rumney

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