]> code.delx.au - gnu-emacs/blobdiff - lisp/array.el
(tar-header-block-tokenize): Decode codes of file
[gnu-emacs] / lisp / array.el
index d58d558188e5e5130cd38f8a98c97ecd7bab32b7..a172c52a08444d8f9b987181548722343a9927ea 100644 (file)
@@ -1,15 +1,16 @@
-;;; Array editing commands for Gnu Emacs
-;;;  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
+;;; array.el --- array editing commands for Gnu Emacs
 
 ;; Copyright (C) 1987 Free Software Foundation, Inc.
 
 
 ;; Copyright (C) 1987 Free Software Foundation, Inc.
 
+;; Author David M. Brown
+;; Maintainer: FSF
+;; Keywords: extensions
+
 ;; This file is part of GNU Emacs.
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
 ;; This file is part of GNU Emacs.
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 1, or (at your option)
+;; the Free Software Foundation; either version 2, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
 ;; 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:
+
+;; 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.
 
 
-;;; 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.
+;;  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.
 
 \f
 
 \f
+;;; Code:
 
 ;;; Internal information functions.
   
 
 ;;; Internal information functions.
   
@@ -67,7 +80,7 @@ Its ok to be on a row number line."
               (1- (% buffer-line lines-per-row))
             (% buffer-line lines-per-row)))
        ;; Array columns on the current line.
               (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
 
 (defun array-update-array-position (&optional a-row a-column)
   "Set `array-row' and `array-column' to their current values or
@@ -90,9 +103,9 @@ to the optional arguments A-ROW and A-COLUMN."
   (interactive)
   (let ((buffer-line (current-line))
        (buffer-column (current-column)))
   (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."
 
 (defun array-display-local-variables ()
   "Display the current state of the local variables in the minibuffer."
@@ -694,8 +707,8 @@ of rows-numbered."
       (setq rows-numbered new-rows-numbered)
       (setq line-length (* old-field-width new-columns-per-line))
       (setq lines-per-row 
       (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"))
       (array-goto-cell (or array-row 1) (or array-column 1)))
     (kill-buffer temp-buffer))
   (message "Working...done"))
@@ -714,26 +727,6 @@ of rows-numbered."
        ((> index limit) limit)
        (t index)))
 
        ((> 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)
 (defun xor (pred1 pred2)
   "Returns the logical exclusive or of predicates PRED1 and PRED2."
   (and (or pred1 pred2)
@@ -797,6 +790,7 @@ Return COLUMN."
 
 (put 'array-mode 'mode-class 'special)
 
 
 (put 'array-mode 'mode-class 'special)
 
+;;;###autoload
 (defun array-mode ()
   "Major mode for editing arrays.
 
 (defun array-mode ()
   "Major mode for editing arrays.
 
@@ -892,13 +886,10 @@ Entering array mode calls the function `array-mode-hook'."
   (array-init-local-variables)
   (setq major-mode 'array-mode)
   (setq mode-name "Array")
   (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)
   (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))
 
   (use-local-map array-mode-map)
   (run-hooks 'array-mode-hook))
 
@@ -953,5 +944,7 @@ array in this buffer."
   "Initialize the value of lines-per-row."
   (setq lines-per-row
        (or arg
   "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