From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jason Rumney Newsgroups: gmane.emacs.devel Subject: Patch for remote files in dnd.el Date: Thu, 27 Jul 2006 23:22:28 +0100 Message-ID: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1154039085 28852 80.91.229.2 (27 Jul 2006 22:24:45 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 27 Jul 2006 22:24:45 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jul 28 00:24:44 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1G6EHV-0005kz-Rq for ged-emacs-devel@m.gmane.org; Fri, 28 Jul 2006 00:24:38 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1G6EHV-0002GA-AN for ged-emacs-devel@m.gmane.org; Thu, 27 Jul 2006 18:24:37 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1G6EHL-0002G5-5m for emacs-devel@gnu.org; Thu, 27 Jul 2006 18:24:27 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1G6EHI-0002Ft-DV for emacs-devel@gnu.org; Thu, 27 Jul 2006 18:24:25 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1G6EHI-0002Fq-Al for emacs-devel@gnu.org; Thu, 27 Jul 2006 18:24:24 -0400 Original-Received: from [194.106.33.237] (helo=outmail.freedom2surf.net) by monty-python.gnu.org with esmtp (Exim 4.52) id 1G6EJ9-000817-32 for emacs-devel@gnu.org; Thu, 27 Jul 2006 18:26:19 -0400 Original-Received: from wanchan.jasonrumney.net (i-83-67-23-108.freedom2surf.net [83.67.23.108]) by outmail.freedom2surf.net (Postfix) with ESMTP id 8A34091A4F; Thu, 27 Jul 2006 23:24:22 +0100 (BST) Original-Received: from TONKOTSU-RAMEN (tonkotsu-ramen.jasonrumney.net [10.0.0.28]) by wanchan.jasonrumney.net (Postfix) with ESMTP id 3CEDF5A3; Thu, 27 Jul 2006 23:24:22 +0100 (BST) Original-To: Jan =?iso-8859-1?Q?Dj=E4rv?= X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:57699 Archived-At: 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)