mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-11-28 07:45:00 +00:00
Assume make-directory handler follows new API
Suggested by Michael Albinus (Bug#58919#56). * lisp/files.el (files--ensure-directory): Omit recently-added arg MKDIR, since it is now always make-directory again. All uses changed. (make-directory): Assume the make-directory handler follows the new API where it yields non-nil if DIR already exists. This reverts some of the recent changes in this area, and simplifies this funciton.
This commit is contained in:
parent
6c1413d5ef
commit
cc2cc0c297
@ -6193,11 +6193,11 @@ instance of such commands."
|
||||
(rename-buffer (generate-new-buffer-name base-name))
|
||||
(force-mode-line-update))))
|
||||
|
||||
(defun files--ensure-directory (mkdir dir)
|
||||
"Use function MKDIR to make directory DIR if it is not already a directory.
|
||||
(defun files--ensure-directory (dir)
|
||||
"Make directory DIR if it is not already a directory.
|
||||
Return non-nil if DIR is already a directory."
|
||||
(condition-case err
|
||||
(funcall mkdir dir)
|
||||
(make-directory-internal dir)
|
||||
(error
|
||||
(or (file-directory-p dir)
|
||||
(signal (car err) (cdr err))))))
|
||||
@ -6223,16 +6223,11 @@ Signal an error if unsuccessful."
|
||||
;; If default-directory is a remote directory,
|
||||
;; make sure we find its make-directory handler.
|
||||
(setq dir (expand-file-name dir))
|
||||
(let ((mkdir (if-let ((handler (find-file-name-handler dir 'make-directory)))
|
||||
#'(lambda (dir)
|
||||
;; Use 'ignore' since the handler might be designed for
|
||||
;; Emacs 28-, so it might return an (undocumented)
|
||||
;; non-nil value, whereas the Emacs 29+ convention is
|
||||
;; to return nil here.
|
||||
(ignore (funcall handler 'make-directory dir)))
|
||||
#'make-directory-internal)))
|
||||
(let ((handler (find-file-name-handler dir 'make-directory)))
|
||||
(if handler
|
||||
(funcall handler 'make-directory dir parents)
|
||||
(if (not parents)
|
||||
(funcall mkdir dir)
|
||||
(make-directory-internal dir)
|
||||
(let ((dir (directory-file-name (expand-file-name dir)))
|
||||
already-dir create-list parent)
|
||||
(while (progn
|
||||
@ -6240,15 +6235,15 @@ Signal an error if unsuccessful."
|
||||
(file-name-directory dir)))
|
||||
(condition-case ()
|
||||
(ignore (setq already-dir
|
||||
(files--ensure-directory mkdir dir)))
|
||||
(files--ensure-directory dir)))
|
||||
(error
|
||||
;; Do not loop if root does not exist (Bug#2309).
|
||||
(not (string= dir parent)))))
|
||||
(setq create-list (cons dir create-list)
|
||||
dir parent))
|
||||
(dolist (dir create-list)
|
||||
(setq already-dir (files--ensure-directory mkdir dir)))
|
||||
already-dir))))
|
||||
(setq already-dir (files--ensure-directory dir)))
|
||||
already-dir)))))
|
||||
|
||||
(defun make-empty-file (filename &optional parents)
|
||||
"Create an empty file FILENAME.
|
||||
|
Loading…
Reference in New Issue
Block a user