|
| From: | Reiner Steib |
| Subject: | Fwd: Preventing drag & drop the dired way |
| Date: | Tue, 10 May 2005 11:43:44 +0200 |
| User-agent: | Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
--- Begin Message ---Subject: Preventing drag & drop the dired way Date: Tue, 10 May 2005 17:26:49 +1000 Hi there, normally, if I drag a file onto an Emacs session Emacs opens the file. But sometimes, such as when the window with focus happens to contain a dired buffer something else happens. dired will attempt to copy the file to it's current directory. C-h k always reports w32-drag-n-drop which says nothing about moving or copying a file. Is there an easy way to cause Emacs to always open the file I drag onto it no matter what buffer happens to be displayed? thanks, olli
--- End Message ---
Hi,
I would have suggested to use `dired-mode-hook' to reset the dnd
variables to their standard values. But this won't work because the
DND setup is done after running the hooks in `dired-mode'.
I think it is reasonable that a user prefers to have the default drop
behavior in dired. Shouldn't we have an option for this? I'd suggest
the following patch. Okay to install?
2005-05-10 Reiner Steib <address@hidden>
* dired.el (dired-dnd-protocol-alist): New variable.
(dired-mode): Use `dired-dnd-protocol-alist'.
--8<---------------cut here---------------start------------->8---
--- dired.el 12 Apr 2005 11:50:24 +0200 1.307
+++ dired.el 10 May 2005 11:36:53 +0200
@@ -200,6 +200,18 @@
;; Note this can't simply be run inside function `dired-ls' as the hook
;; functions probably depend on the dired-subdir-alist to be OK.
+(defcustom dired-dnd-protocol-alist
+ '(("^file:///" . dired-dnd-handle-local-file)
+ ("^file://" . dired-dnd-handle-file)
+ ("^file:" . dired-dnd-handle-local-file))
+ "The functions to call when a drop in `dired-mode' is made.
+See `dnd-protocol-alist' for more information. When nil, behave
+as in other buffers."
+ :type '(choice (repeat (cons (regexp) (function)))
+ (const :tag "Behave as in other buffers" nil))
+ :version "22.1"
+ :group 'dired)
+
;; Internal variables
(defvar dired-marker-char ?* ; the answer is 42
@@ -1522,14 +1534,11 @@
'dired-desktop-buffer-misc-data)
(setq dired-switches-alist nil)
(dired-sort-other dired-actual-switches t)
- (run-mode-hooks 'dired-mode-hook)
(when (featurep 'dnd)
(make-variable-buffer-local 'dnd-protocol-alist)
(setq dnd-protocol-alist
- (append '(("^file:///" . dired-dnd-handle-local-file)
- ("^file://" . dired-dnd-handle-file)
- ("^file:" . dired-dnd-handle-local-file))
- dnd-protocol-alist))))
+ (append dired-dnd-protocol-alist dnd-protocol-alist)))
+ (run-mode-hooks 'dired-mode-hook))
;; Idiosyncratic dired commands that don't deal with marks.
--8<---------------cut here---------------end--------------->8---
| [Prev in Thread] | Current Thread | [Next in Thread] |