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.
This commit is contained in:
Tino Calancha 2016-07-08 17:22:56 +09:00
parent 0e6fa2ddf7
commit 56c8551219
3 changed files with 22 additions and 0 deletions

View file

@ -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'.

View 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

View 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)