]> code.delx.au - gnu-emacs/blobdiff - lisp/ibuf-ext.el
Include versioned preloaded libraries in `package--builtin-versions'
[gnu-emacs] / lisp / ibuf-ext.el
index 72fa8628a1f01ef167414514d3ca2c38d29fcb59..3e4e0dcb1b6745b63291a6e40e48cd5ecbff2b93 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
@@ -1484,6 +1501,23 @@ You can then feed the file name(s) to other commands with \\[yank]."
    #'(lambda (buf)
        (string-match regexp (buffer-name buf)))))
 
+(defun ibuffer-locked-buffer-p (&optional buf)
+  "Return non-nil if BUF is locked.
+When BUF nil, default to the buffer at current line."
+  (let ((cbuffer (or buf (ibuffer-current-buffer))))
+    (when cbuffer
+      (with-current-buffer cbuffer
+        (and (boundp 'emacs-lock-mode) emacs-lock-mode)))))
+
+;;;###autoload
+(defun ibuffer-mark-by-locked ()
+  "Mark all locked buffers."
+  (interactive)
+  (when (featurep 'emacs-lock)
+    (ibuffer-mark-on-buffer
+     (lambda (buf)
+       (ibuffer-locked-buffer-p buf)))))
+
 ;;;###autoload
 (defun ibuffer-mark-by-mode-regexp (regexp)
   "Mark all buffers whose major mode matches REGEXP."