emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 56c8551: Copy buffer names to kill ring


From: Tino Calancha
Subject: [Emacs-diffs] master 56c8551: Copy buffer names to kill ring
Date: Fri, 8 Jul 2016 08:35:29 +0000 (UTC)

branch: master
commit 56c8551219ecace0157ce813733adf8eecb38c32
Author: Tino Calancha <address@hidden>
Commit: Tino Calancha <address@hidden>

    Copy buffer names to kill ring
    
    * 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         |    4 ++++
 lisp/ibuf-ext.el |   17 +++++++++++++++++
 lisp/ibuffer.el  |    1 +
 3 files changed, 22 insertions(+)

diff --git a/etc/NEWS b/etc/NEWS
index f9fbe03..54b62f0 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -199,6 +199,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'.
 
 ---
diff --git a/lisp/ibuf-ext.el b/lisp/ibuf-ext.el
index 2444dac..6102e1f 100644
--- a/lisp/ibuf-ext.el
+++ b/lisp/ibuf-ext.el
@@ -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
diff --git a/lisp/ibuffer.el b/lisp/ibuffer.el
index fde1757..37f72bc 100644
--- a/lisp/ibuffer.el
+++ b/lisp/ibuffer.el
@@ -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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]