unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Fwd: Preventing drag & drop the dired way
@ 2005-05-10  9:43 Reiner Steib
  2005-05-10 10:40 ` David Kastrup
  2005-05-11 13:56 ` Johan Bockgård
  0 siblings, 2 replies; 7+ messages in thread
From: Reiner Steib @ 2005-05-10  9:43 UTC (permalink / raw)


[-- Attachment #1: Type: message/rfc822, Size: 741 bytes --]

From: "oliver" <oliver_baumann@nospam.justemail.net>
Subject: Preventing drag & drop the dired way
Date: Tue, 10 May 2005 17:26:49 +1000
Message-ID: <d5pngo$2oai$1@otis.netspace.net.au>

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 

[-- Attachment #2: Type: text/plain, Size: 2102 bytes --]


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  <Reiner.Steib@gmx.de>

	* 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))
 \f
 ;; Idiosyncratic dired commands that don't deal with marks.
 
--8<---------------cut here---------------end--------------->8---

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Fwd: Preventing drag & drop the dired way
  2005-05-10  9:43 Fwd: Preventing drag & drop the dired way Reiner Steib
@ 2005-05-10 10:40 ` David Kastrup
  2005-05-11 16:27   ` Richard Stallman
  2005-05-11 13:56 ` Johan Bockgård
  1 sibling, 1 reply; 7+ messages in thread
From: David Kastrup @ 2005-05-10 10:40 UTC (permalink / raw)


Reiner Steib <reinersteib+gmane@imap.cc> writes:

> 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'.

That would appear to be a mistake: the purpose of the hook variables
is to establish user preferences at a late point in the load sequence.

> 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?

It would appear more sensible to fix the hook executation to come
last.

Actually, your patch does that, too.

It looks reasonable to me.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Fwd: Preventing drag & drop the dired way
  2005-05-10  9:43 Fwd: Preventing drag & drop the dired way Reiner Steib
  2005-05-10 10:40 ` David Kastrup
@ 2005-05-11 13:56 ` Johan Bockgård
  2005-05-12  8:30   ` Richard Stallman
  1 sibling, 1 reply; 7+ messages in thread
From: Johan Bockgård @ 2005-05-11 13:56 UTC (permalink / raw)



[dired.el]

>    (when (featurep 'dnd)
>      (make-variable-buffer-local 'dnd-protocol-alist)
>      (setq dnd-protocol-alist

I think this should be `make-local-variable'.

-- 
Johan Bockgård

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Fwd: Preventing drag & drop the dired way
  2005-05-10 10:40 ` David Kastrup
@ 2005-05-11 16:27   ` Richard Stallman
  2005-05-11 19:39     ` Reiner Steib
  0 siblings, 1 reply; 7+ messages in thread
From: Richard Stallman @ 2005-05-11 16:27 UTC (permalink / raw)
  Cc: emacs-devel

    > 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'.

    That would appear to be a mistake: the purpose of the hook variables
    is to establish user preferences at a late point in the load sequence.

Yes.  Unless there is some mysterious reason to put that after the
run-mode-hooks call, it should be moved before the run-mode-hooks
call.

Reiner's patch looks good to me too, so I think it should be installed.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Fwd: Preventing drag & drop the dired way
  2005-05-11 16:27   ` Richard Stallman
@ 2005-05-11 19:39     ` Reiner Steib
  0 siblings, 0 replies; 7+ messages in thread
From: Reiner Steib @ 2005-05-11 19:39 UTC (permalink / raw)
  Cc: Richard Stallman

On Wed, May 11 2005, Richard Stallman wrote:

> Unless there is some mysterious reason to put that after the
> run-mode-hooks call, it should be moved before the run-mode-hooks
> call.
>
> Reiner's patch looks good to me too, so I think it should be installed.

I have installed the patch along with a change of the custom type of
`dnd-protocol-alist':

--- dnd.el	11 Apr 2005 22:27:07 -0000	1.2
+++ dnd.el	11 May 2005 19:31:10 -0000
@@ -55,7 +55,7 @@
 The function shall return the action done (move, copy, link or private)
 if some action was made, or nil if the URL is ignored."
   :version "22.1"
-  :type 'alist
+  :type '(repeat (cons (regexp) (function)))
   :group 'dnd)

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Fwd: Preventing drag & drop the dired way
  2005-05-11 13:56 ` Johan Bockgård
@ 2005-05-12  8:30   ` Richard Stallman
  2005-05-12 15:53     ` Kevin Rodgers
  0 siblings, 1 reply; 7+ messages in thread
From: Richard Stallman @ 2005-05-12  8:30 UTC (permalink / raw)
  Cc: emacs-devel

    >    (when (featurep 'dnd)
    >      (make-variable-buffer-local 'dnd-protocol-alist)
    >      (setq dnd-protocol-alist

    I think this should be `make-local-variable'.

Yes.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Fwd: Preventing drag & drop the dired way
  2005-05-12  8:30   ` Richard Stallman
@ 2005-05-12 15:53     ` Kevin Rodgers
  0 siblings, 0 replies; 7+ messages in thread
From: Kevin Rodgers @ 2005-05-12 15:53 UTC (permalink / raw)


Richard Stallman wrote:
>     >    (when (featurep 'dnd)
>     >      (make-variable-buffer-local 'dnd-protocol-alist)
>     >      (setq dnd-protocol-alist
> 
>     I think this should be `make-local-variable'.
> 
> Yes.

My favorite Emacs Lisp idiom:

(set (make-local-variable 'foo) ...)

-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2005-05-12 15:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-10  9:43 Fwd: Preventing drag & drop the dired way Reiner Steib
2005-05-10 10:40 ` David Kastrup
2005-05-11 16:27   ` Richard Stallman
2005-05-11 19:39     ` Reiner Steib
2005-05-11 13:56 ` Johan Bockgård
2005-05-12  8:30   ` Richard Stallman
2005-05-12 15:53     ` Kevin Rodgers

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).