aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/array.el
diff options
context:
space:
mode:
authorStefan Monnier2006-01-18 20:36:19 +0000
committerStefan Monnier2006-01-18 20:36:19 +0000
commit7a9ac68891e68493f1aedf544f09342013d8289e (patch)
tree7091e947b2adc4a02d2888636d357162f8a63246 /lisp/array.el
parent0ff223569f758db24bc6f5c71a56f2b1012fa830 (diff)
downloademacs-7a9ac68891e68493f1aedf544f09342013d8289e.tar.gz
emacs-7a9ac68891e68493f1aedf544f09342013d8289e.zip
Move defvars out of eval-when-compile.
(array-make-template): Replace undeclared global var with a local one. (array-mode): Inline initialization functions. (array-init-local-variables, array-init-max-row) (array-init-max-column, array-init-columns-per-line) (array-init-field-width, array-init-rows-numbered) (array-init-line-length, array-init-lines-per-row): Remove.
Diffstat (limited to 'lisp/array.el')
-rw-r--r--lisp/array.el173
1 files changed, 57 insertions, 116 deletions
diff --git a/lisp/array.el b/lisp/array.el
index 4d8b718965f..fb9e7301206 100644
--- a/lisp/array.el
+++ b/lisp/array.el
@@ -1,7 +1,7 @@
1;;; array.el --- array editing commands for GNU Emacs 1;;; array.el --- array editing commands for GNU Emacs
2 2
3;; Copyright (C) 1987, 2000, 2002, 2003, 2004, 3;; Copyright (C) 1987, 2000, 2002, 2003, 2004,
4;; 2005 Free Software Foundation, Inc. 4;; 2005, 2006 Free Software Foundation, Inc.
5 5
6;; Author David M. Brown 6;; Author David M. Brown
7;; Maintainer: FSF 7;; Maintainer: FSF
@@ -42,21 +42,19 @@
42 42
43;;; Code: 43;;; Code:
44 44
45(eval-when-compile 45(defvar array-max-column nil "Number of columns in the array.")
46 (defvar array-max-column) 46(defvar array-columns-per-line nil "Number of array columns per line.")
47 (defvar array-columns-per-line) 47(defvar array-buffer-column nil "Current column number of point in the buffer.")
48 (defvar array-buffer-column) 48(defvar array-line-length nil "Length of a line in the array.")
49 (defvar array-line-length) 49(defvar array-buffer-line nil "Current line number of point in the buffer.")
50 (defvar array-buffer-line) 50(defvar array-lines-per-row nil "Number of lines per array row.")
51 (defvar array-lines-per-row) 51(defvar array-max-row nil "Number of rows in the array.")
52 (defvar array-max-row) 52(defvar array-field-width nil "Width of a field in the array.")
53 (defvar array-field-width) 53(defvar array-row nil "Current array row location of point.")
54 (defvar array-row) 54(defvar array-column nil "Current array column location of point.")
55 (defvar array-column) 55(defvar array-rows-numbered nil "Are rows numbered in the buffer?")
56 (defvar array-rows-numbered) 56(defvar array-copy-string nil "Current field string being copied.")
57 (defvar array-copy-string) 57(defvar array-respect-tabs nil "Should TAB conversion be prevented?")
58 (defvar array-init-field)
59 (defvar array-respect-tabs))
60 58
61;;; Internal information functions. 59;;; Internal information functions.
62 60
@@ -107,7 +105,7 @@ Set them to the optional arguments A-ROW and A-COLUMN if those are supplied."
107 array-column (or a-column (array-current-column)))) 105 array-column (or a-column (array-current-column))))
108 106
109(defun array-update-buffer-position () 107(defun array-update-buffer-position ()
110 "Set array-buffer-line and array-buffer-column to their current values." 108 "Set `array-buffer-line' and `array-buffer-column' to their current values."
111 (setq array-buffer-line (current-line) 109 (setq array-buffer-line (current-line)
112 array-buffer-column (current-column))) 110 array-buffer-column (current-column)))
113 111
@@ -606,33 +604,34 @@ If optional ARG is given, copy through ARG rows up."
606 (interactive) 604 (interactive)
607 ;; If there is a conflict between array-field-width and init-string, resolve it. 605 ;; If there is a conflict between array-field-width and init-string, resolve it.
608 (let ((check t) 606 (let ((check t)
609 (len)) 607 (len)
608 init-field)
610 (while check 609 (while check
611 (setq array-init-field (read-string "Initial field value: ")) 610 (setq init-field (read-string "Initial field value: "))
612 (setq len (length array-init-field)) 611 (setq len (length init-field))
613 (if (/= len array-field-width) 612 (if (/= len array-field-width)
614 (if (y-or-n-p (format "Change field width to %d? " len)) 613 (if (y-or-n-p (format "Change field width to %d? " len))
615 (progn (setq array-field-width len) 614 (progn (setq array-field-width len)
616 (setq check nil))) 615 (setq check nil)))
617 (setq check nil)))) 616 (setq check nil)))
618 (goto-char (point-min)) 617 (goto-char (point-min))
619 (message "Working...") 618 (message "Working...")
620 (let ((this-row 1)) 619 (let ((this-row 1))
621 ;; Loop through the rows. 620 ;; Loop through the rows.
622 (while (<= this-row array-max-row) 621 (while (<= this-row array-max-row)
623 (if array-rows-numbered 622 (if array-rows-numbered
624 (insert (format "%d:\n" this-row))) 623 (insert (format "%d:\n" this-row)))
625 (let ((this-column 1)) 624 (let ((this-column 1))
626 ;; Loop through the columns. 625 ;; Loop through the columns.
627 (while (<= this-column array-max-column) 626 (while (<= this-column array-max-column)
628 (insert array-init-field) 627 (insert init-field)
629 (if (and (zerop (% this-column array-columns-per-line)) 628 (if (and (zerop (% this-column array-columns-per-line))
630 (/= this-column array-max-column)) 629 (/= this-column array-max-column))
631 (newline)) 630 (newline))
632 (setq this-column (1+ this-column)))) 631 (setq this-column (1+ this-column))))
633 (setq this-row (1+ this-row)) 632 (setq this-row (1+ this-row))
634 (newline))) 633 (newline)))
635 (message "Working...done") 634 (message "Working...done"))
636 (array-goto-cell 1 1)) 635 (array-goto-cell 1 1))
637 636
638(defun array-reconfigure-rows (new-columns-per-line new-rows-numbered) 637(defun array-reconfigure-rows (new-columns-per-line new-rows-numbered)
@@ -874,97 +873,39 @@ Entering array mode calls the function `array-mode-hook'."
874 873
875 (interactive) 874 (interactive)
876 (kill-all-local-variables) 875 (kill-all-local-variables)
877 ;; Number of rows in the array.
878 (make-local-variable 'array-max-row)
879 ;; Number of columns in the array.
880 (make-local-variable 'array-max-column)
881 ;; Number of array columns per line.
882 (make-local-variable 'array-columns-per-line)
883 ;; Width of a field in the array.
884 (make-local-variable 'array-field-width)
885 ;; Are rows numbered in the buffer?
886 (make-local-variable 'array-rows-numbered)
887 ;; Length of a line in the array.
888 (make-local-variable 'array-line-length)
889 ;; Number of lines per array row.
890 (make-local-variable 'array-lines-per-row)
891 ;; Current line number of point in the buffer.
892 (make-local-variable 'array-buffer-line) 876 (make-local-variable 'array-buffer-line)
893 ;; Current column number of point in the buffer.
894 (make-local-variable 'array-buffer-column) 877 (make-local-variable 'array-buffer-column)
895 ;; Current array row location of point.
896 (make-local-variable 'array-row) 878 (make-local-variable 'array-row)
897 ;; Current array column location of point.
898 (make-local-variable 'array-column) 879 (make-local-variable 'array-column)
899 ;; Current field string being copied.
900 (make-local-variable 'array-copy-string) 880 (make-local-variable 'array-copy-string)
901 ;; Should TAB conversion be prevented? 881 (set (make-local-variable 'array-respect-tabs) nil)
902 (make-local-variable 'array-respect-tabs) 882 (set (make-local-variable 'array-max-row)
903 (setq array-respect-tabs nil) 883 (read-number "Number of array rows: "))
904 (array-init-local-variables) 884 (set (make-local-variable 'array-max-column)
885 (read-number "Number of array columns: "))
886 (set (make-local-variable 'array-columns-per-line)
887 (read-number "Array columns per line: "))
888 (set (make-local-variable 'array-field-width)
889 (read-number "Field width: "))
890 (set (make-local-variable 'array-rows-numbered)
891 (y-or-n-p "Rows numbered? "))
892 (set (make-local-variable 'array-line-length)
893 (* array-field-width array-columns-per-line))
894 (set (make-local-variable 'array-lines-per-row)
895 (+ (floor (1- array-max-column) array-columns-per-line)
896 (if array-rows-numbered 2 1)))
897 (message "")
905 (setq major-mode 'array-mode) 898 (setq major-mode 'array-mode)
906 (setq mode-name "Array") 899 (setq mode-name "Array")
907 (force-mode-line-update) 900 (force-mode-line-update)
908 (make-local-variable 'truncate-lines) 901 (set (make-local-variable 'truncate-lines) t)
909 (setq truncate-lines t)
910 (setq overwrite-mode 'overwrite-mode-textual) 902 (setq overwrite-mode 'overwrite-mode-textual)
911 (use-local-map array-mode-map) 903 (use-local-map array-mode-map)
912 (run-mode-hooks 'array-mode-hook)) 904 (run-mode-hooks 'array-mode-hook))
913 905
914 906
915 907
916;;; Initialization functions. These are not interactive.
917
918(defun array-init-local-variables ()
919 "Initialize the variables associated with the array in this buffer."
920 (array-init-max-row)
921 (array-init-max-column)
922 (array-init-columns-per-line)
923 (array-init-field-width)
924 (array-init-rows-numbered)
925 (array-init-line-length)
926 (array-init-lines-per-row)
927 (message ""))
928
929(defun array-init-max-row (&optional arg)
930 "Initialize the value of `array-max-row'."
931 (setq array-max-row
932 (or arg (string-to-number (read-string "Number of array rows: ")))))
933
934(defun array-init-max-column (&optional arg)
935 "Initialize the value of `array-max-column'."
936 (setq array-max-column
937 (or arg (string-to-number (read-string "Number of array columns: ")))))
938
939(defun array-init-columns-per-line (&optional arg)
940 "Initialize the value of `array-columns-per-line'."
941 (setq array-columns-per-line
942 (or arg (string-to-number (read-string "Array columns per line: ")))))
943
944(defun array-init-field-width (&optional arg)
945 "Initialize the value of `array-field-width'."
946 (setq array-field-width
947 (or arg (string-to-number (read-string "Field width: ")))))
948
949(defun array-init-rows-numbered (&optional arg)
950 "Initialize the value of `array-rows-numbered'."
951 (setq array-rows-numbered
952 (or arg (y-or-n-p "Rows numbered? "))))
953
954(defun array-init-line-length (&optional arg)
955 "Initialize the value of `array-line-length'."
956 (setq array-line-length
957 (or arg
958 (* array-field-width array-columns-per-line))))
959
960(defun array-init-lines-per-row (&optional arg)
961 "Initialize the value of `array-lines-per-row'."
962 (setq array-lines-per-row
963 (or arg
964 (+ (floor (1- array-max-column) array-columns-per-line)
965 (if array-rows-numbered 2 1)))))
966
967(provide 'array) 908(provide 'array)
968 909
969;;; arch-tag: 0086605d-79fe-4a1a-992a-456417261f80 910;; arch-tag: 0086605d-79fe-4a1a-992a-456417261f80
970;;; array.el ends here 911;;; array.el ends here