From: Paul Eggert Date: Sat, 17 Dec 2022 20:15:30 +0000 (-0800) Subject: Use make-directory handlers uniformly X-Git-Tag: emacs-29.0.90~1102 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=8a9579ca29df951ace35125873949e905fd1af2b;p=emacs.git Use make-directory handlers uniformly Formerly, the code supported both make-directory and make-directory-internal handlers. This led to confusion and meant than in a few cases (nnmaildir, ido) remote directories could not be used in some cases. Fix this by using only make-directory handlers. Perhaps there used to be a reason for why there were both make-directory and make-directory-internal handlers, but whatever that reason was, it seems to have vanished even before now. There is no longer any need for make-directory-internal handlers, as the few remaining callers that use make-directory-internal do so only when there are no handlers. However, this change keeps the existing make-directory-internal handlers for now, in case this code is ever used in older Emacs versions that still call those handlers. * lisp/gnus/nnmaildir.el (nnmaildir--mkdir): * lisp/ido.el (ido-file-internal): * lisp/net/tramp-smb.el (tramp-smb-handle-make-directory): Use make-directory, not make-directory-internal. * lisp/net/tramp-smb.el (tramp-smb-handle-make-directory-internal): Now obsolete. * src/fileio.c (Fmake_directory_internal): Do not look for or use a make-directory-internal handler. * test/lisp/files-tests.el: (files-tests-file-name-non-special-make-directory-internal): Remove, as this test incorrectly assumes that make-directory-internal must support handlers. --- diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi index e2c3eb33418..b3f63b8f32a 100644 --- a/doc/lispref/files.texi +++ b/doc/lispref/files.texi @@ -3382,7 +3382,6 @@ first, before handlers for jobs such as remote file access. @code{load}, @code{lock-file}, @code{make-auto-save-file-name}, @code{make-directory}, -@code{make-directory-internal}, @code{make-lock-file-name}, @code{make-nearby-temp-file}, @code{make-process}, @@ -3444,7 +3443,6 @@ first, before handlers for jobs such as remote file access. @code{load}, @code{lock-file}, @code{make-auto-save-file-name}, @code{make-direc@discretionary{}{}{}tory}, -@code{make-direc@discretionary{}{}{}tory-internal}, @code{make-lock-file-name}, @code{make-nearby-temp-file}, @code{make-process}, diff --git a/etc/NEWS b/etc/NEWS index 6d28bef409d..72421b03191 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -4482,6 +4482,10 @@ set is too big to transfer to Emacs every time a completion is needed. The table uses new 'external' completion style exclusively and cannot work with regular styles such as 'basic' or 'flex'. ++++ +** Magic file handlers for make-directory-internal are no longer needed. +Instead, Emacs uses the already-existing make-directory handlers. + * Changes in Emacs 29.1 on Non-Free Operating Systems diff --git a/lisp/gnus/nnmaildir.el b/lisp/gnus/nnmaildir.el index faa288934d1..3fb87f3a712 100644 --- a/lisp/gnus/nnmaildir.el +++ b/lisp/gnus/nnmaildir.el @@ -296,7 +296,7 @@ This variable is set by `nnmaildir-request-article'.") (if (file-attributes file) (delete-file file)))) (defun nnmaildir--mkdir (dir) (or (file-exists-p (file-name-as-directory dir)) - (make-directory-internal (directory-file-name dir)))) + (make-directory (directory-file-name dir)))) (defun nnmaildir--mkfile (file) (write-region "" nil file nil 'no-message)) (defun nnmaildir--delete-dir-files (dir ls) diff --git a/lisp/ido.el b/lisp/ido.el index 77e4dd447d8..92b4370cb45 100644 --- a/lisp/ido.el +++ b/lisp/ido.el @@ -2435,7 +2435,7 @@ If cursor is not at the end of the user input, move to end of input." filename)) (ido-record-command method dirname) (ido-record-work-directory dirname) - (make-directory-internal dirname) + (make-directory dirname) (funcall method dirname)) (t ;; put make-directory command on history diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el index c720b33b5f2..24fff9bb495 100644 --- a/lisp/net/tramp-smb.el +++ b/lisp/net/tramp-smb.el @@ -1186,12 +1186,13 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored." (make-directory ldir parents)) ;; Just do it. (when (file-directory-p ldir) - (make-directory-internal dir)) + (make-directory dir)) (unless (file-directory-p dir) (tramp-error v 'file-error "Couldn't make directory %s" dir))))) (defun tramp-smb-handle-make-directory-internal (directory) "Like `make-directory-internal' for Tramp files." + (declare (obsolete nil "29.1")) (setq directory (directory-file-name (expand-file-name directory))) (unless (file-name-absolute-p directory) (setq directory (expand-file-name directory default-directory))) diff --git a/src/fileio.c b/src/fileio.c index 92335b639cd..835c42cc0a4 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -2427,16 +2427,11 @@ DEFUN ("make-directory-internal", Fmake_directory_internal, (Lisp_Object directory) { const char *dir; - Lisp_Object handler; Lisp_Object encoded_dir; CHECK_STRING (directory); directory = Fexpand_file_name (directory, Qnil); - handler = Ffind_file_name_handler (directory, Qmake_directory_internal); - if (!NILP (handler)) - return call2 (handler, Qmake_directory_internal, directory); - encoded_dir = ENCODE_FILE (directory); dir = SSDATA (encoded_dir); diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el index 682b5cdb449..efafb5583ac 100644 --- a/test/lisp/files-tests.el +++ b/test/lisp/files-tests.el @@ -1038,17 +1038,6 @@ unquoted file names." (let ((default-directory nospecial-dir)) (should-error (make-directory "dir"))))) -(ert-deftest files-tests-file-name-non-special-make-directory-internal () - (files-tests--with-temp-non-special (tmpdir nospecial-dir t) - (let ((default-directory nospecial-dir)) - (make-directory-internal "dir") - (should (file-directory-p "dir")) - (delete-directory "dir"))) - (files-tests--with-temp-non-special-and-file-name-handler - (tmpdir nospecial-dir t) - (let ((default-directory nospecial-dir)) - (should-error (make-directory-internal "dir"))))) - (ert-deftest files-tests-file-name-non-special-make-nearby-temp-file () (let* ((default-directory (file-name-quote temporary-file-directory)) (near-tmpfile (make-nearby-temp-file "file")))