Ibuffer: Mark locked buffers

* lisp/ibuf-ext.el (ibuffer-locked-buffer-p): New defun.
(ibuffer-mark-by-locked): New command.
(ibuffer-mode-map): Bind it to '% L'; update menus.
(ibuffer-mode): Update mode doc.
;* etc/NEWS: Add NEWS entry for these changes and previous two commits.
This commit is contained in:
Tino Calancha 2016-07-08 01:34:35 +09:00
parent 9d70e4da74
commit 44517b21ab
3 changed files with 32 additions and 0 deletions

View file

@ -198,6 +198,15 @@ same as in modes where the character is not whitespace.
** Ibuffer
---
*** A new command 'ibuffer-mark-by-locked' to mark
all locked buffers; bound to '% L'.
---
*** A new option 'ibuffer-locked-char' to indicate
locked buffers; Ibuffer shows a new column displaying
'ibuffer-locked-char' for locked buffers.
---
*** A new command 'ibuffer-unmark-all-marks' to unmark
all buffers without asking confirmation; bound to

View file

@ -1484,6 +1484,24 @@ 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 ((_buffer (or buf (ibuffer-current-buffer)))
char)
(when _buffer
(with-current-buffer _buffer
(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."

View file

@ -556,6 +556,7 @@ directory, like `default-directory'."
(define-key map (kbd "% m") 'ibuffer-mark-by-mode-regexp)
(define-key map (kbd "% f") 'ibuffer-mark-by-file-name-regexp)
(define-key map (kbd "% g") 'ibuffer-mark-by-content-regexp)
(define-key map (kbd "% L") 'ibuffer-mark-by-locked)
(define-key map (kbd "C-t") 'ibuffer-visit-tags-table)
@ -782,6 +783,9 @@ directory, like `default-directory'."
'(menu-item "Mark by content (regexp)..."
ibuffer-mark-by-content-regexp
:help "Mark buffers whose content matches a regexp"))
(define-key-after map [menu-bar mark mark-by-locked]
'(menu-item "Mark by locked buffers..." ibuffer-mark-by-locked
:help "Mark all locked buffers"))
map))
@ -2476,6 +2480,7 @@ Marking commands:
`\\[ibuffer-mark-by-mode-regexp]' - Mark buffers by their major mode, using a regexp.
`\\[ibuffer-mark-by-file-name-regexp]' - Mark buffers by their filename, using a regexp.
`\\[ibuffer-mark-by-content-regexp]' - Mark buffers by their content, using a regexp.
`\\[ibuffer-mark-by-locked]' - Mark all locked buffers.
Filtering commands: