Function: ibuffer-confirm-operation-on

ibuffer-confirm-operation-on is a byte-compiled function defined in ibuffer.el.gz.

Signature

(ibuffer-confirm-operation-on OPERATION NAMES)

Documentation

Display a buffer asking whether to perform OPERATION on NAMES.

Source Code

;; Defined in /usr/src/emacs/lisp/ibuffer.el.gz
(defun ibuffer-confirm-operation-on (operation names)
  "Display a buffer asking whether to perform OPERATION on NAMES."
  (or ibuffer-expert
      (if (= (length names) 1)
	  (y-or-n-p (format "Really %s buffer %s? " operation (car names)))
	(let ((buf (get-buffer-create "*Ibuffer confirmation*")))
	  (with-current-buffer buf
	    (setq buffer-read-only nil)
	    (erase-buffer)
	    (ibuffer-columnize-and-insert-list names)
	    (goto-char (point-min))
	    (setq buffer-read-only t))
	  (let ((windows (nreverse (window-list nil 'nomini)))
                lastwin)
            (while (window-parameter (car windows) 'window-side)
              (setq windows (cdr windows)))
            (setq lastwin (car windows))
	    ;; Now attempt to display the buffer...
	    (save-window-excursion
	      (select-window lastwin)
	      ;; The window might be too small to split; in that case,
	      ;; try a few times to increase its size before giving up.
	      (let ((attempts 0)
		    (trying t))
		(while trying
		  (condition-case err
		      (progn
			(split-window)
			(setq trying nil))
		    (error
		     ;; Handle a failure
                     (if (or (> (incf attempts) 4)
			     (and (stringp (cadr err))
				  ;; This definitely falls in the
				  ;; ghetto hack category...
				  (not (string-match-p "too small" (cadr err)))))
			 (signal (car err) (cdr err))
		       (enlarge-window 3))))))
	      (select-window (next-window))
	      (switch-to-buffer buf)
	      (unwind-protect
		  (progn
		    (fit-window-to-buffer)
		    (y-or-n-p (format "Really %s %d buffers? "
				      operation (length names))))
		(kill-buffer buf))))))))