Function: hycontrol-make-windows-grid

hycontrol-make-windows-grid is an interactive and byte-compiled function defined in hycontrol.el.

Signature

(hycontrol-make-windows-grid ARG &optional BUFFER-LIST)

Documentation

Display a grid of windows in the selected frame, sized according to prefix ARG.

Left digit of ARG is the number of grid rows and the right digit is the number of grid columns. If ARG is invalid, prompt for grid size.

If optional BUFFER-LIST is provided, use its length to determine minimum grid size, ignoring ARG.

See documentation of hycontrol-windows-grid for further details.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hycontrol.el
(defun hycontrol-make-windows-grid (arg &optional buffer-list)
  "Display a grid of windows in the selected frame, sized according to prefix ARG.
Left digit of ARG is the number of grid rows and the right digit is
the number of grid columns.  If ARG is invalid, prompt for grid size.

If optional BUFFER-LIST is provided, use its length to determine
minimum grid size, ignoring ARG.

See documentation of `hycontrol-windows-grid' for further details."
  (interactive "p")

  (unless buffer-list
    (setq buffer-list (hycontrol-windows-grid-marked-items)))

  (unless (or arg buffer-list)
    (error "(hycontrol-make-windows-grid): Both 'arg' and 'buffer-list' cannot both be null"))

  (cond (buffer-list
	 ;; Override `arg' when `buffer-list' is given
	 (setq arg (hycontrol-windows-grid-minimum-size (length buffer-list))))
	;; Check `arg': must be 2 digits of [1-9], else read a new `arg' or
	;; signal an error when in a HyControl mode and help is displayed.
	((and (and hycontrol-help-flag (or hycontrol-frames-mode hycontrol-windows-mode))
	      (not (hycontrol-windows-grid-valid-size-p arg)))
	 (let ((hyc-mode (if hycontrol-frames-mode #'hycontrol-frames-mode #'hycontrol-windows-mode)))
	   (hycontrol-disable-modes)
	   (setq arg 1)
	   (while (not (hycontrol-windows-grid-valid-size-p arg))
	     (unless (memq arg '(0 1))
	       (beep))
	     (setq arg (read-number "Display grid of ROW digit by COLUMN digit windows, e.g. 23 for 2R by 3C: ")))
	   (funcall hyc-mode arg)))
	(t (while (not (hycontrol-windows-grid-valid-size-p arg))
	     (unless (memq arg '(0 1))
	       (beep))
	     (setq arg (read-number "Display grid of ROW digit by COLUMN digit windows, e.g. 23 for 2R by 3C: ")))))

  (let ((wconfig (current-window-configuration))
	(hist-elt (hhist:element)))
    ;; If an error occurs during a window split because the window is
    ;; too small, then restore prior window configuration.
    (condition-case err
	;; Make 1 window in selected frame
	(progn (delete-other-windows)

	       (let* ((rows (floor (/ arg 10)))
		      (columns (- arg (* rows 10)))
		      (row-index (1- rows))
		      (row-window-list (list (selected-window)))
		      col-index)

		 ;; Create ARG left-digit rows via split-windows,
		 ;; balancing each time.
		 (while (> row-index 0)
		   (setq row-window-list (cons (split-window-vertically) row-window-list))
		   (balance-windows)
		   (setq row-index (1- row-index)))

		 ;; Create ARG right-digit columns in each row via
		 ;; split-windows, balancing each time.
		 (setq row-index rows)
		 (while (> row-index 0)
		   (with-selected-window (car row-window-list)
		     (setq col-index (1- columns))
		     (while (> col-index 0)
		       (split-window-horizontally)
		       (balance-windows)
		       (setq col-index (1- col-index)))
		     (setq row-index (1- row-index)
			   row-window-list (cdr row-window-list)))))

	       ;; Walk windows in this frame and display different
	       ;; buffers.  In the first pass, select only buffers
	       ;; that pass at least one predicate test in
	       ;; `hycontrol-display-buffer-predicate-list'.  If run
	       ;; out of buffers before windows, then start a 2nd
	       ;; pass at the start of the buffer list and use the
	       ;; inverse, choosing only those buffers that fail all
	       ;; the predicate tests.  Always ignore buffers that
	       ;; start with a space.  With each succeeding pass, the
	       ;; predicate list is inverted again.
	       (setq hycontrol--buffer-list (or buffer-list
						(hycontrol-windows-grid-buffer-list))
		     hycontrol--buffer-list-pointer hycontrol--buffer-list)
               (walk-windows #'hycontrol-window-display-buffer 'no-minibuf)

	       ;; Prevent user from mistakenly using the typically
	       ;; large argument that invoked this function; reset it
	       ;; to 1 if there was no error.
	       (setq hycontrol-arg 1))
      (error (set-window-configuration wconfig)
	     (and hycontrol-help-flag (or hycontrol-frames-mode hycontrol-windows-mode)
		  (pop-to-buffer (messages-buffer)))
	     (error "(HyDebug): Grid Size: %d; %s" arg err)))
    ;; No error, save prior frame configuration for easy return
    (hhist:add hist-elt)
    ;; Return nil so frame config structure is never displayed
    nil))