annotate lisp/array.el @ 64866:6f20cb2a3b72

(query-replace-read-from, query-replace-read-to) (query-replace-read-args): Rename arg `string' to `prompt'.
author Juri Linkov <juri@jurta.org>
date Tue, 09 Aug 2005 21:39:09 +0000
parents 41bb365f41c4
children de87ce42a058 2d92f5c9d6ae
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38412
253f761ad37b Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents: 27286
diff changeset
1 ;;; array.el --- array editing commands for GNU Emacs
662
8a533acedb77 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 180
diff changeset
2
64762
41bb365f41c4 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64429
diff changeset
3 ;; Copyright (C) 1987, 2000, 2002, 2003, 2004,
41bb365f41c4 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64429
diff changeset
4 ;; 2005 Free Software Foundation, Inc.
845
213978acbc1e entered into RCS
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 811
diff changeset
5
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
6 ;; Author David M. Brown
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
7 ;; Maintainer: FSF
2247
2c7997f249eb Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 845
diff changeset
8 ;; Keywords: extensions
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15 ;; any later version.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20 ;; GNU General Public License for more details.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13603
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64091
6fb026ad601f Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 62715
diff changeset
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
6fb026ad601f Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 62715
diff changeset
25 ;; Boston, MA 02110-1301, USA.
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
27 ;;; Commentary:
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
28
2307
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
29 ;; Commands for editing a buffer interpreted as a rectangular array
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
30 ;; or matrix of whitespace-separated strings. You specify the array
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
31 ;; dimensions and some other parameters at startup time.
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
32
2307
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
33 ;; Written by dmb%morgoth@harvard.harvard.edu (address is old)
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
34 ;; (David M. Brown at Goldberg-Zoino & Associates, Inc.)
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
35 ;; Thanks to cph@kleph.ai.mit.edu for assistance
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
36
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
37 ;; To do:
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
38 ;; Smooth initialization process by grokking local variables list
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
39 ;; at end of buffer or parsing buffer using whitespace as delimiters.
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
40 ;; Make 'array-copy-column-right faster.
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
41
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
43 ;;; Code:
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
44
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
45 (eval-when-compile
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
46 (defvar array-max-column)
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
47 (defvar array-columns-per-line)
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
48 (defvar array-buffer-column)
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
49 (defvar array-line-length)
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
50 (defvar array-buffer-line)
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
51 (defvar array-lines-per-row)
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
52 (defvar array-max-row)
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
53 (defvar array-field-width)
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
54 (defvar array-row)
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
55 (defvar array-column)
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
56 (defvar array-rows-numbered)
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
57 (defvar array-copy-string)
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
58 (defvar array-init-field)
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
59 (defvar array-respect-tabs))
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
60
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61 ;;; Internal information functions.
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42704
diff changeset
62
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
63 (defun array-cursor-in-array-range ()
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
64 "Return t if the cursor is in a valid array cell.
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
65 Its ok to be on a row number line."
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
66 (let ((columns-last-line (% array-max-column array-columns-per-line)))
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
67 ;; Requires array-buffer-line and array-buffer-column to be current.
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
68 (not (or
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69 ;; The cursor is too far to the right.
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
70 (>= array-buffer-column array-line-length)
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71 ;; The cursor is below the last row.
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
72 (>= array-buffer-line (* array-lines-per-row array-max-row))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
73 ;; The cursor is on the last line of the row, the line is smaller
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
74 ;; than the others, and the cursor is after the last array column
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
75 ;; on the line.
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
76 (and (zerop (% (1+ array-buffer-line) array-lines-per-row))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
77 (not (zerop columns-last-line))
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
78 (>= array-buffer-column (* columns-last-line array-field-width)))))))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
79
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
80 (defun array-current-row ()
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
81 "Return the array row of the field in which the cursor is located."
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
82 ;; Requires array-buffer-line and array-buffer-column to be current.
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
83 (and (array-cursor-in-array-range)
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
84 (1+ (floor array-buffer-line array-lines-per-row))))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
85
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
86 (defun array-current-column ()
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
87 "Return the array column of the field in which the cursor is located."
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
88 ;; Requires array-buffer-line and array-buffer-column to be current.
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
89 (and (array-cursor-in-array-range)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
90 ;; It's not okay to be on a row number line.
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
91 (not (and array-rows-numbered
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
92 (zerop (% array-buffer-line array-lines-per-row))))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
93 (+
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94 ;; Array columns due to line differences.
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
95 (* array-columns-per-line
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
96 (if array-rows-numbered
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
97 (1- (% array-buffer-line array-lines-per-row))
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
98 (% array-buffer-line array-lines-per-row)))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
99 ;; Array columns on the current line.
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
100 (1+ (floor array-buffer-column array-field-width)))))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
101
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
102 (defun array-update-array-position (&optional a-row a-column)
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
103 "Set `array-row' and `array-column' to their current values.
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
104 Set them to the optional arguments A-ROW and A-COLUMN if those are supplied."
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
105 ;; Requires that array-buffer-line and array-buffer-column be current.
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
106 (setq array-row (or a-row (array-current-row))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
107 array-column (or a-column (array-current-column))))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
108
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
109 (defun array-update-buffer-position ()
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
110 "Set array-buffer-line and array-buffer-column to their current values."
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
111 (setq array-buffer-line (current-line)
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
112 array-buffer-column (current-column)))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
113
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
114
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
115
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
116 ;;; Information commands.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
117
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
118 (defun array-what-position ()
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
119 "Display the row and column in which the cursor is positioned."
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
120 (interactive)
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
121 (let ((array-buffer-line (current-line))
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
122 (array-buffer-column (current-column)))
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
123 (message "Array row: %s Array column: %s"
14338
0f8f00733165 (array-what-position): Delete format call inside message.
Karl Heuer <kwzh@gnu.org>
parents: 14169
diff changeset
124 (prin1-to-string (array-current-row))
0f8f00733165 (array-what-position): Delete format call inside message.
Karl Heuer <kwzh@gnu.org>
parents: 14169
diff changeset
125 (prin1-to-string (array-current-column)))))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
126
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
127 (defun array-display-local-variables ()
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
128 "Display the current state of the local variables in the minibuffer."
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
129 (interactive)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
130 (let ((buf (buffer-name (current-buffer))))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
131 (with-output-to-temp-buffer "*Local Variables*"
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
132 (buffer-disable-undo standard-output)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
133 (terpri)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
134 (princ (format " Buffer: %s\n\n" buf))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
135 (princ (format " max-row: %s\n"
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
136 (prin1-to-string array-max-row)))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
137 (princ (format " max-column: %s\n"
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
138 (prin1-to-string array-max-column)))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
139 (princ (format " columns-per-line: %s\n"
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
140 (prin1-to-string array-columns-per-line)))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
141 (princ (format " field-width: %s\n"
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
142 (prin1-to-string array-field-width)))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
143 (princ (format " rows-numbered: %s\n"
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
144 (prin1-to-string array-rows-numbered)))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
145 (princ (format " lines-per-row: %s\n"
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
146 (prin1-to-string array-lines-per-row)))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
147 (princ (format " line-length: %s\n"
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
148 (prin1-to-string array-line-length))))))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
149
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
150
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
151
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
152 ;;; Internal movement functions.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
153
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
154 (defun array-beginning-of-field (&optional go-there)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
155 "Return the column of the beginning of the current field.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
156 Optional argument GO-THERE, if non-nil, means go there too."
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
157 ;; Requires that array-buffer-column be current.
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
158 (let ((goal-column (- array-buffer-column (% array-buffer-column array-field-width))))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
159 (if go-there
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
160 (move-to-column-untabify goal-column)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
161 goal-column)))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
162
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
163 (defun array-end-of-field (&optional go-there)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
164 "Return the column of the end of the current array field.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
165 If optional argument GO-THERE is non-nil, go there too."
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
166 ;; Requires that array-buffer-column be current.
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
167 (let ((goal-column (+ (- array-buffer-column (% array-buffer-column array-field-width))
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
168 array-field-width)))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
169 (if go-there
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
170 (move-to-column-untabify goal-column)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
171 goal-column)))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
172
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
173 (defun array-move-to-cell (a-row a-column)
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
174 "Move to array row A-ROW and array column A-COLUMN.
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
175 Leave point at the beginning of the field and return the new buffer column."
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
176 (let ((goal-line (+ (* array-lines-per-row (1- a-row))
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
177 (if array-rows-numbered 1 0)
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
178 (floor (1- a-column) array-columns-per-line)))
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
179 (goal-column (* array-field-width (% (1- a-column) array-columns-per-line))))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
180 (goto-char (point-min))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
181 (forward-line goal-line)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
182 (move-to-column-untabify goal-column)))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
183
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
184 (defun array-move-to-row (a-row)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
185 "Move to array row A-ROW preserving the current array column.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
186 Leave point at the beginning of the field and return the new array row."
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
187 ;; Requires that array-buffer-line and array-buffer-column be current.
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
188 (let ((goal-line (+ (* array-lines-per-row (1- a-row))
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
189 (% array-buffer-line array-lines-per-row)))
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
190 (goal-column (- array-buffer-column (% array-buffer-column array-field-width))))
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
191 (forward-line (- goal-line array-buffer-line))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
192 (move-to-column-untabify goal-column)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
193 a-row))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
194
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
195 (defun array-move-to-column (a-column)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
196 "Move to array column A-COLUMN preserving the current array row.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
197 Leave point at the beginning of the field and return the new array column."
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
198 ;; Requires that array-buffer-line and array-buffer-column be current.
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
199 (let ((goal-line (+ (- array-buffer-line (% array-buffer-line array-lines-per-row))
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
200 (if array-rows-numbered 1 0)
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
201 (floor (1- a-column) array-columns-per-line)))
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
202 (goal-column (* array-field-width (% (1- a-column) array-columns-per-line))))
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
203 (forward-line (- goal-line array-buffer-line))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
204 (move-to-column-untabify goal-column)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
205 a-column))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
206
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
207 (defun array-move-one-row (sign)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
208 "Move one array row in direction SIGN (1 or -1).
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
209 Leave point at the beginning of the field and return the new array row.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
210 If requested to move beyond the array bounds, signal an error."
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
211 ;; Requires that array-buffer-line and array-buffer-column be current.
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
212 (let ((goal-column (array-beginning-of-field))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
213 (array-row (or (array-current-row)
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
214 (error "Cursor is not in a valid array cell"))))
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
215 (cond ((and (= array-row array-max-row) (= sign 1))
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
216 (error "End of array"))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
217 ((and (= array-row 1) (= sign -1))
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
218 (error "Beginning of array"))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
219 (t
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
220 (progn
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
221 (forward-line (* sign array-lines-per-row))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
222 (move-to-column-untabify goal-column)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
223 (+ array-row sign))))))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
224
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
225 (defun array-move-one-column (sign)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
226 "Move one array column in direction SIGN (1 or -1).
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
227 Leave point at the beginning of the field and return the new array column.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
228 If requested to move beyond the array bounds, signal an error."
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
229 ;; Requires that array-buffer-line and array-buffer-column be current.
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
230 (let ((array-column (or (array-current-column)
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
231 (error "Cursor is not in a valid array cell"))))
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
232 (cond ((and (= array-column array-max-column) (= sign 1))
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
233 (error "End of array"))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
234 ((and (= array-column 1) (= sign -1))
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
235 (error "Beginning of array"))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
236 (t
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
237 (cond
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
238 ;; Going backward from first column on the line.
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
239 ((and (= sign -1) (= 1 (% array-column array-columns-per-line)))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
240 (forward-line -1)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
241 (move-to-column-untabify
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
242 (* array-field-width (1- array-columns-per-line))))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
243 ;; Going forward from last column on the line.
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
244 ((and (= sign 1) (zerop (% array-column array-columns-per-line)))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
245 (forward-line 1))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
246 ;; Somewhere in the middle of the line.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
247 (t
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
248 (move-to-column-untabify (+ (array-beginning-of-field)
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
249 (* array-field-width sign)))))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
250 (+ array-column sign)))))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
251
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
252 (defun array-normalize-cursor ()
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
253 "Move the cursor to the first non-whitespace character in the field.
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
254 If necessary, scroll horizontally to keep the cursor in view."
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
255 ;; Assumes point is at the beginning of the field.
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
256 (let ((array-buffer-column (current-column)))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
257 (skip-chars-forward " \t"
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
258 (1- (save-excursion (array-end-of-field t) (point))))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
259 (array-maybe-scroll-horizontally)))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
260
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
261 (defun array-maybe-scroll-horizontally ()
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
262 "If necessary, scroll horizontally to keep the cursor in view."
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
263 ;; This is only called from array-normalize-cursor so
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
264 ;; array-buffer-column will always be current.
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
265 (let ((w-hscroll (window-hscroll))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
266 (w-width (window-width)))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
267 (cond
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
268 ((and (>= array-buffer-column w-hscroll)
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
269 (<= array-buffer-column (+ w-hscroll w-width)))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
270 ;; It's already visible. Do nothing.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
271 nil)
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
272 ((> array-buffer-column (+ w-hscroll w-width))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
273 ;; It's to the right. Scroll left.
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
274 (scroll-left (- (- array-buffer-column w-hscroll)
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
275 (/ w-width 2))))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
276 (t
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
277 ;; It's to the left. Scroll right.
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
278 (scroll-right (+ (- w-hscroll array-buffer-column)
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
279 (/ w-width 2)))))))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
280
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
281
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
282
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
283 ;;; Movement commands.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
284
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
285 (defun array-next-row (&optional arg)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
286 "Move down one array row, staying in the current array column.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
287 If optional ARG is given, move down ARG array rows."
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
288 (interactive "p")
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
289 (let ((array-buffer-line (current-line))
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
290 (array-buffer-column (current-column)))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
291 (if (= (abs arg) 1)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
292 (array-move-one-row arg)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
293 (array-move-to-row
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
294 (limit-index (+ (or (array-current-row)
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
295 (error "Cursor is not in an array cell"))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
296 arg)
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
297 array-max-row))))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
298 (array-normalize-cursor))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
299
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
300 (defun array-previous-row (&optional arg)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
301 "Move up one array row, staying in the current array column.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
302 If optional ARG is given, move up ARG array rows."
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
303 (interactive "p")
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
304 (array-next-row (- arg)))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
305
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
306 (defun array-forward-column (&optional arg)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
307 "Move forward one field, staying in the current array row.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
308 If optional ARG is given, move forward ARG array columns.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
309 If necessary, keep the cursor in the window by scrolling right or left."
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
310 (interactive "p")
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
311 (let ((array-buffer-line (current-line))
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
312 (array-buffer-column (current-column)))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
313 (if (= (abs arg) 1)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
314 (array-move-one-column arg)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
315 (array-move-to-column
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
316 (limit-index (+ (or (array-current-column)
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
317 (error "Cursor is not in an array cell"))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
318 arg)
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
319 array-max-column))))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
320 (array-normalize-cursor))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
321
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
322 (defun array-backward-column (&optional arg)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
323 "Move backward one field, staying in the current array row.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
324 If optional ARG is given, move backward ARG array columns.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
325 If necessary, keep the cursor in the window by scrolling right or left."
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
326 (interactive "p")
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
327 (array-forward-column (- arg)))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
328
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
329 (defun array-goto-cell (a-row a-column)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
330 "Go to array row A-ROW and array column A-COLUMN."
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
331 (interactive "nArray row: \nnArray column: ")
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
332 (array-move-to-cell
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
333 (limit-index a-row array-max-row)
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
334 (limit-index a-column array-max-column))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
335 (array-normalize-cursor))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
336
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
337
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
338
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
339 ;;; Internal copying functions.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
340
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
341 (defun array-field-string ()
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
342 "Return the field string at the current cursor location."
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
343 ;; Requires that array-buffer-column be current.
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
344 (buffer-substring
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
345 (save-excursion (array-beginning-of-field t) (point))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
346 (save-excursion (array-end-of-field t) (point))))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
347
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
348 (defun array-copy-once-vertically (sign)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
349 "Copy the current field into one array row in direction SIGN (1 or -1).
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
350 Leave point at the beginning of the field and return the new array row.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
351 If requested to move beyond the array bounds, signal an error."
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
352 ;; Requires that array-buffer-line, array-buffer-column, and array-copy-string be current.
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
353 (let ((a-row (array-move-one-row sign)))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
354 (let ((inhibit-quit t))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
355 (delete-region (point) (save-excursion (array-end-of-field t) (point)))
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
356 (insert array-copy-string))
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
357 (move-to-column array-buffer-column)
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
358 a-row))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
359
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
360 (defun array-copy-once-horizontally (sign)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
361 "Copy the current field into one array column in direction SIGN (1 or -1).
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
362 Leave point at the beginning of the field and return the new array column.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
363 If requested to move beyond the array bounds, signal an error."
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
364 ;; Requires that array-buffer-line, array-buffer-column, and array-copy-string be current.
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
365 (let ((a-column (array-move-one-column sign)))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
366 (array-update-buffer-position)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
367 (let ((inhibit-quit t))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
368 (delete-region (point) (save-excursion (array-end-of-field t) (point)))
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
369 (insert array-copy-string))
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
370 (move-to-column array-buffer-column)
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
371 a-column))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
372
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
373 (defun array-copy-to-row (a-row)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
374 "Copy the current field vertically into every cell up to and including A-ROW.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
375 Leave point at the beginning of the field."
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
376 ;; Requires that array-buffer-line, array-buffer-column, array-row, and
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
377 ;; array-copy-string be current.
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
378 (let* ((num (- a-row array-row))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
379 (count (abs num))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
380 (sign (if (zerop count) () (/ num count))))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
381 (while (> count 0)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
382 (array-move-one-row sign)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
383 (array-update-buffer-position)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
384 (let ((inhibit-quit t))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
385 (delete-region (point) (save-excursion (array-end-of-field t) (point)))
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
386 (insert array-copy-string))
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
387 (move-to-column array-buffer-column)
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
388 (setq count (1- count)))))
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42704
diff changeset
389
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
390 (defun array-copy-to-column (a-column)
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
391 "Copy current field horizontally into every cell up to and including A-COLUMN.
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
392 Leave point at the beginning of the field."
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
393 ;; Requires that array-buffer-line, array-buffer-column, array-column, and
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
394 ;; array-copy-string be current.
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
395 (let* ((num (- a-column array-column))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
396 (count (abs num))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
397 (sign (if (zerop count) () (/ num count))))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
398 (while (> count 0)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
399 (array-move-one-column sign)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
400 (array-update-buffer-position)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
401 (let ((inhibit-quit t))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
402 (delete-region (point) (save-excursion (array-end-of-field t) (point)))
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
403 (insert array-copy-string))
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
404 (move-to-column array-buffer-column)
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
405 (setq count (1- count)))))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
406
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
407 (defun array-copy-to-cell (a-row a-column)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
408 "Copy the current field into the cell at A-ROW, A-COLUMN.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
409 Leave point at the beginning of the field."
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
410 ;; Requires that array-copy-string be current.
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
411 (array-move-to-cell a-row a-column)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
412 (array-update-buffer-position)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
413 (delete-region (point) (save-excursion (array-end-of-field t) (point)))
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
414 (insert array-copy-string)
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
415 (move-to-column array-buffer-column))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
416
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
417
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
418
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
419 ;;; Commands for copying.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
420
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
421 (defun array-copy-down (&optional arg)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
422 "Copy the current field one array row down.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
423 If optional ARG is given, copy down through ARG array rows."
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
424 (interactive "p")
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
425 (let* ((array-buffer-line (current-line))
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
426 (array-buffer-column (current-column))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
427 (array-row (or (array-current-row)
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
428 (error "Cursor is not in a valid array cell")))
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
429 (array-copy-string (array-field-string)))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
430 (if (= (abs arg) 1)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
431 (array-copy-once-vertically arg)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
432 (array-copy-to-row
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
433 (limit-index (+ array-row arg) array-max-row))))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
434 (array-normalize-cursor))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
435
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
436 (defun array-copy-up (&optional arg)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
437 "Copy the current field one array row up.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
438 If optional ARG is given, copy up through ARG array rows."
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
439 (interactive "p")
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
440 (array-copy-down (- arg)))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
441
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
442 (defun array-copy-forward (&optional arg)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
443 "Copy the current field one array column to the right.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
444 If optional ARG is given, copy through ARG array columns to the right."
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
445 (interactive "p")
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
446 (let* ((array-buffer-line (current-line))
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
447 (array-buffer-column (current-column))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
448 (array-column (or (array-current-column)
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
449 (error "Cursor is not in a valid array cell")))
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
450 (array-copy-string (array-field-string)))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
451 (if (= (abs arg) 1)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
452 (array-copy-once-horizontally arg)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
453 (array-copy-to-column
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
454 (limit-index (+ array-column arg) array-max-column))))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
455 (array-normalize-cursor))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
456
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
457 (defun array-copy-backward (&optional arg)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
458 "Copy the current field one array column to the left.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
459 If optional ARG is given, copy through ARG array columns to the left."
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
460 (interactive "p")
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
461 (array-copy-forward (- arg)))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
462
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
463 (defun array-copy-column-forward (&optional arg)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
464 "Copy the entire current column in to the column to the right.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
465 If optional ARG is given, copy through ARG array columns to the right."
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
466 (interactive "p")
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
467 (array-update-buffer-position)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
468 (array-update-array-position)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
469 (if (not array-column)
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
470 (error "Cursor is not in a valid array cell"))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
471 (message "Working...")
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
472 (let ((this-row 0))
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
473 (while (< this-row array-max-row)
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
474 (setq this-row (1+ this-row))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
475 (array-move-to-cell this-row array-column)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
476 (array-update-buffer-position)
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
477 (let ((array-copy-string (array-field-string)))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
478 (if (= (abs arg) 1)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
479 (array-copy-once-horizontally arg)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
480 (array-copy-to-column
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
481 (limit-index (+ array-column arg) array-max-column))))))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
482 (message "Working...done")
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
483 (array-move-to-row array-row)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
484 (array-normalize-cursor))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
485
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
486 (defun array-copy-column-backward (&optional arg)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
487 "Copy the entire current column one column to the left.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
488 If optional ARG is given, copy through ARG columns to the left."
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
489 (interactive "p")
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
490 (array-copy-column-forward (- arg)))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
491
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
492 (defun array-copy-row-down (&optional arg)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
493 "Copy the entire current row one row down.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
494 If optional ARG is given, copy through ARG rows down."
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
495 (interactive "p")
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
496 (array-update-buffer-position)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
497 (array-update-array-position)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
498 (if (not array-row)
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
499 (error "Cursor is not in a valid array cell"))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
500 (cond
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
501 ((and (= array-row 1) (= arg -1))
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
502 (error "Beginning of array"))
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
503 ((and (= array-row array-max-row) (= arg 1))
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
504 (error "End of array"))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
505 (t
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
506 (let* ((array-copy-string
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
507 (buffer-substring
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
508 (save-excursion (array-move-to-cell array-row 1)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
509 (point))
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
510 (save-excursion (array-move-to-cell array-row array-max-column)
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
511 (forward-line 1)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
512 (point))))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
513 (this-row array-row)
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
514 (goal-row (limit-index (+ this-row arg) array-max-row))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
515 (num (- goal-row this-row))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
516 (count (abs num))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
517 (sign (if (not (zerop count)) (/ num count))))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
518 (while (> count 0)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
519 (setq this-row (+ this-row sign))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
520 (array-move-to-cell this-row 1)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
521 (let ((inhibit-quit t))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
522 (delete-region (point)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
523 (save-excursion
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
524 (array-move-to-cell this-row array-max-column)
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
525 (forward-line 1)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
526 (point)))
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
527 (insert array-copy-string))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
528 (setq count (1- count)))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
529 (array-move-to-cell goal-row (or array-column 1)))))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
530 (array-normalize-cursor))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
531
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
532 (defun array-copy-row-up (&optional arg)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
533 "Copy the entire current array row into the row above.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
534 If optional ARG is given, copy through ARG rows up."
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
535 (interactive "p")
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
536 (array-copy-row-down (- arg)))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
537
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
538 (defun array-fill-rectangle ()
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
539 "Copy the field at mark into every cell between mark and point."
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
540 (interactive)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
541 ;; Bind arguments.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
542 (array-update-buffer-position)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
543 (let ((p-row (or (array-current-row)
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
544 (error "Cursor is not in a valid array cell")))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
545 (p-column (or (array-current-column)
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
546 (error "Cursor is not in a valid array cell")))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
547 (m-row
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
548 (save-excursion
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
549 (exchange-point-and-mark)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
550 (array-update-buffer-position)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
551 (or (array-current-row)
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
552 (error "Mark is not in a valid array cell"))))
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
553 (m-column
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
554 (save-excursion
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
555 (exchange-point-and-mark)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
556 (array-update-buffer-position)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
557 (or (array-current-column)
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
558 (error "Mark is not in a valid array cell")))))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
559 (message "Working...")
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
560 (let ((top-row (min m-row p-row))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
561 (bottom-row (max m-row p-row))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
562 (left-column (min m-column p-column))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
563 (right-column (max m-column p-column)))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
564 ;; Do the first row.
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
565 (let ((array-copy-string
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
566 (save-excursion
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
567 (array-move-to-cell m-row m-column)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
568 (array-update-buffer-position)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
569 (array-field-string))))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
570 (array-copy-to-cell top-row left-column)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
571 (array-update-array-position top-row left-column)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
572 (array-update-buffer-position)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
573 (array-copy-to-column right-column))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
574 ;; Do the rest of the rows.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
575 (array-move-to-cell top-row left-column)
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
576 (let ((array-copy-string
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
577 (buffer-substring
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
578 (point)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
579 (save-excursion
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
580 (array-move-to-cell top-row right-column)
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
581 (setq array-buffer-column (current-column))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
582 (array-end-of-field t)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
583 (point))))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
584 (this-row top-row))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
585 (while (/= this-row bottom-row)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
586 (setq this-row (1+ this-row))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
587 (array-move-to-cell this-row left-column)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
588 (let ((inhibit-quit t))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
589 (delete-region
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
590 (point)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
591 (save-excursion
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
592 (array-move-to-cell this-row right-column)
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
593 (setq array-buffer-column (current-column))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
594 (array-end-of-field t)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
595 (point)))
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
596 (insert array-copy-string)))))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
597 (message "Working...done")
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
598 (array-goto-cell p-row p-column)))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
599
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
600
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
601
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
602 ;;; Reconfiguration of the array.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
603
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
604 (defun array-make-template ()
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
605 "Create the template of an array."
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
606 (interactive)
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
607 ;; If there is a conflict between array-field-width and init-string, resolve it.
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
608 (let ((check t)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
609 (len))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
610 (while check
62458
2c228409c44d Replace `read-input' by `read-string'.
Juanma Barranquero <lekktu@gmail.com>
parents: 62402
diff changeset
611 (setq array-init-field (read-string "Initial field value: "))
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
612 (setq len (length array-init-field))
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
613 (if (/= len array-field-width)
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
614 (if (y-or-n-p (format "Change field width to %d? " len))
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
615 (progn (setq array-field-width len)
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
616 (setq check nil)))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
617 (setq check nil))))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
618 (goto-char (point-min))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
619 (message "Working...")
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
620 (let ((this-row 1))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
621 ;; Loop through the rows.
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
622 (while (<= this-row array-max-row)
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
623 (if array-rows-numbered
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
624 (insert (format "%d:\n" this-row)))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
625 (let ((this-column 1))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
626 ;; Loop through the columns.
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
627 (while (<= this-column array-max-column)
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
628 (insert array-init-field)
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
629 (if (and (zerop (% this-column array-columns-per-line))
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
630 (/= this-column array-max-column))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
631 (newline))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
632 (setq this-column (1+ this-column))))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
633 (setq this-row (1+ this-row))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
634 (newline)))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
635 (message "Working...done")
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
636 (array-goto-cell 1 1))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
637
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
638 (defun array-reconfigure-rows (new-columns-per-line new-rows-numbered)
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
639 "Reconfigure the state of `array-rows-numbered' and `array-columns-per-line'.
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
640 NEW-COLUMNS-PER-LINE is the desired value of `array-columns-per-line' and
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
641 NEW-ROWS-NUMBERED (a character, either ?y or ?n) is the desired value
64429
dd1d759e63db (array-mode, array-reconfigure-rows, untabify-backward): Fix typos in
Juanma Barranquero <lekktu@gmail.com>
parents: 64091
diff changeset
642 of `array-rows-numbered'."
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
643 (interactive "nColumns per line: \ncRows numbered? (y or n) ")
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
644 ;; Check on new-columns-per-line
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
645 (let ((check t))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
646 (while check
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
647 (if (and (>= new-columns-per-line 1)
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
648 (<= new-columns-per-line array-max-column))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
649 (setq check nil)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
650 (setq new-columns-per-line
62402
a7e02ef1e3d6 Replace `string-to-int' by `string-to-number'.
Juanma Barranquero <lekktu@gmail.com>
parents: 52401
diff changeset
651 (string-to-number
62458
2c228409c44d Replace `read-input' by `read-string'.
Juanma Barranquero <lekktu@gmail.com>
parents: 62402
diff changeset
652 (read-string
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
653 (format "Columns per line (1 - %d): " array-max-column)))))))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
654 ;; Check on new-rows-numbered. It has to be done this way
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
655 ;; because interactive does not have y-or-n-p.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
656 (cond
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
657 ((eq new-rows-numbered ?y)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
658 (setq new-rows-numbered t))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
659 ((eq new-rows-numbered ?n)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
660 (setq new-rows-numbered nil))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
661 (t
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
662 (setq new-rows-numbered (y-or-n-p "Rows numbered? "))))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
663 (message "Working...")
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
664 (array-update-buffer-position)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
665 (let* ((main-buffer (buffer-name (current-buffer)))
25428
4caa1d53d0e4 (array-reconfigure-rows): Use generate-new-buffer.
Richard M. Stallman <rms@gnu.org>
parents: 25226
diff changeset
666 (temp-buffer (generate-new-buffer " *Array*"))
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
667 (temp-max-row array-max-row)
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
668 (temp-max-column array-max-column)
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
669 (old-rows-numbered array-rows-numbered)
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
670 (old-columns-per-line array-columns-per-line)
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
671 (old-lines-per-row array-lines-per-row)
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
672 (old-field-width array-field-width)
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
673 (old-line-length array-line-length)
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
674 (this-row 1))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
675 (array-update-array-position)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
676 ;; Do the cutting in a temporary buffer.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
677 (copy-to-buffer temp-buffer (point-min) (point-max))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
678 (set-buffer temp-buffer)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
679 (goto-char (point-min))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
680 (while (<= this-row temp-max-row)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
681 ;; Deal with row number.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
682 (cond
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
683 ((or (and old-rows-numbered new-rows-numbered)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
684 (and (not old-rows-numbered) (not new-rows-numbered)))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
685 ;; Nothing is changed.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
686 ())
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
687 ((and old-rows-numbered (not new-rows-numbered))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
688 ;; Delete the row number.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
689 (kill-line 1))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
690 (t
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
691 ;; Add the row number.
41567
37ca208c68f0 (array-reconfigure-rows): Use insert instead of insert-string.
Pavel Janík <Pavel@Janik.cz>
parents: 38412
diff changeset
692 (insert (format "%d:\n" this-row))))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
693 ;; Deal with the array columns in this row.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
694 (cond
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
695 ((= old-columns-per-line new-columns-per-line)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
696 ;; Nothing is changed. Go to the next row.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
697 (forward-line (- old-lines-per-row (if old-rows-numbered 1 0))))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
698 (t
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
699 ;; First expand the row. Then cut it up into new pieces.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
700 (let ((newlines-to-be-removed
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
701 (floor (1- temp-max-column) old-columns-per-line))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
702 (newlines-removed 0)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
703 (newlines-to-be-added
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
704 (floor (1- temp-max-column) new-columns-per-line))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
705 (newlines-added 0))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
706 (while (< newlines-removed newlines-to-be-removed)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
707 (move-to-column-untabify
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
708 (* (1+ newlines-removed) old-line-length))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
709 (kill-line 1)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
710 (setq newlines-removed (1+ newlines-removed)))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
711 (beginning-of-line)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
712 (while (< newlines-added newlines-to-be-added)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
713 (move-to-column-untabify (* old-field-width new-columns-per-line))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
714 (newline)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
715 (setq newlines-added (1+ newlines-added)))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
716 (forward-line 1))))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
717 (setq this-row (1+ this-row)))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
718 (let ((inhibit-quit t))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
719 (set-buffer main-buffer)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
720 (erase-buffer)
64429
dd1d759e63db (array-mode, array-reconfigure-rows, untabify-backward): Fix typos in
Juanma Barranquero <lekktu@gmail.com>
parents: 64091
diff changeset
721 (insert-buffer-substring temp-buffer)
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
722 ;; Update local variables.
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
723 (setq array-columns-per-line new-columns-per-line)
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
724 (setq array-rows-numbered new-rows-numbered)
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
725 (setq array-line-length (* old-field-width new-columns-per-line))
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
726 (setq array-lines-per-row
4514
e64f012944e0 (abs, ceiling, floor): Remove, since they now redefine
Paul Eggert <eggert@twinsun.com>
parents: 2307
diff changeset
727 (+ (floor (1- temp-max-column) new-columns-per-line)
e64f012944e0 (abs, ceiling, floor): Remove, since they now redefine
Paul Eggert <eggert@twinsun.com>
parents: 2307
diff changeset
728 (if new-rows-numbered 2 1)))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
729 (array-goto-cell (or array-row 1) (or array-column 1)))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
730 (kill-buffer temp-buffer))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
731 (message "Working...done"))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
732
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
733 (defun array-expand-rows ()
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
734 "Expand the rows so each fits on one line and remove row numbers."
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
735 (interactive)
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
736 (array-reconfigure-rows array-max-column ?n))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
737
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
738
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
739
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
740 ;;; Utilities.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
741
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
742 (defun limit-index (index limit)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
743 (cond ((< index 1) 1)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
744 ((> index limit) limit)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
745 (t index)))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
746
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
747 (defun xor (pred1 pred2)
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
748 "Return the logical exclusive or of predicates PRED1 and PRED2."
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
749 (and (or pred1 pred2)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
750 (not (and pred1 pred2))))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
751
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
752 (defun current-line ()
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
753 "Return the current buffer line at point. The first line is 0."
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
754 (save-excursion
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
755 (beginning-of-line)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
756 (count-lines (point-min) (point))))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
757
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
758 (defun move-to-column-untabify (column)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
759 "Move to COLUMN on the current line, untabifying if necessary.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
760 Return COLUMN."
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
761 (or (and (= column (move-to-column column))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
762 column)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
763 ;; There is a tab in the way.
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
764 (if array-respect-tabs
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
765 (error "There is a TAB character in the way")
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
766 (progn
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
767 (untabify-backward)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
768 (move-to-column column)))))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
769
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
770 (defun untabify-backward ()
64429
dd1d759e63db (array-mode, array-reconfigure-rows, untabify-backward): Fix typos in
Juanma Barranquero <lekktu@gmail.com>
parents: 64091
diff changeset
771 "Untabify the preceding TAB."
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
772 (save-excursion
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
773 (let ((start (point)))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
774 (backward-char 1)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
775 (untabify (point) start))))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
776
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
777
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
778
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
779 ;;; Array mode.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
780
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
781 (defvar array-mode-map nil
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
782 "Keymap used in array mode.")
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
783
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
784 (if array-mode-map
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
785 ()
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
786 (setq array-mode-map (make-keymap))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
787 ;; Bind keys.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
788 (define-key array-mode-map "\M-ad" 'array-display-local-variables)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
789 (define-key array-mode-map "\M-am" 'array-make-template)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
790 (define-key array-mode-map "\M-ae" 'array-expand-rows)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
791 (define-key array-mode-map "\M-ar" 'array-reconfigure-rows)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
792 (define-key array-mode-map "\M-a=" 'array-what-position)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
793 (define-key array-mode-map "\M-ag" 'array-goto-cell)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
794 (define-key array-mode-map "\M-af" 'array-fill-rectangle)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
795 (define-key array-mode-map "\C-n" 'array-next-row)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
796 (define-key array-mode-map "\C-p" 'array-previous-row)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
797 (define-key array-mode-map "\C-f" 'array-forward-column)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
798 (define-key array-mode-map "\C-b" 'array-backward-column)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
799 (define-key array-mode-map "\M-n" 'array-copy-down)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
800 (define-key array-mode-map "\M-p" 'array-copy-up)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
801 (define-key array-mode-map "\M-f" 'array-copy-forward)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
802 (define-key array-mode-map "\M-b" 'array-copy-backward)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
803 (define-key array-mode-map "\M-\C-n" 'array-copy-row-down)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
804 (define-key array-mode-map "\M-\C-p" 'array-copy-row-up)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
805 (define-key array-mode-map "\M-\C-f" 'array-copy-column-forward)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
806 (define-key array-mode-map "\M-\C-b" 'array-copy-column-backward))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
807
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
808 (put 'array-mode 'mode-class 'special)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
809
21631
e9650ae37732 (array-mode): Add autoload cookie.
Dave Love <fx@gnu.org>
parents: 14338
diff changeset
810 ;;;###autoload
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
811 (defun array-mode ()
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
812 "Major mode for editing arrays.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
813
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
814 Array mode is a specialized mode for editing arrays. An array is
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
815 considered to be a two-dimensional set of strings. The strings are
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
816 NOT recognized as integers or real numbers.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
817
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
818 The array MUST reside at the top of the buffer.
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
819
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
820 TABs are not respected, and may be converted into spaces at any time.
64429
dd1d759e63db (array-mode, array-reconfigure-rows, untabify-backward): Fix typos in
Juanma Barranquero <lekktu@gmail.com>
parents: 64091
diff changeset
821 Setting the variable `array-respect-tabs' to non-nil will prevent TAB conversion,
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
822 but will cause many functions to give errors if they encounter one.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
823
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
824 Upon entering array mode, you will be prompted for the values of
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
825 several variables. Others will be calculated based on the values you
42704
6d7f6edfdb45 Fix typo.
Pavel Janík <Pavel@Janik.cz>
parents: 41567
diff changeset
826 supply. These variables are all local to the buffer. Other buffer
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
827 in array mode may have different values assigned to the variables.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
828 The variables are:
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
829
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
830 Variables you assign:
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
831 array-max-row: The number of rows in the array.
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
832 array-max-column: The number of columns in the array.
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
833 array-columns-per-line: The number of columns in the array per line of buffer.
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
834 array-field-width: The width of each field, in characters.
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
835 array-rows-numbered: A logical variable describing whether to ignore
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
836 row numbers in the buffer.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
837
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
838 Variables which are calculated:
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
839 array-line-length: The number of characters in a buffer line.
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
840 array-lines-per-row: The number of buffer lines used to display each row.
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
841
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
842 The following commands are available (an asterisk indicates it may
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
843 take a numeric prefix argument):
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
844
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
845 * \\<array-mode-map>\\[array-forward-column] Move forward one column.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
846 * \\[array-backward-column] Move backward one column.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
847 * \\[array-next-row] Move down one row.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
848 * \\[array-previous-row] Move up one row.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
849
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
850 * \\[array-copy-forward] Copy the current field into the column to the right.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
851 * \\[array-copy-backward] Copy the current field into the column to the left.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
852 * \\[array-copy-down] Copy the current field into the row below.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
853 * \\[array-copy-up] Copy the current field into the row above.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
854
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
855 * \\[array-copy-column-forward] Copy the current column into the column to the right.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
856 * \\[array-copy-column-backward] Copy the current column into the column to the left.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
857 * \\[array-copy-row-down] Copy the current row into the row below.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
858 * \\[array-copy-row-up] Copy the current row into the row above.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
859
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
860 \\[array-fill-rectangle] Copy the field at mark into every cell with row and column
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
861 between that of point and mark.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
862
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
863 \\[array-what-position] Display the current array row and column.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
864 \\[array-goto-cell] Go to a particular array cell.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
865
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
866 \\[array-make-template] Make a template for a new array.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
867 \\[array-reconfigure-rows] Reconfigure the array.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
868 \\[array-expand-rows] Expand the array (remove row numbers and
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
869 newlines inside rows)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
870
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
871 \\[array-display-local-variables] Display the current values of local variables.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
872
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
873 Entering array mode calls the function `array-mode-hook'."
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
874
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
875 (interactive)
62715
d07ea6e0706b (array-mode): Use kill-all-local-variables and run-mode-hooks.
Lute Kamstra <lute@gnu.org>
parents: 62458
diff changeset
876 (kill-all-local-variables)
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
877 ;; Number of rows in the array.
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
878 (make-local-variable 'array-max-row)
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
879 ;; Number of columns in the array.
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
880 (make-local-variable 'array-max-column)
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
881 ;; Number of array columns per line.
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
882 (make-local-variable 'array-columns-per-line)
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
883 ;; Width of a field in the array.
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
884 (make-local-variable 'array-field-width)
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
885 ;; Are rows numbered in the buffer?
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
886 (make-local-variable 'array-rows-numbered)
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
887 ;; Length of a line in the array.
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
888 (make-local-variable 'array-line-length)
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
889 ;; Number of lines per array row.
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
890 (make-local-variable 'array-lines-per-row)
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
891 ;; Current line number of point in the buffer.
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
892 (make-local-variable 'array-buffer-line)
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
893 ;; Current column number of point in the buffer.
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
894 (make-local-variable 'array-buffer-column)
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
895 ;; Current array row location of point.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
896 (make-local-variable 'array-row)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
897 ;; Current array column location of point.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
898 (make-local-variable 'array-column)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
899 ;; Current field string being copied.
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
900 (make-local-variable 'array-copy-string)
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
901 ;; Should TAB conversion be prevented?
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
902 (make-local-variable 'array-respect-tabs)
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
903 (setq array-respect-tabs nil)
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
904 (array-init-local-variables)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
905 (setq major-mode 'array-mode)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
906 (setq mode-name "Array")
11591
5f3aa9df448e (array-mode): Use force-mode-line-update.
Karl Heuer <kwzh@gnu.org>
parents: 4514
diff changeset
907 (force-mode-line-update)
27286
d3c2ea889aa8 (array-mode): Don't use make-variable-buffer-local.
Richard M. Stallman <rms@gnu.org>
parents: 27227
diff changeset
908 (make-local-variable 'truncate-lines)
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
909 (setq truncate-lines t)
13603
cb0d1b1782f4 (array-mode): Set overwrite-mode to overwrite-mode-textual.
Richard M. Stallman <rms@gnu.org>
parents: 11591
diff changeset
910 (setq overwrite-mode 'overwrite-mode-textual)
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
911 (use-local-map array-mode-map)
62715
d07ea6e0706b (array-mode): Use kill-all-local-variables and run-mode-hooks.
Lute Kamstra <lute@gnu.org>
parents: 62458
diff changeset
912 (run-mode-hooks 'array-mode-hook))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
913
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
914
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
915
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
916 ;;; Initialization functions. These are not interactive.
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
917
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
918 (defun array-init-local-variables ()
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
919 "Initialize the variables associated with the array in this buffer."
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
920 (array-init-max-row)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
921 (array-init-max-column)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
922 (array-init-columns-per-line)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
923 (array-init-field-width)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
924 (array-init-rows-numbered)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
925 (array-init-line-length)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
926 (array-init-lines-per-row)
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
927 (message ""))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
928
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
929 (defun array-init-max-row (&optional arg)
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
930 "Initialize the value of `array-max-row'."
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
931 (setq array-max-row
62458
2c228409c44d Replace `read-input' by `read-string'.
Juanma Barranquero <lekktu@gmail.com>
parents: 62402
diff changeset
932 (or arg (string-to-number (read-string "Number of array rows: ")))))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
933
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
934 (defun array-init-max-column (&optional arg)
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
935 "Initialize the value of `array-max-column'."
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
936 (setq array-max-column
62458
2c228409c44d Replace `read-input' by `read-string'.
Juanma Barranquero <lekktu@gmail.com>
parents: 62402
diff changeset
937 (or arg (string-to-number (read-string "Number of array columns: ")))))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
938
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
939 (defun array-init-columns-per-line (&optional arg)
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
940 "Initialize the value of `array-columns-per-line'."
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
941 (setq array-columns-per-line
62458
2c228409c44d Replace `read-input' by `read-string'.
Juanma Barranquero <lekktu@gmail.com>
parents: 62402
diff changeset
942 (or arg (string-to-number (read-string "Array columns per line: ")))))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
943
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
944 (defun array-init-field-width (&optional arg)
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
945 "Initialize the value of `array-field-width'."
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
946 (setq array-field-width
62458
2c228409c44d Replace `read-input' by `read-string'.
Juanma Barranquero <lekktu@gmail.com>
parents: 62402
diff changeset
947 (or arg (string-to-number (read-string "Field width: ")))))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
948
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
949 (defun array-init-rows-numbered (&optional arg)
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
950 "Initialize the value of `array-rows-numbered'."
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
951 (setq array-rows-numbered
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
952 (or arg (y-or-n-p "Rows numbered? "))))
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
953
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
954 (defun array-init-line-length (&optional arg)
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
955 "Initialize the value of `array-line-length'."
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
956 (setq array-line-length
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
957 (or arg
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
958 (* array-field-width array-columns-per-line))))
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
959
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
960 (defun array-init-lines-per-row (&optional arg)
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
961 "Initialize the value of `array-lines-per-row'."
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
962 (setq array-lines-per-row
180
289ee39b1637 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
963 (or arg
27227
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
964 (+ (floor (1- array-max-column) array-columns-per-line)
10ee0084db53 Assorted cleanups for compiler warnings, doc strings, `array-' prefix
Dave Love <fx@gnu.org>
parents: 25428
diff changeset
965 (if array-rows-numbered 2 1)))))
662
8a533acedb77 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 180
diff changeset
966
25226
0ff7a16ab8f9 Provide `array'.
Karl Heuer <kwzh@gnu.org>
parents: 21631
diff changeset
967 (provide 'array)
0ff7a16ab8f9 Provide `array'.
Karl Heuer <kwzh@gnu.org>
parents: 21631
diff changeset
968
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 49588
diff changeset
969 ;;; arch-tag: 0086605d-79fe-4a1a-992a-456417261f80
662
8a533acedb77 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 180
diff changeset
970 ;;; array.el ends here