]> git.eshelyaron.com Git - emacs.git/commitdiff
(dired-yank): New command
authorEshel Yaron <me@eshelyaron.com>
Tue, 22 Oct 2024 17:59:00 +0000 (19:59 +0200)
committerEshel Yaron <me@eshelyaron.com>
Tue, 22 Oct 2024 18:00:14 +0000 (20:00 +0200)
lisp/dired-aux.el
lisp/dired.el

index 1be8b9334bdc96333e1d6c1f86bcd31ab4b001db..47caba6fe9754f00f3a8b7959c442ebaebc63433 100644 (file)
@@ -3992,6 +3992,18 @@ case, the VERBOSE argument is ignored."
         (setq model (vc-checkout-model backend only-files-list))))
     (list backend files only-files-list state model)))
 
+;;;###autoload
+(defun dired-yank (target)
+  (interactive (list (dired-current-directory)) dired-mode)
+  (let ((files (split-string-and-unquote (current-kill 0))))
+    (dolist (file files)
+      (unless (file-name-absolute-p file)
+        (user-error "Found non-filename in top of kill-ring"))
+      (message "Pasting file %s..." file)
+      (dired-copy-file file target 0)
+      (dired-add-file (expand-file-name (file-name-nondirectory file)) dired-marker-char))
+    (message "Pasted %d files from clipboard" (length dired-clipboard))))
+
 \f
 (provide 'dired-aux)
 
index a8421a679954b128592e16e6cc6b369010b36deb..62e968c62c577756b4a5ce786100b35fc2d6a355 100644 (file)
@@ -2402,6 +2402,7 @@ Do so according to the former subdir alist OLD-SUBDIR-ALIST."
   "<remap> <undo>"             #'dired-undo
   "<remap> <advertised-undo>"  #'dired-undo
   "<remap> <vc-next-action>"   #'dired-vc-next-action
+  "<remap> <yank>"             #'dired-yank
   ;; thumbnail manipulation (image-dired)
   "C-t d"   #'image-dired-display-thumbs
   "C-t t"   #'image-dired-tag-files