changeset 1537:8531c6d96e5c

(make-directory): Renamed from make-directory-path. Optional argument says whether to create parent dirs. Invoke file-name handler here. (after-find-file): Delete code that offers to create dir. Instead, just print a message.
author Richard M. Stallman <rms@gnu.org>
date Tue, 03 Nov 1992 07:07:02 +0000
parents 0877009e6324
children 2d29bf379da3
files lisp/files.el
diffstat 1 files changed, 28 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/files.el	Tue Nov 03 02:24:05 1992 +0000
+++ b/lisp/files.el	Tue Nov 03 07:07:02 1992 +0000
@@ -557,20 +557,13 @@
 		   "Note: file is write protected")
 		  ((file-attributes (directory-file-name default-directory))
 		   "File not found and directory write-protected")
+		  ((file-exists-p (file-name-directory buffer-file-name))
+		   (setq buffer-read-only nil))
 		  (t
-		   ;; If the directory the buffer is in doesn't exist,
-		   ;; offer to create it.  It's better to do this now
-		   ;; than when we save the buffer, because we want
-		   ;; autosaving to work.
 		   (setq buffer-read-only nil)
-		   (or (file-exists-p (file-name-directory buffer-file-name))
-		       (if (yes-or-no-p
-			    (format
-			     "The directory containing %s does not exist.  Create? "
-			     (abbreviate-file-name buffer-file-name)))
-			   (make-directory-path
-			    (file-name-directory buffer-file-name))))
-		   nil))))
+		   (if (file-exists-p (file-name-directory (directory-file-name (file-name-directory buffer-file-name))))
+		       "Use M-x make-dir RET RET to create the directory"
+		     "Use C-u M-x make-dir RET RET to create directory and its parents")))))
       (if msg
 	  (progn
 	    (message msg)
@@ -1411,18 +1404,29 @@
     (rename-buffer name)
     (set-buffer-modified-p (buffer-modified-p)))) ; force mode line update
 
-(defun make-directory-path (path)
-  "Create all the directories along path that don't exist yet."
-  (interactive "Fdirectory path to create: ")
-  (let ((path (directory-file-name (expand-file-name path)))
-	create-list)
-    (while (not (file-exists-p path))
-      (setq create-list (cons path create-list)	    
-	    path (directory-file-name (file-name-directory path))))
-    (while create-list
-      (make-directory (car create-list))
-      (setq create-list (cdr create-list)))))
-
+(defun make-directory (dir &optional parents)
+  "Create the directory DIR and any nonexistent parent dirs."
+  (interactive "FMake directory: \nP")
+  (let (handler (handlers file-name-handler-alist))
+    (save-match-data
+     (while (and (consp handlers) (null handler))
+       (if (and (consp (car handlers))
+		(stringp (car (car handlers)))
+		(string-match (car (car handlers)) file))
+	   (setq handler (cdr (car handlers))))
+       (setq handlers (cdr handlers))))
+    (if handler
+	(funcall handler 'make-directory dir parents)
+      (if (not parents)
+	  (make-directory-internal dir)
+	(let ((dir (directory-file-name (expand-file-name dir)))
+	      create-list)
+	  (while (not (file-exists-p dir))
+	    (setq create-list (cons dir create-list)	    
+		  dir (directory-file-name (file-name-directory dir))))
+	  (while create-list
+	    (make-directory-internal (car create-list))
+	    (setq create-list (cdr create-list))))))))
 
 (put 'revert-buffer-function 'permanent-local t)
 (defvar revert-buffer-function nil