]> code.delx.au - gnu-emacs/commitdiff
Copy buffer names to kill ring
authorTino Calancha <tino.calancha@gmail.com>
Fri, 8 Jul 2016 08:22:56 +0000 (17:22 +0900)
committerTino Calancha <tino.calancha@gmail.com>
Fri, 8 Jul 2016 08:22:56 +0000 (17:22 +0900)
* ibuf-ext.el (ibuffer-copy-buffername-as-kill): New command.
* lisp/ibuffer (ibuffer-mode-map): Bound it to 'B'.
;* etc/NEWS: Add entry for this new feature.

etc/NEWS
lisp/ibuf-ext.el
lisp/ibuffer.el

index f9fbe03e086c388bdb754a1935ab16fb1b49a364..54b62f02ee39d21eceb02482dca4ef3b0a6c270c 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -198,6 +198,10 @@ same as in modes where the character is not whitespace.
 
 ** Ibuffer
 
+---
+*** A new command 'ibuffer-copy-buffername-as-kill'; bound
+to 'B'.
+
 ---
 *** New command 'ibuffer-change-marks'; bound to '* c'.
 
index 2444dac58058c9e6b15e455d9f86aa0e26aacd7f..6102e1f7400574d41d53c0d526fea2e251cff997 100644 (file)
@@ -1462,6 +1462,23 @@ You can then feed the file name(s) to other commands with \\[yank]."
       (kill-new result)
       (message "%s" result))))
 
+;;;###autoload
+(defun ibuffer-copy-buffername-as-kill ()
+  "Copy buffer names of marked buffers into the kill ring.
+The names are separated by a space.
+You can then feed the file name(s) to other commands with \\[yank]."
+  (interactive)
+  (if (zerop (ibuffer-count-marked-lines))
+      (message "No buffers marked; use 'm' to mark a buffer")
+    (let ((res ""))
+      (ibuffer-map-marked-lines
+       #'(lambda (buf _mark)
+           (setq res (concat res (buffer-name buf) " "))))
+      (when (not (zerop (length res)))
+        (setq res (substring res 0 -1)))
+      (kill-new res)
+      (message res))))
+
 (defun ibuffer-mark-on-buffer (func &optional ibuffer-mark-on-buffer-mark group)
   (let ((count
         (ibuffer-map-lines
index fde17573dd7ccc114eab87ca2ffca741f40a5f60..37f72bc1aaac1203c11611870371f71b1dadba28 100644 (file)
@@ -586,6 +586,7 @@ directory, like `default-directory'."
 
     (define-key map (kbd "k") 'ibuffer-do-kill-lines)
     (define-key map (kbd "w") 'ibuffer-copy-filename-as-kill)
+    (define-key map (kbd "B") 'ibuffer-copy-buffername-as-kill)
 
     (define-key map (kbd "RET") 'ibuffer-visit-buffer)
     (define-key map (kbd "e") 'ibuffer-visit-buffer)