branch: elpa/helm
commit 6e218b610027552f836968be497df360d278b544
Author: Thierry Volpiatto <[email protected]>
Commit: Thierry Volpiatto <[email protected]>
Remove support for drag and drop for emacs<29.1
HFF use now dnd for its drag-and-drop fn (helm-ff-mouse-drag).
The variables helm-ff-drag-and-drop-default-directory and
helm-ff-drag-and-drop-default-directories have been removed.
---
helm-core.el | 2 +-
helm-files.el | 113 ++++++++++++----------------------------------------------
helm-help.el | 14 ++------
3 files changed, 26 insertions(+), 103 deletions(-)
diff --git a/helm-core.el b/helm-core.el
index 4c143fd263..da63503ae1 100644
--- a/helm-core.el
+++ b/helm-core.el
@@ -5427,7 +5427,7 @@ specified as respectively `helm-cand-num' and
`helm-cur-source'."
(let ((inhibit-read-only t)
(map (get-text-property pos 'keymap)))
(when map
- (define-key map [drag-mouse-1] helm-drag-mouse-1-fn)
+ (define-key map [down-mouse-1] helm-drag-mouse-1-fn)
(define-key map [mouse-2] 'helm-maybe-exit-minibuffer)
(put-text-property
helm-selection-point
diff --git a/helm-files.el b/helm-files.el
index fdc11b258b..15f20e6b48 100644
--- a/helm-files.el
+++ b/helm-files.el
@@ -97,6 +97,7 @@
(declare-function helm-epa-collect-keys-from-candidates "helm-epa")
(declare-function async-byte-compile-file "async-bytecomp.el")
(declare-function async-byte-recompile-directory "async-bytecomp.el")
+(declare-function dnd-begin-drag-files "dnd.el")
(defvar term-char-mode-point-at-process-mark)
(defvar term-char-mode-buffer-read-only)
@@ -949,34 +950,13 @@ present in this list."
"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 '(history . 10)
- "Directories where to drop files on a drag-and-drop action.
-Can be a list of directories, or a cons cell (history . <n>) where <n> is the
-first <n> directories of `helm-ff-history'.
-It is used when no suitable directory is found at drop place,
-generally when dropping outside of an emacs frame."
- :type '(choice
- (cons
- (const :tag "History" history)
- integer)
- (repeat string)))
-
(defcustom helm-ff-drag-mouse-1-default-action 'copy
"Default action when dragging files.
-Possible values are `copy', `rsync' or `rename'."
+Possible values are `copy', `move' or `link'."
:type '(choice
(const :tag "Copy" copy)
- (const :tag "Rsync" rsync)
- (const :tag "Move" rename)))
+ (const :tag "Move" move)
+ (const :tag "Link" link)))
;;; Faces
;;
@@ -5610,73 +5590,23 @@ Show the first `helm-ff-history-max-length' elements of
helm-ff-history))))
(put 'helm-find-files-history 'helm-only t)
-(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.
-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-directories' if set."
+;; The `helm-drag-mouse-1-fn' for helm-find-files, see
+;; `helm--bind-mouse-for-selection'. It react when dropping, not dragging so
+;; `helm-drag-mouse-1-fn' is bound to <down-mouse-1> and not <drag-mouse-1>.
+(defun helm-ff-mouse-drag (_event)
+ "The drag-an-drop function for helm-find-files.
+
+Drag-and-drop marked files."
(interactive "e")
- (cl-assert (memq helm-ff-drag-mouse-1-default-action
- '(copy rsync rename)))
- ;; Prevent marking when moving mouse.
+ (require 'dnd)
(when mark-active (deactivate-mark))
- (let* ((win-or-frame (posn-window (event-end event)))
- (target-frame (when (framep win-or-frame)
- (car (mouse-pixel-position))))
- (target (with-selected-window
- (if target-frame
- (frame-selected-window target-frame)
- win-or-frame)
- default-directory))
- (windows (and target-frame
- (remove (helm-window)
- (window-list target-frame 1)))))
- (when windows
- (setq target
- (helm-acond ((cdr windows)
- (x-popup-menu
- t (list "Choose target"
- (cons ""
- (cl-loop for win in windows
- for dir =
(with-selected-window
- win
default-directory)
- collect (cons dir dir))))))
- ((and (eql (window-buffer (car windows))
- helm-current-buffer)
- (or helm-ff-drag-and-drop-default-directories
- helm-ff-drag-and-drop-default-directory))
- (when (and (eq (car it) 'history)
- (numberp (cdr it)))
- (setq it (helm-take
- (remove helm-ff-default-directory
- (helm-fast-remove-dups
- helm-ff-history :test 'equal))
- (cdr it))))
- (x-popup-menu
- t (list "Choose target"
- (cons ""
- (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))
- (unwind-protect
- (helm-find-files-do-action
- helm-ff-drag-mouse-1-default-action target)
- ;; Retrieve focus after dropping
- (with-selected-frame helm-initial-frame
- (select-window (minibuffer-window))
- (force-mode-line-update t)))
- (helm-run-after-exit
- #'helm-find-files-do-action
- helm-ff-drag-mouse-1-default-action target))))
+ (let ((action helm-ff-drag-mouse-1-default-action))
+ (with-helm-window
+ (condition-case err
+ (let ((files (helm-marked-candidates)))
+ (dnd-begin-drag-files files nil action t))
+ (error (user-error (cadr err)))))))
+(put 'helm-ff-mouse-drag 'helm-only t)
(defun helm-find-files-1 (fname &optional preselect)
"Find FNAME filename with PRESELECT filename preselected.
@@ -5704,8 +5634,9 @@ Use it for non-interactive calls of `helm-find-files'."
;; Ensure not being prompted for password each time we
;; navigate to a directory.
(password-cache t))
- (helm-set-local-variable 'helm-follow-mode-persistent nil
- 'helm-drag-mouse-1-fn 'helm-ff-drag-mouse-1-fn)
+ (helm-set-local-variable 'helm-follow-mode-persistent nil)
+ (when (fboundp 'dnd-begin-drag-files)
+ (helm-set-local-variable 'helm-drag-mouse-1-fn 'helm-ff-mouse-drag))
(unless helm-source-find-files
(setq helm-source-find-files (helm-make-source
"Find Files" 'helm-source-ffiles)))
diff --git a/helm-help.el b/helm-help.el
index 294c58ca84..2a20eb3c14 100644
--- a/helm-help.el
+++ b/helm-help.el
@@ -885,21 +885,13 @@ rsync command line with a prefix arg (see above).
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 or the first <n> elements of
-`helm-ff-history' you specify with a cons cell where the first element
-is the symbol =history= and the second an integer, it is '(history . 10)
-by default, customize it to your needs. Tip: To trigger this from an
-Emacs full frame, drag to the border of the Emacs frame.
+of the buffer you drag-and-drop in or in an external application.
By default Helm copy files when using drag-and-drop, you can customize
`helm-ff-drag-mouse-1-default-action' to modify this.
-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:
+To drag-and-drop to external applications you can also use the
+external application [[https://github.com/mwh/dragon][Dragon]] and use it as
follow:
#+begin_src elisp
(defun helm-ff-dragon (files)