diff options
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | lisp/dired.el | 39 |
2 files changed, 30 insertions, 14 deletions
| @@ -166,6 +166,11 @@ of 'user-emacs-directory'. | |||
| 166 | 166 | ||
| 167 | * Incompatible changes in Emacs 29.1 | 167 | * Incompatible changes in Emacs 29.1 |
| 168 | 168 | ||
| 169 | --- | ||
| 170 | ** 'w' ('dired-copy-filename-as-kill') has changed behaviour. | ||
| 171 | If there are several files marked, file names containing space and | ||
| 172 | quote characters will be quoted "like this". | ||
| 173 | |||
| 169 | +++ | 174 | +++ |
| 170 | ** Warning about "eager macro-expansion failure" is changed into an error. | 175 | ** Warning about "eager macro-expansion failure" is changed into an error. |
| 171 | 176 | ||
diff --git a/lisp/dired.el b/lisp/dired.el index 43563d969f1..59346a19014 100644 --- a/lisp/dired.el +++ b/lisp/dired.el | |||
| @@ -3072,7 +3072,11 @@ If EOL, it should be an position to use instead of | |||
| 3072 | 3072 | ||
| 3073 | (defun dired-copy-filename-as-kill (&optional arg) | 3073 | (defun dired-copy-filename-as-kill (&optional arg) |
| 3074 | "Copy names of marked (or next ARG) files into the kill ring. | 3074 | "Copy names of marked (or next ARG) files into the kill ring. |
| 3075 | The names are separated by a space. | 3075 | If there are several names, they will be separated by a space, |
| 3076 | and file names that have spaces or quote characters in them will | ||
| 3077 | be quoted (with double quotes). (When there's a single file, no | ||
| 3078 | quoting is done.) | ||
| 3079 | |||
| 3076 | With a zero prefix arg, use the absolute file name of each marked file. | 3080 | With a zero prefix arg, use the absolute file name of each marked file. |
| 3077 | With \\[universal-argument], use the file name relative to the Dired buffer's | 3081 | With \\[universal-argument], use the file name relative to the Dired buffer's |
| 3078 | `default-directory'. (This still may contain slashes if in a subdirectory.) | 3082 | `default-directory'. (This still may contain slashes if in a subdirectory.) |
| @@ -3082,19 +3086,26 @@ prefix arg and marked files are ignored in this case. | |||
| 3082 | 3086 | ||
| 3083 | You can then feed the file name(s) to other commands with \\[yank]." | 3087 | You can then feed the file name(s) to other commands with \\[yank]." |
| 3084 | (interactive "P") | 3088 | (interactive "P") |
| 3085 | (let ((string | 3089 | (let* ((files |
| 3086 | (or (dired-get-subdir) | 3090 | (or (ensure-list (dired-get-subdir)) |
| 3087 | (mapconcat #'identity | 3091 | (if arg |
| 3088 | (if arg | 3092 | (cond ((zerop (prefix-numeric-value arg)) |
| 3089 | (cond ((zerop (prefix-numeric-value arg)) | 3093 | (dired-get-marked-files)) |
| 3090 | (dired-get-marked-files)) | 3094 | ((consp arg) |
| 3091 | ((consp arg) | 3095 | (dired-get-marked-files t)) |
| 3092 | (dired-get-marked-files t)) | 3096 | (t |
| 3093 | (t | 3097 | (dired-get-marked-files |
| 3094 | (dired-get-marked-files | 3098 | 'no-dir (prefix-numeric-value arg)))) |
| 3095 | 'no-dir (prefix-numeric-value arg)))) | 3099 | (dired-get-marked-files 'no-dir)))) |
| 3096 | (dired-get-marked-files 'no-dir)) | 3100 | (string |
| 3097 | " ")))) | 3101 | (if (length= files 1) |
| 3102 | (car files) | ||
| 3103 | (mapconcat (lambda (file) | ||
| 3104 | (if (string-match-p "[ \"']" file) | ||
| 3105 | (format "%S" file) | ||
| 3106 | file)) | ||
| 3107 | files | ||
| 3108 | " ")))) | ||
| 3098 | (unless (string= string "") | 3109 | (unless (string= string "") |
| 3099 | (if (eq last-command 'kill-region) | 3110 | (if (eq last-command 'kill-region) |
| 3100 | (kill-append string nil) | 3111 | (kill-append string nil) |