branch: elpa/helm commit edfbe48205db5a03c7d0dbdd623702c9a3117ab7 Author: Thierry Volpiatto <thie...@posteo.net> Commit: Thierry Volpiatto <thie...@posteo.net>
Handle REQUIRE-MATCH from helm-ff-RET When helm-ff-RET is used from helm-read-file-name and MUST-MATCH is t we have no dummy source to handle this so instead of returning an error send a minibuffer-message and exit. Remove the must-match argument of helm-ff-RET-1 and the unused function helm-ff-RET-must-match. --- helm-core.el | 6 ++++-- helm-files.el | 52 ++++++++++++++++++++++++---------------------------- 2 files changed, 28 insertions(+), 30 deletions(-) diff --git a/helm-core.el b/helm-core.el index 6399049267..ff31a68021 100644 --- a/helm-core.el +++ b/helm-core.el @@ -196,9 +196,11 @@ window handling a buffer, it is this one we store.") "[INTERNAL] Recenter when deleting minibuffer-contents and preselecting. This is a flag used internally.") (defvar helm--minibuffer-completing-file-name nil - "A flag notifying Helm is in file completion. + "[INTERNAL] A flag notifying Helm is in file completion. It is let-bounded in `helm-read-file-name'. Same as -`minibuffer-completing-file-name' but doesn't affect `file-directory-p'.") +`minibuffer-completing-file-name' but doesn't affect `file-directory-p' when +called on remote files. +WARN: Use this only in `helm-read-file-name'.") ;;; Multi keys ;; diff --git a/helm-files.el b/helm-files.el index 2f5f6dc6ea..87900e31a2 100644 --- a/helm-files.el +++ b/helm-files.el @@ -2611,29 +2611,30 @@ at end of pattern using \\<helm-map>\\[backward-char] and (setq helm-ff--deleting-char-backward nil)) (defvar helm-ff--RET-disabled nil) -(defun helm-ff-RET-1 (&optional must-match) - "Used for RET action in `helm-find-files'. -See `helm-ff-RET' for details. -If MUST-MATCH is specified exit with -`helm-confirm-and-exit-minibuffer' which handle must-match mechanism." - (let ((sel (helm-get-selection)) - ;; Ensure `file-directory-p' works on remote files. - non-essential) - (cl-assert sel nil "Trying to exit with no candidates") - (if (and (or (file-directory-p sel) - (helm-ff--invalid-tramp-name-p sel)) - ;; Allows exiting with default action when a prefix arg - ;; is specified. - (null current-prefix-arg) - (null helm-ff--RET-disabled) - (or (and (file-remote-p sel) - (string= "." (helm-basename sel)) - (string-match-p "\\`[/].*:.*:\\'" - helm-pattern)) - (not (string= "." (helm-basename sel))))) - (helm-execute-persistent-action) - (if must-match - (helm-confirm-and-exit-minibuffer) +(defun helm-ff-RET-1 () + "Used for RET action in `helm-find-files' and `helm-read-file-name'. +See `helm-ff-RET' for details." + (catch 'must-match + (let ((sel (helm-get-selection)) + ;; Ensure `file-directory-p' works on remote files. + non-essential) + ;; `helm--minibuffer-completing-file-name' is non nil that's mean we are + ;; in `helm-read-file-name'. + (if (and helm--minibuffer-completing-file-name (null sel)) + (throw 'must-match (minibuffer-message "[No match]")) + (cl-assert sel nil "Trying to exit with no candidates")) + (if (and (or (file-directory-p sel) + (helm-ff--invalid-tramp-name-p sel)) + ;; Allows exiting with default action when a prefix arg + ;; is specified. + (null current-prefix-arg) + (null helm-ff--RET-disabled) + (or (and (file-remote-p sel) + (string= "." (helm-basename sel)) + (string-match-p "\\`[/].*:.*:\\'" + helm-pattern)) + (not (string= "." (helm-basename sel))))) + (helm-execute-persistent-action) (helm-maybe-exit-minibuffer))))) (defun helm-ff-RET () @@ -2671,11 +2672,6 @@ Called with a prefix arg open menu unconditionally." (helm-ff-TAB-1 arg)) (put 'helm-ff-TAB 'helm-only t) -(defun helm-ff-RET-must-match () - "Same as `helm-ff-RET' but used in must-match map." - (interactive) - (helm-ff-RET-1 t)) - (helm-make-command-from-action helm-ff-run-grep "Run Grep action from `helm-source-find-files'." 'helm-find-files-grep)