diff options
| -rw-r--r-- | lisp/ffap.el | 7 | ||||
| -rw-r--r-- | test/lisp/ffap-tests.el | 13 |
2 files changed, 18 insertions, 2 deletions
diff --git a/lisp/ffap.el b/lisp/ffap.el index 2e88adfaf4a..7e716f7be2b 100644 --- a/lisp/ffap.el +++ b/lisp/ffap.el @@ -1618,7 +1618,8 @@ which may actually result in an URL rather than a filename." ;; allows you to switch back to reading a file name, ;; while other prompters, like ido, really expect a ;; file, and don't allow you to edit it if it's an URL. - (funcall #'read-file-name-default prompt guess guess) + (funcall #'read-file-name-default prompt guess guess + (confirm-nonexistent-file-or-buffer)) (unless guess (setq guess default-directory)) (unless (ffap-file-remote-p guess) @@ -1629,7 +1630,9 @@ which may actually result in an URL rather than a filename." #'read-directory-name #'read-file-name) prompt - (file-name-directory guess) nil nil + (file-name-directory guess) + nil + (confirm-nonexistent-file-or-buffer) (file-name-nondirectory guess)))) ;; Remove the special handler manually. We used to just let-bind ;; file-name-handler-alist to preserve its value, but that caused diff --git a/test/lisp/ffap-tests.el b/test/lisp/ffap-tests.el index 825ed8ba139..6860ac28c45 100644 --- a/test/lisp/ffap-tests.el +++ b/test/lisp/ffap-tests.el @@ -311,6 +311,19 @@ End of search list. (delete-file test-file) (should (equal (ffap-file-at-point) default-directory))))) +(ert-deftest ffap-respects-confirm-nonexistent-file-or-buffer () + (let ((default-directory temporary-file-directory) + (file1 (make-temp-file "ffap-test-foo1")) + (file2 (make-temp-file "ffap-test-foo2"))) + (minibuffer-with-setup-hook + (lambda () + (execute-kbd-macro (kbd "ffap- TAB RET")) + (should (equal (expand-file-name "ffap-test-foo") (minibuffer-contents))) + (should (equal major-mode 'minibuffer-mode)) + (delete-file file1) + (delete-file file2)) + (let ((executing-kbd-macro t)) (find-file-at-point))))) + (provide 'ffap-tests) ;;; ffap-tests.el ends here |
