diff options
author | Thierry Volpiatto <thievol@posteo.net> | 2020-09-08 16:41:28 +0200 |
---|---|---|
committer | Thierry Volpiatto <thievol@posteo.net> | 2020-09-08 16:41:28 +0200 |
commit | 8d5c3074ae6da2ffc5c8b01d330ff7f5ee02a3ee (patch) | |
tree | be9310320b8cf70c6471ba49514f704d23d8959e /helm-mode.el | |
parent | 1c1f2ab320f5e6d9178d871e510b55abef87c921 (diff) |
Honor use-file-dialog when opening file from menu (#2381)
Call x-file-dialog instead of helm-read-file-name when opening file from menu.
Diffstat (limited to 'helm-mode.el')
-rw-r--r-- | helm-mode.el | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/helm-mode.el b/helm-mode.el index a2471fb4..8761abb8 100644 --- a/helm-mode.el +++ b/helm-mode.el @@ -1391,7 +1391,7 @@ Don't use it directly, use instead `helm-read-file-name' in your programs." (reading-directory (eq predicate 'file-directory-p)) helm-completion-mode-start-message ; Be quiet helm-completion-mode-quit-message ; Same here - fname) + add-to-history fname) ;; Build `default-filename' with `dir'+`initial' when ;; `default-filename' is not specified. ;; See `read-file-name' docstring for more infos. @@ -1416,20 +1416,28 @@ Don't use it directly, use instead `helm-read-file-name' in your programs." (helm-mode 1)))) ;; If we use now `read-file-name' we MUST turn off `helm-mode' ;; to avoid infinite recursion and CRASH. It will be reenabled on exit. - (when (or (eq def-com 'read-file-name) - (eq def-com 'ido-read-file-name) + (when (or (memq def-com '(read-file-name ido-read-file-name)) + (string= str-command "menu-find-file-existing") (and (stringp str-defcom) (not (string-match "^helm" str-defcom)))) (helm-mode -1)) (unwind-protect (setq fname - (cond (;; A specialized function exists, run it - ;; with the two extra args specific to helm. - ;; Note that the helm handler should ensure - ;; :initial-input is not nil i.e. Use init - ;; which fallback to default-directory instead - ;; of INITIAL. - (and def-com helm-mode + (cond ((string= str-command "menu-find-file-existing") + (let ((dialog-mustmatch + (not (memq mustmatch + '(nil confirm confirm-after-completion))))) + (setq add-to-history t) + (x-file-dialog prompt init default-filename + dialog-mustmatch + (eq predicate 'file-directory-p)))) + ;; A specialized function exists, run it + ;; with the two extra args specific to helm. + ;; Note that the helm handler should ensure + ;; :initial-input is not nil i.e. Use init + ;; which fallback to default-directory instead + ;; of INITIAL. + ((and def-com helm-mode (not (eq def-com 'ido-read-file-name)) (not (eq def-com 'incompatible))) (apply def-com others-args)) @@ -1442,7 +1450,7 @@ Don't use it directly, use instead `helm-read-file-name' in your programs." ;; run it with default args. (eq def-com 'read-file-name) (apply def-com def-args)) - (t ; Fall back to classic `helm-read-file-name'. + (t ; Fall back to classic `helm-read-file-name'. (helm-read-file-name prompt :name str-command @@ -1458,13 +1466,17 @@ Don't use it directly, use instead `helm-read-file-name' in your programs." (helm-mode 1) ;; Same comment as in `helm--completing-read-default'. (setq this-command current-command)) + (when add-to-history + (add-to-history 'file-name-history + (minibuffer-maybe-quote-filename fname))) (if (and ;; Using `read-directory-name'. reading-directory ;; `file-name-as-directory' return "./" when FNAME is ;; empty string. (not (string= fname ""))) - (file-name-as-directory fname) fname))) + (file-name-as-directory fname) + fname))) ;; Read file name handler with history (issue #1652) (defun helm-read-file-name-handler-1 (prompt dir default-filename |