branch: elpa/helm
commit b16f1e63b2800597c898004f3907c8d1c403f9a6
Author: Thierry Volpiatto <thie...@posteo.net>
Commit: Thierry Volpiatto <thie...@posteo.net>

    New user var helm-ff-drag-and-drop-default-directories
    
    Allow setting up a list of directories where to drag-and-drop files
    when no suitable target directory is found.
    
    Make obsolete helm-ff-drag-and-drop-default-directory.
---
 helm-files.el | 33 ++++++++++++++++++++++++---------
 helm-help.el  | 31 +++++++++++++++++++++++++++++++
 2 files changed, 55 insertions(+), 9 deletions(-)

diff --git a/helm-files.el b/helm-files.el
index 33dc1909d4..cd0982325e 100644
--- a/helm-files.el
+++ b/helm-files.el
@@ -948,6 +948,21 @@ present in this list."
 (defcustom helm-ff-dim-prompt-on-update t
   "When non nil dim prompt while updating."
   :type 'boolean)
+
+(defvaralias 'helm-ff-drag-and-drop-default-directory 
'helm-ff-drag-and-drop-default-directories
+  "Default directory where to drop files on a drag-and-drop action.
+It is used when no suitable directory is found at drop place,
+generally when dropping outside of an emacs frame.
+You want generally to set this to your home desktop directory.")
+(make-obsolete-variable 'helm-ff-drag-and-drop-default-directory
+                        'helm-ff-drag-and-drop-default-directories
+                        "4.0.3")
+
+(defcustom helm-ff-drag-and-drop-default-directories nil
+  "A list of directories where to drop files on a drag-and-drop action.
+It is used when no suitable directory is found at drop place,
+generally when dropping outside of an emacs frame."
+  :type '(repeat (choice string)))
 
 ;;; Faces
 ;;
@@ -5584,12 +5599,6 @@ Show the first `helm-ff-history-max-length' elements of
   "Default action when dragging files.
 Possible values are `copy', `rsync' or `rename'.")
 
-(defvar helm-ff-drag-and-drop-default-directory nil
-  "Default directory where to drop files on a drag-and-drop action.
-It is used when no suitable directory is found at drop place,
-generally when dropping outside of an emacs frame.
-You want generally to set this to your home desktop directory.")
-
 (defun helm-ff-drag-mouse-1-fn (event)
   "Drag-and-drop function for `helm-find-files'.
 Allows dropping marked files to another frame or window.
@@ -5597,7 +5606,7 @@ When dropping to another frame (i.e. not the selected one 
where helm
 is running), you are asked for which directory you want to drop to when frame
 displays more than one window.
 When no suitable place to drop is found ask to drop to
-`helm-ff-drag-and-drop-default-directory' if set."
+`helm-ff-drag-and-drop-default-directories' if set."
   (interactive "e")
   (cl-assert (memq helm-ff-drag-mouse-1-default-action
                    '(copy rsync rename)))
@@ -5624,11 +5633,17 @@ When no suitable place to drop is found ask to drop to
                                                  collect (cons  dir dir))))))
                         ((and (eql (window-buffer (car windows))
                                    helm-current-buffer)
-                              helm-ff-drag-and-drop-default-directory)
+                              (or helm-ff-drag-and-drop-default-directories
+                                  helm-ff-drag-and-drop-default-directory))
                          (x-popup-menu
                           t (list "Choose target"
                                   (cons ""
-                                        (list (cons it it))))))
+                                        (if (listp it)
+                                            (cl-loop for fname in it
+                                                     collect (cons fname 
fname))
+                                          ;; Handle obsolete
+                                          ;; 
helm-ff-drag-and-drop-default-directory.
+                                          (list (cons it it)))))))
                         ((car windows)
                          (with-selected-window it default-directory)))))
     (if (memq helm-ff-drag-mouse-1-default-action '(copy rsync))
diff --git a/helm-help.el b/helm-help.el
index 11e6a0abb9..85bc0779a0 100644
--- a/helm-help.el
+++ b/helm-help.el
@@ -881,6 +881,37 @@ automatically \"-e 'ssh -p 2222'\" to the rsync command 
line
 unless you have specified yourself the \"-e\" option by editing
 rsync command line with a prefix arg (see above).
 
+*** Drag and drop files from Helm
+
+When mouse support is enabled in Helm (which is the default, see
+`helm-allow-mouse') you can drag and drop files to `default-directory'
+of the buffer you drag-and-drop in.  When you drag and drop outside of
+an emacs frame, the target directory is defined by the variable
+`helm-ff-drag-and-drop-default-directories' which is a list of
+directories you can choose from, it is nil by default, customize it to
+your needs.  Tip: To trigger this from an Emacs full frame, drag to the
+border of the Emacs frame.
+
+Drag-and-drop to external applications is not supported in Helm, to
+achieve this you will have to install external application 
[[https://github.com/mwh/dragon][Dragon]]
+and use it as follow:
+
+#+begin_src elisp
+  (defun helm-ff-dragon (files)
+    \"Create a small window with FILES ready to drag and drop.
+Use this to drop files on externals applications or desktop.
+Dropping on emacs buffers with this is not supported.
+
+Needs `dragon' executable: https://github.com/mwh/dragon.\";
+    (interactive (list (helm-marked-candidates)))
+    (cl-assert (executable-find \"dragon\") nil \"Dragon executable not 
found\")
+    (apply #'call-process \"dragon\" nil nil nil \"--all\" \"--and-exit\" 
files))
+  (define-key helm-find-files-map (kbd \"C-c m\") 'helm-ff-dragon)
+#+end_src
+
+Tip: From the Dragon window, you can move your mouse to an other desktop
+where the external application you want to drag-and-drop is.
+
 *** Access files on Android phones from Helm
 
 Since Android doesn't provide anymore mass storage for USB, it is

Reply via email to