Mercurial > emacs
annotate lisp/dnd.el @ 72687:eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
(dnd-open-remote-url): New function.
(dnd-open-remote-file-function): Set to dnd-open-remote-url if
not windows-nt.
2006-09-07 Jason Rumney <jasonr@gnu.org>
* dnd.el (dnd-open-remote-file-function): New variable.
(dnd-open-unc-file): New function.
(dnd-open-file): Call dnd-open-remote-file-function if set.
author | Jan Djärv <jan.h.d@swipnet.se> |
---|---|
date | Thu, 07 Sep 2006 07:44:33 +0000 |
parents | eca94c558ceb |
children | 3ff56e45c67f |
rev | line source |
---|---|
61479 | 1 ;;; dnd.el --- drag and drop support. |
2 | |
68651
3bd95f4f2941
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65582
diff
changeset
|
3 ;; Copyright (C) 2005, 2006 Free Software Foundation, Inc. |
61479 | 4 |
5 ;; Author: Jan Dj,Ad(Brv <jan.h.d@swipnet.se> | |
6 ;; Maintainer: FSF | |
7 ;; Keywords: window, drag, drop | |
8 | |
9 ;; This file is part of GNU Emacs. | |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
13 ;; the Free Software Foundation; either version 2, or (at your option) | |
14 ;; any later version. | |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
64091 | 23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
24 ;; Boston, MA 02110-1301, USA. | |
61479 | 25 |
26 ;;; Commentary: | |
27 | |
28 ;; This file provides the generic handling of the drop part only. | |
29 ;; Different DND backends (X11, W32, etc.) that handle the platform | |
30 ;; specific DND parts call the functions here to do final delivery of | |
31 ;; a drop. | |
32 | |
33 ;;; Code: | |
34 | |
35 ;;; Customizable variables | |
36 | |
72687
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
37 (eval-when-compile |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
38 (require 'url-handlers)) |
61479 | 39 |
62311
a8f10a069bde
(dnd-protocol-alist): Add autoload.
Richard M. Stallman <rms@gnu.org>
parents:
62240
diff
changeset
|
40 ;;;###autoload |
61479 | 41 (defcustom dnd-protocol-alist |
72687
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
42 '(("^file:///" . dnd-open-local-file) ; XDND format. |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
43 ("^file://" . dnd-open-file) ; URL with host |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
44 ("^file:" . dnd-open-local-file) ; Old KDE, Motif, Sun |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
45 ("^\\(https?\\|ftp\\|file\\|nfs\\)://" . dnd-open-file) |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
46 ) |
61479 | 47 |
48 "The functions to call for different protocols when a drop is made. | |
49 This variable is used by `dnd-handle-one-url' and `dnd-handle-file-name'. | |
50 The list contains of (REGEXP . FUNCTION) pairs. | |
51 The functions shall take two arguments, URL, which is the URL dropped and | |
52 ACTION which is the action to be performed for the drop (move, copy, link, | |
53 private or ask). | |
54 If no match is found here, and the value of `browse-url-browser-function' | |
55 is a pair of (REGEXP . FUNCTION), those regexps are tried for a match. | |
56 If no match is found, the URL is inserted as text by calling `dnd-insert-text'. | |
57 The function shall return the action done (move, copy, link or private) | |
58 if some action was made, or nil if the URL is ignored." | |
59 :version "22.1" | |
62240
19d278c4224b
* dnd.el (dnd-protocol-alist): Improve custom type.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
61482
diff
changeset
|
60 :type '(repeat (cons (regexp) (function))) |
61479 | 61 :group 'dnd) |
62 | |
63 | |
72687
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
64 (defcustom dnd-open-remote-file-function |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
65 (if (eq system-type 'windows-nt) |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
66 'dnd-open-unc-file |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
67 'dnd-open-remote-url) |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
68 "The function to call when opening a file on a remote machine. |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
69 The function will be called with two arguments; URI and ACTION. See |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
70 `dnd-open-file' for details. |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
71 If nil, then dragging remote files into Emacs will result in an error. |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
72 Predefined functions are `dnd-open-unc-file' and `dnd-open-remote-url'. |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
73 `dnd-open-unc-file' attempts to open the file using its UNC name and is the |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
74 default on MS-Windows. `dnd-open-remote-url' uses `url-handler-mode' and |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
75 is the default except for MS-Windows." |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
76 :version "22.1" |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
77 :type 'function |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
78 :group 'dnd) |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
79 |
61479 | 80 |
81 (defcustom dnd-open-file-other-window nil | |
82 "If non-nil, always use find-file-other-window to open dropped files." | |
83 :version "22.1" | |
84 :type 'boolean | |
85 :group 'dnd) | |
86 | |
87 | |
88 ;; Functions | |
89 | |
70760
eca94c558ceb
(dnd-handle-one-url): Change 3rd arg ARG to URL. Don't unescape URL.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
68651
diff
changeset
|
90 (defun dnd-handle-one-url (window action url) |
61479 | 91 "Handle one dropped url by calling the appropriate handler. |
92 The handler is first located by looking at `dnd-protocol-alist'. | |
93 If no match is found here, and the value of `browse-url-browser-function' | |
94 is a pair of (REGEXP . FUNCTION), those regexps are tried for a match. | |
95 If no match is found, just call `dnd-insert-text'. | |
96 WINDOW is where the drop happend, ACTION is the action for the drop, | |
70760
eca94c558ceb
(dnd-handle-one-url): Change 3rd arg ARG to URL. Don't unescape URL.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
68651
diff
changeset
|
97 URL is what has been dropped. |
61479 | 98 Returns ACTION." |
99 (require 'browse-url) | |
70760
eca94c558ceb
(dnd-handle-one-url): Change 3rd arg ARG to URL. Don't unescape URL.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
68651
diff
changeset
|
100 (let (ret) |
61479 | 101 (or |
102 (catch 'done | |
103 (dolist (bf dnd-protocol-alist) | |
70760
eca94c558ceb
(dnd-handle-one-url): Change 3rd arg ARG to URL. Don't unescape URL.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
68651
diff
changeset
|
104 (when (string-match (car bf) url) |
eca94c558ceb
(dnd-handle-one-url): Change 3rd arg ARG to URL. Don't unescape URL.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
68651
diff
changeset
|
105 (setq ret (funcall (cdr bf) url action)) |
61479 | 106 (throw 'done t))) |
107 nil) | |
108 (when (not (functionp browse-url-browser-function)) | |
109 (catch 'done | |
110 (dolist (bf browse-url-browser-function) | |
70760
eca94c558ceb
(dnd-handle-one-url): Change 3rd arg ARG to URL. Don't unescape URL.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
68651
diff
changeset
|
111 (when (string-match (car bf) url) |
61479 | 112 (setq ret 'private) |
70760
eca94c558ceb
(dnd-handle-one-url): Change 3rd arg ARG to URL. Don't unescape URL.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
68651
diff
changeset
|
113 (funcall (cdr bf) url action) |
61479 | 114 (throw 'done t))) |
115 nil)) | |
116 (progn | |
70760
eca94c558ceb
(dnd-handle-one-url): Change 3rd arg ARG to URL. Don't unescape URL.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
68651
diff
changeset
|
117 (dnd-insert-text window action url) |
61479 | 118 (setq ret 'private))) |
119 ret)) | |
120 | |
121 | |
122 (defun dnd-get-local-file-uri (uri) | |
123 "Return an uri converted to file:/// syntax if uri is a local file. | |
124 Return nil if URI is not a local file." | |
125 | |
126 ;; The hostname may be our hostname, in that case, convert to a local | |
127 ;; file. Otherwise return nil. TODO: How about an IP-address as hostname? | |
128 (let ((hostname (when (string-match "^file://\\([^/]*\\)" uri) | |
129 (downcase (match-string 1 uri)))) | |
130 (system-name-no-dot | |
131 (downcase (if (string-match "^[^\\.]+" system-name) | |
132 (match-string 0 system-name) | |
133 system-name)))) | |
134 (when (and hostname | |
135 (or (string-equal "localhost" hostname) | |
136 (string-equal (downcase system-name) hostname) | |
137 (string-equal system-name-no-dot hostname))) | |
138 (concat "file://" (substring uri (+ 7 (length hostname))))))) | |
139 | |
140 (defun dnd-get-local-file-name (uri &optional must-exist) | |
141 "Return file name converted from file:/// or file: syntax. | |
142 URI is the uri for the file. If MUST-EXIST is given and non-nil, | |
143 only return non-nil if the file exists. | |
144 Return nil if URI is not a local file." | |
145 (let ((f (cond ((string-match "^file:///" uri) ; XDND format. | |
146 (substring uri (1- (match-end 0)))) | |
147 ((string-match "^file:" uri) ; Old KDE, Motif, Sun | |
148 (substring uri (match-end 0)))))) | |
149 (when (and f must-exist) | |
70760
eca94c558ceb
(dnd-handle-one-url): Change 3rd arg ARG to URL. Don't unescape URL.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
68651
diff
changeset
|
150 (setq f (replace-regexp-in-string |
eca94c558ceb
(dnd-handle-one-url): Change 3rd arg ARG to URL. Don't unescape URL.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
68651
diff
changeset
|
151 "%[A-Z0-9][A-Z0-9]" |
eca94c558ceb
(dnd-handle-one-url): Change 3rd arg ARG to URL. Don't unescape URL.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
68651
diff
changeset
|
152 (lambda (arg) |
eca94c558ceb
(dnd-handle-one-url): Change 3rd arg ARG to URL. Don't unescape URL.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
68651
diff
changeset
|
153 (format "%c" (string-to-number (substring arg 1) 16))) |
eca94c558ceb
(dnd-handle-one-url): Change 3rd arg ARG to URL. Don't unescape URL.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
68651
diff
changeset
|
154 f nil t)) |
61479 | 155 (let* ((decoded-f (decode-coding-string |
156 f | |
157 (or file-name-coding-system | |
158 default-file-name-coding-system))) | |
159 (try-f (if (file-readable-p decoded-f) decoded-f f))) | |
160 (when (file-readable-p try-f) try-f))))) | |
161 | |
162 | |
163 (defun dnd-open-local-file (uri action) | |
164 "Open a local file. | |
165 The file is opened in the current window, or a new window if | |
166 `dnd-open-file-other-window' is set. URI is the url for the file, | |
167 and must have the format file:file-name or file:///file-name. | |
168 The last / in file:/// is part of the file name. ACTION is ignored." | |
169 | |
170 (let* ((f (dnd-get-local-file-name uri t))) | |
171 (if (and f (file-readable-p f)) | |
172 (progn | |
173 (if dnd-open-file-other-window | |
174 (find-file-other-window f) | |
175 (find-file f)) | |
176 'private) | |
177 (error "Can not read %s" uri)))) | |
178 | |
72687
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
179 (defun dnd-open-unc-file (uri action) |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
180 "Open a remote file using its unc path. |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
181 The file is opened in the current window, or a new window if |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
182 `dnd-open-file-other-window' is set. URI is the url for the file, |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
183 and must have the format file://hostname/file-name. ACTION is ignored. |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
184 //hostname/file-name is the unc path." |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
185 (let ((unc-file (if (string-match "^file:" uri) |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
186 (substring uri 5)))) |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
187 (if (and unc-file (file-readable-p unc-file)) |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
188 (progn |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
189 (if dnd-open-file-other-window |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
190 (find-file-other-window unc-file) |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
191 (find-file unc-file)) |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
192 'private) |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
193 (error "Invalid file url")))) |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
194 |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
195 (defun dnd-open-remote-url (uri action) |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
196 "Open a remote file with `find-file' and `url-handler-mode'. |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
197 Turns `url-handler-mode' on if not on before. The file is opened in the |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
198 current window, or a new window if `dnd-open-file-other-window' is set. |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
199 URI is the url for the file. ACTION is ignored." |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
200 (progn |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
201 (or url-handler-mode (url-handler-mode)) |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
202 (if dnd-open-file-other-window |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
203 (find-file-other-window uri) |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
204 (find-file uri)) |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
205 'private)) |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
206 |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
207 |
61479 | 208 (defun dnd-open-file (uri action) |
209 "Open a local or remote file. | |
210 The file is opened in the current window, or a new window if | |
211 `dnd-open-file-other-window' is set. URI is the url for the file, | |
212 and must have the format file://hostname/file-name. ACTION is ignored. | |
213 The last / in file://hostname/ is part of the file name." | |
214 | |
215 ;; The hostname may be our hostname, in that case, convert to a local | |
216 ;; file. Otherwise return nil. | |
217 (let ((local-file (dnd-get-local-file-uri uri))) | |
218 (if local-file (dnd-open-local-file local-file action) | |
72687
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
219 (if dnd-open-remote-file-function |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
220 (funcall dnd-open-remote-file-function uri action) |
eedaad0e9f80
* dnd.el (dnd-protocol-alist): Add what url-handler-mode can handle.
Jan Djärv <jan.h.d@swipnet.se>
parents:
70760
diff
changeset
|
221 (error "Remote files not supported"))))) |
61479 | 222 |
223 | |
224 (defun dnd-insert-text (window action text) | |
225 "Insert text at point or push to the kill ring if buffer is read only. | |
226 TEXT is the text as a string, WINDOW is the window where the drop happened." | |
227 (if (or buffer-read-only | |
228 (not (windowp window))) | |
229 (progn | |
230 (kill-new text) | |
65582
4d1085b02d64
Message format spec fixes (1)
Deepak Goel <deego@gnufans.org>
parents:
64762
diff
changeset
|
231 (message "%s" |
61479 | 232 (substitute-command-keys |
233 "The dropped text can be accessed with \\[yank]"))) | |
234 (insert text)) | |
235 action) | |
236 | |
237 | |
238 (provide 'dnd) | |
239 | |
61482 | 240 ;; arch-tag: 0472f6a5-2e8f-4304-9e44-1a0877c771b7 |
61479 | 241 ;;; dnd.el ends here |