diff lisp/files.el @ 57867:5a547995da89

* files.el (find-file-existing): New function. * menu-bar.el (menu-bar-files-menu): Make "Open File..." call find-file-existing. Add "New File..." that calls find-file. * dired.el (dired-read-dir-and-switches): Call read-driectory-name instead of read-file-name.
author Jan Djärv <jan.h.d@swipnet.se>
date Tue, 02 Nov 2004 07:57:53 +0000
parents 78c9886e4daf
children fc267b57656c
line wrap: on
line diff
--- a/lisp/files.el	Tue Nov 02 07:56:08 2004 +0000
+++ b/lisp/files.el	Tue Nov 02 07:57:53 2004 +0000
@@ -977,6 +977,14 @@
 	  (mapcar 'switch-to-buffer (cdr value)))
       (switch-to-buffer-other-frame value))))
 
+(defun find-file-existing (filename &optional wildcards)
+  "Edit the existing file FILENAME.
+Like \\[find-file] but only allow files that exists."
+  (interactive (find-file-read-args "Find existing file: " t))
+  (unless (file-exists-p filename) (error "%s does not exist" filename))
+  (find-file filename wildcards)
+  (current-buffer))
+
 (defun find-file-read-only (filename &optional wildcards)
   "Edit file FILENAME but don't allow changes.
 Like \\[find-file] but marks buffer as read-only.