diff options
author | Tino Calancha <tino.calancha@gmail.com> | 2016-07-08 17:22:56 +0900 |
---|---|---|
committer | Tino Calancha <tino.calancha@gmail.com> | 2016-07-08 17:22:56 +0900 |
commit | 56c8551219ecace0157ce813733adf8eecb38c32 (patch) | |
tree | c7902df718f37216c749a1b6dabc80f8c8dc61f8 | |
parent | 0e6fa2ddf76a1d702d836db3786ec1e34f7dcf54 (diff) |
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.
-rw-r--r-- | etc/NEWS | 4 | ||||
-rw-r--r-- | lisp/ibuf-ext.el | 17 | ||||
-rw-r--r-- | lisp/ibuffer.el | 1 |
3 files changed, 22 insertions, 0 deletions
@@ -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 2444dac580..6102e1f740 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 fde17573dd..37f72bc1aa 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) |