Function: ibuffer-map-lines
ibuffer-map-lines is a byte-compiled function defined in
ibuffer.el.gz.
Signature
(ibuffer-map-lines FUNCTION &optional NOMODIFY GROUP)
Documentation
Call FUNCTION for each buffer.
Set the ibuffer modification flag unless NOMODIFY is non-nil.
If optional argument GROUP is non-nil, then only call FUNCTION on buffers in filtering group GROUP.
FUNCTION is called with two arguments: the buffer object itself and the current mark symbol.
Source Code
;; Defined in /usr/src/emacs/lisp/ibuffer.el.gz
(defun ibuffer-map-lines (function &optional nomodify group)
"Call FUNCTION for each buffer.
Set the ibuffer modification flag unless NOMODIFY is non-nil.
If optional argument GROUP is non-nil, then only call FUNCTION on
buffers in filtering group GROUP.
FUNCTION is called with two arguments:
the buffer object itself and the current mark symbol."
(ibuffer-assert-ibuffer-mode)
(ibuffer-forward-line 0)
(let* ((orig-target-line (1+ (count-lines (save-excursion
(goto-char (point-min))
(ibuffer-forward-line 0)
(point))
(point))))
(target-line-offset orig-target-line)
(ibuffer-map-lines-total 0)
(ibuffer-map-lines-count 0))
(unwind-protect
(progn
(setq buffer-read-only nil)
(goto-char (point-min))
(ibuffer-forward-line 0 t)
(while (and (not (eobp))
(not (get-text-property (point) 'ibuffer-summary))
(progn
(ibuffer-forward-line 0 t)
(and (not (eobp))
(not (get-text-property (point) 'ibuffer-summary)))))
(let ((result
(if (buffer-live-p (ibuffer-current-buffer))
(when (or (null group)
(when-let* ((it (get-text-property
(point) 'ibuffer-filter-group)))
(equal group it)))
(save-excursion
(funcall function
(ibuffer-current-buffer)
(ibuffer-current-mark))))
;; Kill the line if the buffer is dead
'kill)))
;; A given mapping function should return:
;; nil if it chose not to affect the buffer
;; `kill' means the remove line from the buffer list
;; t otherwise
(incf ibuffer-map-lines-total)
(cond ((null result)
(forward-line 1))
((eq result 'kill)
(delete-region (line-beginning-position)
(1+ (line-end-position)))
(incf ibuffer-map-lines-count)
(when (< ibuffer-map-lines-total
orig-target-line)
(decf target-line-offset)))
(t
(incf ibuffer-map-lines-count)
(forward-line 1)))))
;; With `ibuffer-auto-mode' enabled, `ibuffer-expert' nil
;; and more than one marked buffer lines, the preceding loop
;; counts the automatically popped up (and hence not
;; user-marked) buffer "*Ibuffer confirmation*". Since
;; Ibuffer reports how many marked buffers lines were acted
;; upon, and in this case the reported count would be too
;; high by one, we decrement the count to avoid the
;; confusing message (see bug#64230).
(if (and (featurep 'ibuf-ext) ibuffer-auto-mode
(> ibuffer-map-lines-count 1)
(not ibuffer-expert))
(1- ibuffer-map-lines-count)
ibuffer-map-lines-count))
(progn
(setq buffer-read-only t)
(unless nomodify
(set-buffer-modified-p nil))
(goto-char (point-min))
(ibuffer-forward-line 0)
(ibuffer-forward-line (1- target-line-offset))))))