diff options
| author | Richard M. Stallman | 1992-11-03 07:07:02 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1992-11-03 07:07:02 +0000 |
| commit | 4e43240ad38b1a1d7362cb30bedb16404d2f3cb9 (patch) | |
| tree | 24c8577ad3511bea8ac382897cb83ea3c37acc92 | |
| parent | 353cfc19983002d9ad125bc2a91cc922d210f076 (diff) | |
| download | emacs-4e43240ad38b1a1d7362cb30bedb16404d2f3cb9.tar.gz emacs-4e43240ad38b1a1d7362cb30bedb16404d2f3cb9.zip | |
(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.
| -rw-r--r-- | lisp/files.el | 52 |
1 files changed, 28 insertions, 24 deletions
diff --git a/lisp/files.el b/lisp/files.el index 6a0737722dd..9fd20526dd6 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -557,20 +557,13 @@ Finishes by calling the functions in `find-file-hooks'." | |||
| 557 | "Note: file is write protected") | 557 | "Note: file is write protected") |
| 558 | ((file-attributes (directory-file-name default-directory)) | 558 | ((file-attributes (directory-file-name default-directory)) |
| 559 | "File not found and directory write-protected") | 559 | "File not found and directory write-protected") |
| 560 | ((file-exists-p (file-name-directory buffer-file-name)) | ||
| 561 | (setq buffer-read-only nil)) | ||
| 560 | (t | 562 | (t |
| 561 | ;; If the directory the buffer is in doesn't exist, | ||
| 562 | ;; offer to create it. It's better to do this now | ||
| 563 | ;; than when we save the buffer, because we want | ||
| 564 | ;; autosaving to work. | ||
| 565 | (setq buffer-read-only nil) | 563 | (setq buffer-read-only nil) |
| 566 | (or (file-exists-p (file-name-directory buffer-file-name)) | 564 | (if (file-exists-p (file-name-directory (directory-file-name (file-name-directory buffer-file-name)))) |
| 567 | (if (yes-or-no-p | 565 | "Use M-x make-dir RET RET to create the directory" |
| 568 | (format | 566 | "Use C-u M-x make-dir RET RET to create directory and its parents"))))) |
| 569 | "The directory containing %s does not exist. Create? " | ||
| 570 | (abbreviate-file-name buffer-file-name))) | ||
| 571 | (make-directory-path | ||
| 572 | (file-name-directory buffer-file-name)))) | ||
| 573 | nil)))) | ||
| 574 | (if msg | 567 | (if msg |
| 575 | (progn | 568 | (progn |
| 576 | (message msg) | 569 | (message msg) |
| @@ -1411,18 +1404,29 @@ or multiple mail buffers, etc." | |||
| 1411 | (rename-buffer name) | 1404 | (rename-buffer name) |
| 1412 | (set-buffer-modified-p (buffer-modified-p)))) ; force mode line update | 1405 | (set-buffer-modified-p (buffer-modified-p)))) ; force mode line update |
| 1413 | 1406 | ||
| 1414 | (defun make-directory-path (path) | 1407 | (defun make-directory (dir &optional parents) |
| 1415 | "Create all the directories along path that don't exist yet." | 1408 | "Create the directory DIR and any nonexistent parent dirs." |
| 1416 | (interactive "Fdirectory path to create: ") | 1409 | (interactive "FMake directory: \nP") |
| 1417 | (let ((path (directory-file-name (expand-file-name path))) | 1410 | (let (handler (handlers file-name-handler-alist)) |
| 1418 | create-list) | 1411 | (save-match-data |
| 1419 | (while (not (file-exists-p path)) | 1412 | (while (and (consp handlers) (null handler)) |
| 1420 | (setq create-list (cons path create-list) | 1413 | (if (and (consp (car handlers)) |
| 1421 | path (directory-file-name (file-name-directory path)))) | 1414 | (stringp (car (car handlers))) |
| 1422 | (while create-list | 1415 | (string-match (car (car handlers)) file)) |
| 1423 | (make-directory (car create-list)) | 1416 | (setq handler (cdr (car handlers)))) |
| 1424 | (setq create-list (cdr create-list))))) | 1417 | (setq handlers (cdr handlers)))) |
| 1425 | 1418 | (if handler | |
| 1419 | (funcall handler 'make-directory dir parents) | ||
| 1420 | (if (not parents) | ||
| 1421 | (make-directory-internal dir) | ||
| 1422 | (let ((dir (directory-file-name (expand-file-name dir))) | ||
| 1423 | create-list) | ||
| 1424 | (while (not (file-exists-p dir)) | ||
| 1425 | (setq create-list (cons dir create-list) | ||
| 1426 | dir (directory-file-name (file-name-directory dir)))) | ||
| 1427 | (while create-list | ||
| 1428 | (make-directory-internal (car create-list)) | ||
| 1429 | (setq create-list (cdr create-list)))))))) | ||
| 1426 | 1430 | ||
| 1427 | (put 'revert-buffer-function 'permanent-local t) | 1431 | (put 'revert-buffer-function 'permanent-local t) |
| 1428 | (defvar revert-buffer-function nil | 1432 | (defvar revert-buffer-function nil |