# HG changeset patch # User Richard M. Stallman # Date 1008554285 0 # Node ID eb27208de620a124f95b43cd77bb45598f49b710 # Parent fbcd9b643c57bcecfe347310d9dada201f054314 (dired-copy-filename-as-kill): Moved from dired-x.el. (dired-mode-map): Bind w to dired-copy-filename-as-kill. diff -r fbcd9b643c57 -r eb27208de620 lisp/dired.el --- a/lisp/dired.el Mon Dec 17 01:55:53 2001 +0000 +++ b/lisp/dired.el Mon Dec 17 01:58:05 2001 +0000 @@ -962,6 +962,7 @@ (define-key map "t" 'dired-do-toggle) (define-key map "u" 'dired-unmark) (define-key map "v" 'dired-view-file) + (define-key map "w" 'dired-copy-filename-as-kill) (define-key map "x" 'dired-do-flagged-delete) (define-key map "y" 'dired-show-file-type) (define-key map "+" 'dired-create-directory) @@ -1632,6 +1633,35 @@ (point)))) +;;; COPY NAMES OF MARKED FILES INTO KILL-RING. + +(defun dired-copy-filename-as-kill (&optional arg) + "Copy names of marked (or next ARG) files into the kill ring. +The names are separated by a space. +With a zero prefix arg, use the complete pathname of each marked file. +With \\[universal-argument], use the relative pathname of each marked file. + +If on a subdir headerline, use subdirname instead; prefix arg is ignored +in this case. + +You can then feed the file name(s) to other commands with \\[yank]." + (interactive "P") + (let ((string + (or (dired-get-subdir) + (mapconcat (function identity) + (if arg + (cond ((zerop (prefix-numeric-value arg)) + (dired-get-marked-files)) + ((integerp arg) + (dired-get-marked-files 'no-dir arg)) + (t ; else a raw arg + (dired-get-marked-files t))) + (dired-get-marked-files 'no-dir)) + " ")))) + (kill-new string) + (message "%s" string))) + + ;; Keeping Dired buffers in sync with the filesystem and with each other (defun dired-buffers-for-dir (dir &optional file)