summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles A. Roelli <charles@aurox.ch>2026-05-28 13:28:53 +0000
committerCharles A. Roelli <charles@aurox.ch>2026-06-04 12:26:15 +0200
commita2e7b68764381e0880d55f71ef1d39cff73f950c (patch)
treefaf22629e1188b91132e9ecd140dd43447a1eb13
parentaa6acc69edb64eb962beb074c065c7b44c194da7 (diff)
Use `confirm-nonexistent-file-or-buffer' in ffapdevmain
* test/lisp/ffap-tests.el (ffap-respects-confirm-nonexistent-file-or-buffer): New test. * lisp/ffap.el (ffap-read-file-or-url): Respect `confirm-nonexistent-file-or-buffer'.
-rw-r--r--lisp/ffap.el7
-rw-r--r--test/lisp/ffap-tests.el13
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