Function: array-make-template

array-make-template is an interactive and byte-compiled function defined in array.el.gz.

Signature

(array-make-template)

Documentation

Create the template of an array.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/array.el.gz
;;; Reconfiguration of the array.

(defun array-make-template ()
  "Create the template of an array."
  (interactive)
  ;; If there is a conflict between array-field-width and init-string, resolve it.
  (let ((check t)
	(len)
        init-field)
    (while check
      (setq init-field (read-string "Initial field value: "))
      (setq len (length init-field))
      (if (/= len array-field-width)
	  (if (y-or-n-p (format "Change field width to %d? " len))
	      (progn (setq array-field-width len)
		     (setq check nil)))
	(setq check nil)))
    (goto-char (point-min))
    (message "Working...")
    (let ((this-row 1))
      ;; Loop through the rows.
      (while (<= this-row array-max-row)
        (if array-rows-numbered
            (insert (format "%d:\n" this-row)))
        (let ((this-column 1))
          ;; Loop through the columns.
          (while (<= this-column array-max-column)
            (insert init-field)
            (if (and (zerop (% this-column array-columns-per-line))
                     (/= this-column array-max-column))
                (newline))
            (setq this-column (1+ this-column))))
        (setq this-row (1+ this-row))
        (newline)))
    (message "Working...done"))
  (array-goto-cell 1 1))