Show
Ignore:
Timestamp:
09/09/06 16:30:10 (2 years ago)
Author:
miyoshi
Message:

Sync up with Emacs CVS HEAD.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lisp/dnd.el

    r4091 r4161  
    3838;;;###autoload 
    3939(defcustom dnd-protocol-alist 
    40   '( 
    41     ("^file:///" . dnd-open-local-file)        ; XDND format. 
    42     ("^file://"  . dnd-open-file)      ; URL with host 
    43     ("^file:"    . dnd-open-local-file)        ; Old KDE, Motif, Sun 
    44    
     40  '(("^file:///"  . dnd-open-local-file)       ; XDND format. 
     41    ("^file://"   . dnd-open-file)             ; URL with host 
     42    ("^file:"     . dnd-open-local-file)       ; Old KDE, Motif, Sun 
     43    ("^\\(https?\\|ftp\\|file\\|nfs\\)://" . dnd-open-file) 
     44   
    4545 
    4646  "The functions to call for different protocols when a drop is made. 
     
    5959  :group 'dnd) 
    6060 
     61 
     62(defcustom dnd-open-remote-file-function 
     63  (if (eq system-type 'windows-nt) 
     64      'dnd-open-unc-file 
     65    'dnd-open-remote-url) 
     66  "The function to call when opening a file on a remote machine. 
     67The function will be called with two arguments; URI and ACTION. See 
     68`dnd-open-file' for details. 
     69If nil, then dragging remote files into Emacs will result in an error. 
     70Predefined functions are `dnd-open-unc-file' and `dnd-open-remote-url'. 
     71`dnd-open-unc-file' attempts to open the file using its UNC name and is the  
     72default on MS-Windows.  `dnd-open-remote-url' uses `url-handler-mode' and 
     73is the default except for MS-Windows." 
     74  :version "22.1" 
     75  :type 'function 
     76  :group 'dnd) 
    6177 
    6278 
     
    159175      (error "Can not read %s" uri)))) 
    160176 
     177(defun dnd-open-unc-file (uri action) 
     178  "Open a remote file using its unc path. 
     179The file is opened in the current window, or a new window if 
     180`dnd-open-file-other-window' is set. URI is the url for the file, 
     181and must have the format file://hostname/file-name. ACTION is ignored. 
     182//hostname/file-name is the unc path." 
     183  (let ((unc-file (if (string-match "^file:" uri) 
     184                      (substring uri 5)))) 
     185    (if (and unc-file (file-readable-p unc-file)) 
     186        (progn 
     187          (if dnd-open-file-other-window 
     188              (find-file-other-window unc-file) 
     189            (find-file unc-file)) 
     190          'private) 
     191      (error "Invalid file url")))) 
     192 
     193(defun dnd-open-remote-url (uri action) 
     194  "Open a remote file with `find-file' and `url-handler-mode'. 
     195Turns `url-handler-mode' on if not on before.  The file is opened in the 
     196current window, or a new window if `dnd-open-file-other-window' is set. 
     197URI is the url for the file.  ACTION is ignored." 
     198  (progn 
     199    (require 'url-handlers) 
     200    (or url-handler-mode (url-handler-mode)) 
     201    (if dnd-open-file-other-window 
     202        (find-file-other-window uri) 
     203      (find-file uri)) 
     204    'private)) 
     205 
     206 
    161207(defun dnd-open-file (uri action) 
    162208  "Open a local or remote file. 
     
    170216  (let ((local-file (dnd-get-local-file-uri uri))) 
    171217    (if local-file (dnd-open-local-file local-file action) 
    172       (error "Remote files not supported")))) 
     218      (if dnd-open-remote-file-function 
     219          (funcall dnd-open-remote-file-function uri action) 
     220        (error "Remote files not supported"))))) 
    173221 
    174222