| 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 | ) |
|---|
| | 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. |
|---|
| | 67 | The function will be called with two arguments; URI and ACTION. See |
|---|
| | 68 | `dnd-open-file' for details. |
|---|
| | 69 | If nil, then dragging remote files into Emacs will result in an error. |
|---|
| | 70 | Predefined 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 |
|---|
| | 72 | default on MS-Windows. `dnd-open-remote-url' uses `url-handler-mode' and |
|---|
| | 73 | is the default except for MS-Windows." |
|---|
| | 74 | :version "22.1" |
|---|
| | 75 | :type 'function |
|---|
| | 76 | :group 'dnd) |
|---|
| | 177 | (defun dnd-open-unc-file (uri action) |
|---|
| | 178 | "Open a remote file using its unc path. |
|---|
| | 179 | The 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, |
|---|
| | 181 | and 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'. |
|---|
| | 195 | Turns `url-handler-mode' on if not on before. The file is opened in the |
|---|
| | 196 | current window, or a new window if `dnd-open-file-other-window' is set. |
|---|
| | 197 | URI 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 | |
|---|