From ff854b0bde465a9db550dcff21d8db411c84818d Mon Sep 17 00:00:00 2001 From: Chong Yidong Date: Sat, 19 Mar 2011 18:07:41 -0400 Subject: [PATCH] Add error for dired-create-directory on existing file (Bug#8246). * lisp/dired-aux.el (dired-create-directory): Signal an error if the directory already exists. --- lisp/ChangeLog | 3 +++ lisp/dired-aux.el | 5 ++++- lisp/dired.el | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5244e261c11..a60ce0be672 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,8 @@ 2011-03-19 Chong Yidong + * dired-aux.el (dired-create-directory): Signal an error if the + directory already exists (Bug#8246). + * facemenu.el (list-colors-display): Call list-faces-display inside with-help-window. (list-colors-print): Use display property to align the final diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index c533c81be0e..9ab1fcb0e2b 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -1638,11 +1638,14 @@ Optional arg HOW-TO determiness how to treat the target. ;;;###autoload (defun dired-create-directory (directory) - "Create a directory called DIRECTORY." + "Create a directory called DIRECTORY. +If DIRECTORY already exists, signal an error." (interactive (list (read-file-name "Create directory: " (dired-current-directory)))) (let* ((expanded (directory-file-name (expand-file-name directory))) (try expanded) new) + (if (file-exists-p expanded) + (error "Cannot create directory %s: file exists" expanded)) ;; Find the topmost nonexistent parent dir (variable `new') (while (and try (not (file-exists-p try)) (not (equal new try))) (setq new try diff --git a/lisp/dired.el b/lisp/dired.el index c4374503a6f..22470ea61e6 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -3627,7 +3627,7 @@ Ask means pop up a menu for the user to select one of copy, move or link." ;;;;;; dired-run-shell-command dired-do-shell-command dired-do-async-shell-command ;;;;;; dired-clean-directory dired-do-print dired-do-touch dired-do-chown ;;;;;; dired-do-chgrp dired-do-chmod dired-compare-directories dired-backup-diff -;;;;;; dired-diff) "dired-aux" "dired-aux.el" "154cdfbf451aedec60c5012b625ff329") +;;;;;; dired-diff) "dired-aux" "dired-aux.el" "2d805d6766bd7970cd446413b4ed4ce0") ;;; Generated autoloads from dired-aux.el (autoload 'dired-diff "dired-aux" "\ @@ -3858,6 +3858,7 @@ Not documented (autoload 'dired-create-directory "dired-aux" "\ Create a directory called DIRECTORY. +If DIRECTORY already exists, signal an error. \(fn DIRECTORY)" t nil) -- 2.39.2