diff options
| -rw-r--r-- | etc/NEWS | 14 | ||||
| -rw-r--r-- | lisp/dired-aux.el | 23 |
2 files changed, 35 insertions, 2 deletions
| @@ -1423,6 +1423,20 @@ a control panel window. | |||
| 1423 | 1423 | ||
| 1424 | ** Dired | 1424 | ** Dired |
| 1425 | 1425 | ||
| 1426 | --- | ||
| 1427 | *** New user option 'dired-create-empty-file-in-current-directory'. | ||
| 1428 | When non-nil, 'dired-create-empty-file' creates a new empty file and | ||
| 1429 | adds an entry for it (or its topmost new parent directory if created) | ||
| 1430 | under the current subdirectory in the Dired buffer by default | ||
| 1431 | (otherwise, it adds adds the new file (and new subdirectories if | ||
| 1432 | provided) to whichever directory the user enters at the prompt). When | ||
| 1433 | nil, `dired-create-empty-file' acts on the default directory by default. | ||
| 1434 | |||
| 1435 | Note that setting this user option to non-nil makes invoking | ||
| 1436 | 'dired-create-empty-file' outside of a Dired buffer raise an error (like | ||
| 1437 | other Dired commands that always prompt with the current subdirectory, | ||
| 1438 | such as 'dired-create-directory'). | ||
| 1439 | |||
| 1426 | +++ | 1440 | +++ |
| 1427 | *** New user option 'dired-check-symlinks' allows disabling validity checks. | 1441 | *** New user option 'dired-check-symlinks' allows disabling validity checks. |
| 1428 | Dired uses 'file-truename' to check symbolic link validity when | 1442 | Dired uses 'file-truename' to check symbolic link validity when |
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index 2e8d5c1a379..100f203b3f6 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el | |||
| @@ -2872,13 +2872,32 @@ If DIRECTORY already exists, signal an error." | |||
| 2872 | (dired-add-file new) | 2872 | (dired-add-file new) |
| 2873 | (dired-move-to-filename)))) | 2873 | (dired-move-to-filename)))) |
| 2874 | 2874 | ||
| 2875 | (defcustom dired-create-empty-file-in-current-directory nil | ||
| 2876 | "Whether `dired-create-empty-file' acts on the current directory. | ||
| 2877 | If non-nil, `dired-create-empty-file' creates a new empty file and adds | ||
| 2878 | an entry for it (or its topmost new parent directory if created) under | ||
| 2879 | the current subdirectory in the Dired buffer by default (otherwise, it | ||
| 2880 | adds the new file (and new subdirectories if provided) to whichever | ||
| 2881 | directory the user enters at the prompt). If nil, | ||
| 2882 | `dired-create-empty-file' acts on the default directory by default." | ||
| 2883 | :type 'boolean | ||
| 2884 | :version "31.1") | ||
| 2885 | |||
| 2875 | ;;;###autoload | 2886 | ;;;###autoload |
| 2876 | (defun dired-create-empty-file (file) | 2887 | (defun dired-create-empty-file (file) |
| 2877 | "Create an empty file called FILE. | 2888 | "Create an empty file called FILE. |
| 2878 | Add a new entry for the new file in the Dired buffer. | ||
| 2879 | Parent directories of FILE are created as needed. | 2889 | Parent directories of FILE are created as needed. |
| 2890 | Add an entry in the Dired buffer for the topmost new parent | ||
| 2891 | directory of FILE, if created, otherwise for the new file. | ||
| 2892 | If user option `dired-create-empty-file-in-current-directory' is | ||
| 2893 | non-nil, act on the current subdirectory by default, otherwise act on | ||
| 2894 | the default directory by default. | ||
| 2880 | If FILE already exists, signal an error." | 2895 | If FILE already exists, signal an error." |
| 2881 | (interactive (list (read-file-name "Create empty file: ")) dired-mode) | 2896 | (interactive |
| 2897 | (list (read-file-name "Create empty file: " | ||
| 2898 | (and dired-create-empty-file-in-current-directory | ||
| 2899 | (dired-current-directory)))) | ||
| 2900 | dired-mode) | ||
| 2882 | (let* ((expanded (expand-file-name file)) | 2901 | (let* ((expanded (expand-file-name file)) |
| 2883 | new) | 2902 | new) |
| 2884 | (if (file-exists-p expanded) | 2903 | (if (file-exists-p expanded) |