changeset 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 c7e565aa7305
children c955f6add62a
files lisp/ChangeLog lisp/dired.el lisp/files.el lisp/menu-bar.el
diffstat 4 files changed, 31 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Tue Nov 02 07:56:08 2004 +0000
+++ b/lisp/ChangeLog	Tue Nov 02 07:57:53 2004 +0000
@@ -1,3 +1,18 @@
+2004-11-02  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* 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.
+
+	* diropen.pbm diropen.xpm: New files.
+	
+	* toolbar/tool-bar.el (tool-bar-setup): Tool bar item dired uses
+	icon diropen.  New tool bar item find-file-existing uses icon open.
+
+	* dired.el (dired-read-dir-and-switches): Call read-driectory-name
+	instead of read-file-name.
+
 2004-11-02  Ulf Jasper  <ulf.jasper@web.de>
 
 	* calendar/icalendar.el (icalendar-version): Increase to 0.08.
--- a/lisp/dired.el	Tue Nov 02 07:56:08 2004 +0000
+++ b/lisp/dired.el	Tue Nov 02 07:57:53 2004 +0000
@@ -546,7 +546,7 @@
 	    (if current-prefix-arg
 		(read-string "Dired listing switches: "
 			     dired-listing-switches))
-	    (read-file-name (format "Dired %s(directory): " str)
+	    (read-directory-name (format "Dired %s(directory): " str)
 			    nil default-directory nil))))
 
 ;;;###autoload (define-key ctl-x-map "d" 'dired)
--- 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.
--- a/lisp/menu-bar.el	Tue Nov 02 07:56:08 2004 +0000
+++ b/lisp/menu-bar.el	Tue Nov 02 07:57:53 2004 +0000
@@ -186,10 +186,15 @@
   '(menu-item "Open Directory..." dired
 	      :help "Read a directory, operate on its files"))
 (define-key menu-bar-files-menu [open-file]
-  '(menu-item "Open File..." find-file
+  '(menu-item "Open File..." find-file-existing
 	      :enable (not (window-minibuffer-p
 			    (frame-selected-window menu-updating-frame)))
-	      :help "Read a file into an Emacs buffer"))
+	      :help "Read an existing file into an Emacs buffer"))
+(define-key menu-bar-files-menu [new-file]
+  '(menu-item "New File..." find-file
+	      :enable (not (window-minibuffer-p
+			    (frame-selected-window menu-updating-frame)))
+	      :help "Read or create a file and edit it"))
 
 
 ;; The "Edit" menu items