;;; array.el --- array editing commands for Gnu Emacs
+;; Copyright (C) 1987 Free Software Foundation, Inc.
+
;; Author David M. Brown
;; Maintainer: FSF
-;; Last-Modified: 30 Jan 1991
-
-;; Copyright (C) 1987 Free Software Foundation, Inc.
+;; Keywords: extensions
;; This file is part of GNU Emacs.
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to
-;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+;; along with GNU Emacs; see the file COPYING. If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
;;; Commentary:
-;;; Written by dmb%morgoth@harvard.harvard.edu (address is old)
-;;; (David M. Brown at Goldberg-Zoino & Associates, Inc.)
-;;; Thanks to cph@kleph.ai.mit.edu for assistance
+;; Commands for editing a buffer interpreted as a rectangular array
+;; or matrix of whitespace-separated strings. You specify the array
+;; dimensions and some other parameters at startup time.
+
+;; Written by dmb%morgoth@harvard.harvard.edu (address is old)
+;; (David M. Brown at Goldberg-Zoino & Associates, Inc.)
+;; Thanks to cph@kleph.ai.mit.edu for assistance
-;;; To do:
-;;; Smooth initialization process by grokking local variables list
-;;; at end of buffer or parsing buffer using whitespace as delimiters.
-;;; Make 'array-copy-column-right faster.
+;; To do:
+;; Smooth initialization process by grokking local variables list
+;; at end of buffer or parsing buffer using whitespace as delimiters.
+;; Make 'array-copy-column-right faster.
\f
;;; Code:
(1- (% buffer-line lines-per-row))
(% buffer-line lines-per-row)))
;; Array columns on the current line.
- (ceiling (1+ buffer-column) field-width))))
+ (1+ (floor buffer-column field-width)))))
(defun array-update-array-position (&optional a-row a-column)
"Set `array-row' and `array-column' to their current values or
(interactive)
(let ((buffer-line (current-line))
(buffer-column (current-column)))
- (message (format "Array row: %s Array column: %s"
- (prin1-to-string (array-current-row))
- (prin1-to-string (array-current-column))))))
+ (message "Array row: %s Array column: %s"
+ (prin1-to-string (array-current-row))
+ (prin1-to-string (array-current-column)))))
(defun array-display-local-variables ()
"Display the current state of the local variables in the minibuffer."
(setq rows-numbered new-rows-numbered)
(setq line-length (* old-field-width new-columns-per-line))
(setq lines-per-row
- (+ (ceiling temp-max-column new-columns-per-line)
- (if new-rows-numbered 1 0)))
+ (+ (floor (1- temp-max-column) new-columns-per-line)
+ (if new-rows-numbered 2 1)))
(array-goto-cell (or array-row 1) (or array-column 1)))
(kill-buffer temp-buffer))
(message "Working...done"))
((> index limit) limit)
(t index)))
-(defun abs (int)
- "Return the absolute value of INT."
- (if (< int 0) (- int) int))
-
-
-(defun floor (int1 int2)
- "Returns the floor of INT1 divided by INT2.
-INT1 may be negative. INT2 must be positive."
- (if (< int1 0)
- (- (ceiling (- int1) int2))
- (/ int1 int2)))
-
-(defun ceiling (int1 int2)
- "Returns the ceiling of INT1 divided by INT2.
-Assumes that both arguments are nonnegative."
- (+ (/ int1 int2)
- (if (zerop (mod int1 int2))
- 0
- 1)))
-
(defun xor (pred1 pred2)
"Returns the logical exclusive or of predicates PRED1 and PRED2."
(and (or pred1 pred2)
(put 'array-mode 'mode-class 'special)
+;;;###autoload
(defun array-mode ()
"Major mode for editing arrays.
(array-init-local-variables)
(setq major-mode 'array-mode)
(setq mode-name "Array")
- ;; Update mode-line.
- (progn (save-excursion (set-buffer (other-buffer)))
- (set-buffer-modified-p (buffer-modified-p))
- (sit-for 0))
+ (force-mode-line-update)
(make-variable-buffer-local 'truncate-lines)
(setq truncate-lines t)
- (setq overwrite-mode t)
+ (setq overwrite-mode 'overwrite-mode-textual)
(use-local-map array-mode-map)
(run-hooks 'array-mode-hook))
"Initialize the value of lines-per-row."
(setq lines-per-row
(or arg
- (+ (ceiling max-column columns-per-line)
- (if rows-numbered 1 0)))))
+ (+ (floor (1- max-column) columns-per-line)
+ (if rows-numbered 2 1)))))
;;; array.el ends here