Commit 2bb63e81 authored by Vincent Belaïche's avatar Vincent Belaïche
Browse files

Fix commenting and indenting convention.

parent 1f773f32
2011-06-27 Vincent Belaïche <vincentb1@users.sourceforge.net>
* ses.el: Fix commenting and indenting convention.
2011-06-27 Stefan Monnier <monnier@iro.umontreal.ca>
* bs.el (bs-cycle-next): Complete last change.
......
......@@ -3,8 +3,8 @@
;; Copyright (C) 2002-2011 Free Software Foundation, Inc.
;; Author: Jonathan Yavner <jyavner@member.fsf.org>
;; Maintainer: Jonathan Yavner <jyavner@member.fsf.org>
;; Keywords: spreadsheet
;; Maintainer: Vincent Belaïche <vincentb1@users.sourceforge.net>
;; Keywords: spreadsheet Dijkstra
;; This file is part of GNU Emacs.
......@@ -154,7 +154,7 @@ Each function is called with ARG=1."
(defalias 'ses-mode-print-map
(let ((keys '([backtab] backward-char
[tab] ses-forward-or-insert
"\C-i" ses-forward-or-insert ;Needed for ses-coverage.el?
"\C-i" ses-forward-or-insert ; Needed for ses-coverage.el?
"\M-o" ses-insert-column
"\C-o" ses-insert-row
"\C-m" ses-edit-cell
......@@ -225,10 +225,10 @@ Each function is called with ARG=1."
"Initial contents for the file-trailer area at the bottom of the file.")
(defconst ses-initial-file-contents
(concat " \n" ;One blank cell in print area
(concat " \n" ; One blank cell in print area.
ses-print-data-boundary
"(ses-cell A1 nil nil nil nil)\n" ;One blank cell in data area
"\n" ;End-of-row terminator for the one row in data area
"(ses-cell A1 nil nil nil nil)\n" ; One blank cell in data area.
"\n" ; End-of-row terminator for the one row in data area.
"(ses-column-widths [7])\n"
"(ses-column-printers [nil])\n"
"(ses-default-printer \"%.7g\")\n"
......@@ -271,7 +271,7 @@ default printer and then modify its output.")
(make-local-variable x)
(set x nil)))
;;;This variable is documented as being permitted in file-locals:
;;; This variable is documented as being permitted in file-locals:
(put 'ses--symbolic-formulas 'safe-local-variable 'consp)
(defconst ses-paramlines-plist
......@@ -514,7 +514,7 @@ for this spreadsheet."
0-25 become A-Z; 26-701 become AA-ZZ, and so on."
(let ((units (char-to-string (+ ?A (% col 26)))))
(if (< col 26)
units
units
(concat (ses-column-letter (1- (/ col 26))) units))))
(defun ses-create-cell-symbol (row col)
......@@ -584,7 +584,7 @@ cell (ROW,COL). This is undoable. The cell's data will be updated through
(ses-aset-with-undo cell elt val)))
(if change
(add-to-list 'ses--deferred-write (cons row col))))
nil) ;Make coverage-tester happy
nil) ; Make coverage-tester happy.
(defun ses-cell-set-formula (row col formula)
"Store a new formula for (ROW . COL) and enqueues the cell for
......@@ -642,7 +642,7 @@ the old and FORCE is nil."
(setq formula-error sig
newval '*error*)))
(if (and (not newval) (eq oldval '*skip*))
;;Don't lose the *skip* - previous field spans this one
;; Don't lose the *skip* --- previous field spans this one.
(setq newval '*skip*))
(when (or force (not (eq newval oldval)))
(add-to-list 'ses--deferred-write (cons row col)) ;In case force=t
......@@ -667,10 +667,11 @@ if the cell's value is unchanged and FORCE is nil."
curlist prevlist rowcol formula)
(with-temp-message " "
(while (and ses--deferred-recalc (not (equal nextlist prevlist)))
;;In each loop, recalculate cells that refer only to other cells that
;;have already been recalculated or aren't in the recalculation
;;region. Repeat until all cells have been processed or until the
;;set of cells being worked on stops changing.
;; In each loop, recalculate cells that refer only to other
;; cells that have already been recalculated or aren't in the
;; recalculation region. Repeat until all cells have been
;; processed or until the set of cells being worked on stops
;; changing.
(if prevlist
(message "Recalculating... (%d cells left)"
(length ses--deferred-recalc)))
......@@ -690,7 +691,7 @@ if the cell's value is unchanged and FORCE is nil."
;;ses-update-cells is called from post-command-hook, so
;;inhibit-quit is implicitly bound to t.
(when quit-flag
;;Abort the recalculation. User will probably undo now.
;; Abort the recalculation. User will probably undo now.
(error "Quit"))
(ses-calculate-cell (car rowcol) (cdr rowcol) force))
(setq curlist (cdr curlist)))
......@@ -701,15 +702,15 @@ if the cell's value is unchanged and FORCE is nil."
;;We'll go around the loop one more time.
(add-to-list 'nextlist t)))
(when ses--deferred-recalc
;;Just couldn't finish these
;; Just couldn't finish these.
(dolist (x ses--deferred-recalc)
(let ((rowcol (ses-sym-rowcol x)))
(ses-set-cell (car rowcol) (cdr rowcol) 'value '*error*)
(1value (ses-print-cell (car rowcol) (cdr rowcol)))))
(error "Circular references: %s" ses--deferred-recalc))
(message " "))
;;Can't use save-excursion here: if the cell under point is
;;updated, save-excusion's marker will move past the cell.
;; Can't use save-excursion here: if the cell under point is updated,
;; save-excusion's marker will move past the cell.
(goto-char pos)))
......@@ -721,22 +722,22 @@ if the cell's value is unchanged and FORCE is nil."
"Returns t if point is in print area of spreadsheet."
(<= (point) ses--data-marker))
;;We turn off point-motion-hooks and explicitly position the cursor, in case
;;the intangible properties have gotten screwed up (e.g., when
;;ses-goto-print is called during a recursive ses-print-cell).
;; We turn off point-motion-hooks and explicitly position the cursor, in case
;; the intangible properties have gotten screwed up (e.g., when ses-goto-print
;; is called during a recursive ses-print-cell).
(defun ses-goto-print (row col)
"Move point to print area for cell (ROW,COL)."
(let ((inhibit-point-motion-hooks t)
(n 0))
(goto-char (point-min))
(forward-line row)
;; calculate column position
;; Calculate column position.
(dotimes (c col)
(setq n (+ n (ses-col-width c) 1)))
;; move to the position
;; Move to the position.
(and (> n (move-to-column n))
(eolp)
;; move point to the bol of next line (for TAB at the last cell)
;; Move point to the bol of next line (for TAB at the last cell).
(forward-char))))
(defun ses-set-curcell ()
......@@ -745,13 +746,13 @@ region, or nil if cursor is not at a cell."
(if (or (not mark-active)
deactivate-mark
(= (region-beginning) (region-end)))
;;Single cell
;; Single cell.
(setq ses--curcell (get-text-property (point) 'intangible))
;;Range
;; Range.
(let ((bcell (get-text-property (region-beginning) 'intangible))
(ecell (get-text-property (1- (region-end)) 'intangible)))
(when (= (region-end) ses--data-marker)
;;Correct for overflow
;; Correct for overflow.
(setq ecell (get-text-property (- (region-end) 2) 'intangible)))
(setq ses--curcell (if (and bcell ecell)
(cons bcell ecell)
......@@ -764,7 +765,7 @@ appropriate if some argument is 'end. A range is appropriate if some
argument is 'range. A single cell is appropriate unless some argument is
'needrange."
(if (eq ses--curcell t)
;;curcell recalculation was postponed, but user typed ahead
;; curcell recalculation was postponed, but user typed ahead.
(ses-set-curcell))
(cond
((not ses--curcell)
......@@ -791,53 +792,53 @@ preceding cell has spilled over."
(printer (ses-cell-printer cell))
(maxcol (1+ col))
text sig startpos x)
;;Create the string to print
;; Create the string to print.
(cond
((eq value '*skip*)
;;Don't print anything
;; Don't print anything.
(throw 'ses-print-cell nil))
((eq value '*error*)
(setq text (make-string (ses-col-width col) ?#)))
(t
;;Deferred safety-check on printer
;; Deferred safety-check on printer.
(if (eq (car-safe printer) 'ses-safe-printer)
(ses-set-cell row col 'printer
(setq printer (ses-safe-printer (cadr printer)))))
;;Print the value
;; Print the value.
(setq text (ses-call-printer (or printer
(ses-col-printer col)
ses--default-printer)
value))
(if (consp ses-call-printer-return)
;;Printer returned an error
;; Printer returned an error.
(setq sig ses-call-printer-return))))
;;Adjust print width to match column width
;; Adjust print width to match column width.
(let ((width (ses-col-width col))
(len (string-width text)))
(cond
((< len width)
;;Fill field to length with spaces
;; Fill field to length with spaces.
(setq len (make-string (- width len) ?\s)
text (if (eq ses-call-printer-return t)
(concat text len)
(concat len text))))
((> len width)
;;Spill over into following cells, if possible
;; Spill over into following cells, if possible.
(let ((maxwidth width))
(while (and (> len maxwidth)
(< maxcol ses--numcols)
(or (not (setq x (ses-cell-value row maxcol)))
(eq x '*skip*)))
(unless x
;;Set this cell to '*skip* so it won't overwrite our spillover
;; Set this cell to '*skip* so it won't overwrite our spillover.
(ses-set-cell row maxcol 'value '*skip*))
(setq maxwidth (+ maxwidth (ses-col-width maxcol) 1)
maxcol (1+ maxcol)))
(if (<= len maxwidth)
;;Fill to complete width of all the fields spanned
;; Fill to complete width of all the fields spanned.
(setq text (concat text (make-string (- maxwidth len) ?\s)))
;;Not enough room to end of line or next non-nil field. Truncate
;;if string or decimal; otherwise fill with error indicator
;; Not enough room to end of line or next non-nil field. Truncate
;; if string or decimal; otherwise fill with error indicator.
(setq sig `(error "Too wide" ,text))
(cond
((stringp value)
......@@ -854,12 +855,12 @@ preceding cell has spilled over."
(substring text (match-end 0)))))
(t
(setq text (make-string maxwidth ?#)))))))))
;;Substitute question marks for tabs and newlines. Newlines are
;;used as row-separators; tabs could confuse the reimport logic.
;; Substitute question marks for tabs and newlines. Newlines are used as
;; row-separators; tabs could confuse the reimport logic.
(setq text (replace-regexp-in-string "[\t\n]" "?" text))
(ses-goto-print row col)
(setq startpos (point))
;;Install the printed result. This is not interruptible.
;; Install the printed result. This is not interruptible.
(let ((inhibit-read-only t)
(inhibit-quit t))
(let ((inhibit-point-motion-hooks t))
......@@ -867,32 +868,32 @@ preceding cell has spilled over."
(move-to-column (+ (current-column)
(string-width text)))
(1+ (point)))))
;;We use concat instead of inserting separate strings in order to
;;reduce the number of cells in the undo list.
;; We use concat instead of inserting separate strings in order to
;; reduce the number of cells in the undo list.
(setq x (concat text (if (< maxcol ses--numcols) " " "\n")))
;;We use set-text-properties to prevent a wacky print function
;;from inserting rogue properties, and to ensure that the keymap
;;property is inherited (is it a bug that only unpropertied strings
;;actually inherit from surrounding text?)
;; We use set-text-properties to prevent a wacky print function from
;; inserting rogue properties, and to ensure that the keymap property is
;; inherited (is it a bug that only unpropertied strings actually
;; inherit from surrounding text?)
(set-text-properties 0 (length x) nil x)
(insert-and-inherit x)
(put-text-property startpos (point) 'intangible
(ses-cell-symbol cell))
(when (and (zerop row) (zerop col))
;;Reconstruct special beginning-of-buffer attributes
;; Reconstruct special beginning-of-buffer attributes.
(put-text-property (point-min) (point) 'keymap 'ses-mode-print-map)
(put-text-property (point-min) (point) 'read-only 'ses)
(put-text-property (point-min) (1+ (point-min)) 'front-sticky t)))
(if (= row (1- ses--header-row))
;;This line is part of the header - force recalc
;; This line is part of the header --- force recalc.
(ses-reset-header-string))
;;If this cell (or a preceding one on the line) previously spilled over
;;and has gotten shorter, redraw following cells on line recursively.
;; If this cell (or a preceding one on the line) previously spilled over
;; and has gotten shorter, redraw following cells on line recursively.
(when (and (< maxcol ses--numcols)
(eq (ses-cell-value row maxcol) '*skip*))
(ses-set-cell row maxcol 'value nil)
(ses-print-cell row maxcol))
;;Return to start of cell
;; Return to start of cell.
(goto-char startpos)
sig)))
......@@ -932,13 +933,13 @@ inhibit-quit to t."
(blank (if (> change 0) (make-string change ?\s)))
(at-end (= col ses--numcols)))
(ses-set-with-undo 'ses--linewidth (+ ses--linewidth change))
;;ses-set-with-undo always returns t for strings.
;; ses-set-with-undo always returns t for strings.
(1value (ses-set-with-undo 'ses--blank-line
(concat (make-string ses--linewidth ?\s) "\n")))
(dotimes (row ses--numrows)
(ses-goto-print row col)
(when at-end
;;Insert new columns before newline
;; Insert new columns before newline.
(let ((inhibit-point-motion-hooks t))
(backward-char 1)))
(if blank
......@@ -976,13 +977,13 @@ number, COL is the column number for a data cell -- otherwise DEF
is one of the symbols ses--col-widths, ses--col-printers,
ses--default-printer, ses--numrows, or ses--numcols."
(ses-widen)
(let ((inhibit-point-motion-hooks t)) ;In case intangible attrs are wrong
(let ((inhibit-point-motion-hooks t)) ; In case intangible attrs are wrong.
(if col
;;It's a cell
;; It's a cell.
(progn
(goto-char ses--data-marker)
(forward-line (+ 1 (* def (1+ ses--numcols)) col)))
;;Convert def-symbol to offset
;; Convert def-symbol to offset.
(setq def (plist-get ses-paramlines-plist def))
(or def (signal 'args-out-of-range nil))
(goto-char ses--params-marker)
......@@ -993,8 +994,8 @@ ses--default-printer, ses--numrows, or ses--numcols."
See `ses-goto-data' for meaning of DEF. Newlines in the data are escaped.
If ELEM is specified, it is the array subscript within DEF to be set to VALUE."
(save-excursion
;;We call ses-goto-data early, using the old values of numrows and
;;numcols in case one of them is being changed.
;; We call ses-goto-data early, using the old values of numrows and numcols
;; in case one of them is being changed.
(ses-goto-data def)
(let ((inhibit-read-only t)
(fmt (plist-get '(ses--col-widths "(ses-column-widths %S)"
......@@ -1012,7 +1013,7 @@ If ELEM is specified, it is the array subscript within DEF to be set to VALUE."
(aset (symbol-value def) elem value))
(setq oldval (symbol-value def))
(set def value))
;;Special undo since it's outside the narrowed buffer
;; Special undo since it's outside the narrowed buffer.
(let (buffer-undo-list)
(delete-region (point) (line-end-position))
(insert (format fmt (symbol-value def))))
......@@ -1042,7 +1043,7 @@ Newlines in the data are escaped."
(setq formula (cadr formula)))
(if (eq (car-safe printer) 'ses-safe-printer)
(setq printer (cadr printer)))
;;This is noticably faster than (format "%S %S %S %S %S")
;; This is noticably faster than (format "%S %S %S %S %S")
(setq text (concat "(ses-cell "
(symbol-name sym)
" "
......@@ -1129,7 +1130,7 @@ Sets `ses-relocate-return' to 'delete if cell-references were removed."
(if (setq rowcol (ses-sym-rowcol formula))
(ses-relocate-symbol formula rowcol
startrow startcol rowincr colincr)
formula) ;Pass through as-is
formula) ; Pass through as-is.
(dolist (cur formula)
(setq rowcol (ses-sym-rowcol cur))
(cond
......@@ -1138,9 +1139,9 @@ Sets `ses-relocate-return' to 'delete if cell-references were removed."
startrow startcol rowincr colincr))
(if cur
(push cur result)
;;Reference to a deleted cell. Set a flag in ses-relocate-return.
;;don't change the flag if it's already 'range, since range
;;implies 'delete.
;; Reference to a deleted cell. Set a flag in ses-relocate-return.
;; don't change the flag if it's already 'range, since range implies
;; 'delete.
(unless ses-relocate-return
(setq ses-relocate-return 'delete))))
((eq (car-safe cur) 'ses-range)
......@@ -1148,10 +1149,10 @@ Sets `ses-relocate-return' to 'delete if cell-references were removed."
(if cur
(push cur result)))
((or (atom cur) (eq (car cur) 'quote))
;;Constants pass through unchanged
;; Constants pass through unchanged.
(push cur result))
(t
;;Recursively copy and alter subformulas
;; Recursively copy and alter subformulas.
(push (ses-relocate-formula cur startrow startcol
rowincr colincr)
result))))
......@@ -1177,47 +1178,47 @@ if the range was altered."
field)
(cond
((and (not min) (not max))
(setq range nil)) ;;The entire range is deleted
(setq range nil)) ; The entire range is deleted.
((zerop colincr)
;;Inserting or deleting rows
;; Inserting or deleting rows.
(setq field 'car)
(if (not min)
;;Chopped off beginning of range
;; Chopped off beginning of range.
(setq min (ses-create-cell-symbol startrow (cdr minrowcol))
ses-relocate-return 'range))
(if (not max)
(if (> rowincr 0)
;;Trying to insert a nonexistent row
;; Trying to insert a nonexistent row.
(setq max (ses-create-cell-symbol (1- ses--numrows)
(cdr minrowcol)))
;;End of range is being deleted
;; End of range is being deleted.
(setq max (ses-create-cell-symbol (1- startrow) (cdr minrowcol))
ses-relocate-return 'range))
(and (> rowincr 0)
(= (car maxrowcol) (1- startrow))
(= (cdr minrowcol) (cdr maxrowcol))
;;Insert after ending row of vertical range - include it
;; Insert after ending row of vertical range --- include it.
(setq max (ses-create-cell-symbol (+ startrow rowincr -1)
(cdr maxrowcol))))))
(t
;;Inserting or deleting columns
;; Inserting or deleting columns.
(setq field 'cdr)
(if (not min)
;;Chopped off beginning of range
;; Chopped off beginning of range.
(setq min (ses-create-cell-symbol (car minrowcol) startcol)
ses-relocate-return 'range))
(if (not max)
(if (> colincr 0)
;;Trying to insert a nonexistent column
;; Trying to insert a nonexistent column.
(setq max (ses-create-cell-symbol (car maxrowcol)
(1- ses--numcols)))
;;End of range is being deleted
;; End of range is being deleted.
(setq max (ses-create-cell-symbol (car maxrowcol) (1- startcol))
ses-relocate-return 'range))
(and (> colincr 0)
(= (cdr maxrowcol) (1- startcol))
(= (car minrowcol) (car maxrowcol))
;;Insert after ending column of horizontal range - include it
;; Insert after ending column of horizontal range --- include it.
(setq max (ses-create-cell-symbol (car maxrowcol)
(+ startcol colincr -1)))))))
(when range
......@@ -1225,7 +1226,7 @@ if the range was altered."
(funcall field minrowcol))
(- (funcall field (ses-sym-rowcol max))
(funcall field (ses-sym-rowcol min))))
;;This range has changed size
;; This range has changed size.
(setq ses-relocate-return 'range))
(list 'ses-range min max))))
......@@ -1244,13 +1245,13 @@ to each symbol."
minrow mincol rowincr colincr))
(ses-set-cell row col 'formula newval)
(if (eq ses-relocate-return 'range)
;;This cell contains a (ses-range X Y) where a cell has been
;;inserted or deleted in the middle of the range.
;; This cell contains a (ses-range X Y) where a cell has been
;; inserted or deleted in the middle of the range.
(push (cons row col) reform))
(if ses-relocate-return
;;This cell referred to a cell that's been deleted or is no
;;longer part of the range. We can't fix that now because
;;reference lists cells have been partially updated.
;; This cell referred to a cell that's been deleted or is no
;; longer part of the range. We can't fix that now because
;; reference lists cells have been partially updated.
(add-to-list 'ses--deferred-recalc
(ses-create-cell-symbol row col)))
(setq newval (ses-relocate-formula (ses-cell-references mycell)
......@@ -1259,13 +1260,13 @@ to each symbol."
(and (>= row minrow) (>= col mincol)
(ses-set-cell row col 'symbol
(ses-create-cell-symbol row col))))))
;;Relocate the cell values
;; Relocate the cell values.
(let (oldval myrow mycol xrow xcol)
(cond
((and (<= rowincr 0) (<= colincr 0))
;;Deletion of rows and/or columns
;; Deletion of rows and/or columns.
(dotimes-with-progress-reporter
(row (- ses--numrows minrow)) "Relocating variables..."
(row (- ses--numrows minrow)) "Relocating variables..."
(setq myrow (+ row minrow))
(dotimes (col (- ses--numcols mincol))
(setq mycol (+ col mincol)
......@@ -1273,11 +1274,11 @@ to each symbol."
xcol (- mycol colincr))
(if (and (< xrow ses--numrows) (< xcol ses--numcols))
(setq oldval (ses-cell-value xrow xcol))
;;Cell is off the end of the array
;; Cell is off the end of the array.
(setq oldval (symbol-value (ses-create-cell-symbol xrow xcol))))
(ses-set-cell myrow mycol 'value oldval))))
((and (wholenump rowincr) (wholenump colincr))
;;Insertion of rows and/or columns. Run the loop backwards.
;; Insertion of rows and/or columns. Run the loop backwards.
(let ((disty (1- ses--numrows))
(distx (1- ses--numcols))
myrow mycol)
......@@ -1289,16 +1290,16 @@ to each symbol."
xrow (- myrow rowincr)
xcol (- mycol colincr))
(if (or (< xrow minrow) (< xcol mincol))
;;Newly-inserted value
;; Newly-inserted value.
(setq oldval nil)
;;Transfer old value
;; Transfer old value.
(setq oldval (ses-cell-value xrow xcol)))
(ses-set-cell myrow mycol 'value oldval)))
t)) ;Make testcover happy by returning non-nil here
t)) ; Make testcover happy by returning non-nil here.
(t
(error "ROWINCR and COLINCR must have the same sign"))))
;;Reconstruct reference lists for cells that contain ses-ranges that
;;have changed size.
;; Reconstruct reference lists for cells that contain ses-ranges that have
;; changed size.
(when reform
(message "Fixing ses-ranges...")
(let (row col)
......@@ -1324,9 +1325,9 @@ to each symbol."
(defun ses-set-with-undo (sym newval)
"Like set, but undoable. Result is t if value has changed."
;;We try to avoid adding redundant entries to the undo list, but this is
;;unavoidable for strings because equal ignores text properties and there's
;;no easy way to get the whole property list to see if it's different!
;; We try to avoid adding redundant entries to the undo list, but this is
;; unavoidable for strings because equal ignores text properties and there's
;; no easy way to get the whole property list to see if it's different!
(unless (and (boundp sym)
(equal (symbol-value sym) newval)
(not (stringp newval)))
......@@ -1339,14 +1340,15 @@ to each symbol."
(defun ses-unset-with-undo (sym)
"Set SYM to be unbound. This is undoable."
(when (1value (boundp sym)) ;;Always bound, except after a programming error
(when (1value (boundp sym)) ; Always bound, except after a programming error.
(push `(apply ses-set-with-undo ,sym ,(symbol-value sym)) buffer-undo-list)
(makunbound sym)))
(defun ses-aset-with-undo (array idx newval)
"Like aset, but undoable. Result is t if element has changed"
(unless (equal (aref array idx) newval)
(push `(apply ses-aset-with-undo ,array ,idx ,(aref array idx)) buffer-undo-list)
(push `(apply ses-aset-with-undo ,array ,idx
,(aref array idx)) buffer-undo-list)
(aset array idx newval)
t))
......@@ -1359,7 +1361,7 @@ to each symbol."
"Parse the current buffer and sets up buffer-local variables. Does not
execute cell formulas or print functions."
(widen)
;;Read our global parameters, which should be a 3-element list
;; Read our global parameters, which should be a 3-element list.
(goto-char (point-max))
(search-backward ";; Local Variables:\n" nil t)
(backward-list 1)
......@@ -1376,7 +1378,7 @@ execute cell formulas or print functions."
ses--numrows (cadr params)
ses--numcols (nth 2 params))
(when (= ses--file-format 1)
(let (buffer-undo-list) ;This is not undoable
(let (buffer-undo-list) ; This is not undoable.
(ses-goto-data 'ses--header-row)
(insert "(ses-header-row 0)\n")
(ses-set-parameter 'ses--file-format 2)
......@@ -1384,11 +1386,11 @@ execute cell formulas or print functions."
(or (= ses--file-format 2)
(error "This file needs a newer version of the SES library code"))
(ses-create-cell-variable-range 0 (1- ses--numrows) 0 (1- ses--numcols))
;;Initialize cell array
;; Initialize cell array.
(setq ses--cells (make-vector ses--numrows nil))
(dotimes (row ses--numrows)
(aset ses--cells row (make-vector ses--numcols nil))))
;;Skip over print area, which we assume is correct
;; Skip over print area, which we assume is correct.
(goto-char (point-min))
(forward-line ses--numrows)
(or (looking-at ses-print-data-boundary)
......@@ -1396,10 +1398,10 @@ execute cell formulas or print functions."
(forward-char 1)
(setq ses--data-marker (point-marker))
(forward-char (1- (length ses-print-data-boundary)))
;;Initialize printer and symbol lists
;; Initialize printer and symbol lists.
(mapc 'ses-printer-record ses-standard-printer-functions)
(setq ses--symbolic-formulas nil)
;;Load cell definitions
;; Load cell definitions.
(dotimes (row ses--numrows)
(dotimes (col ses--numcols)
(let* ((x (read (current-buffer)))
......@@ -1412,7 +1414,7 @@ execute cell formulas or print functions."
(eval x)))
(or (looking-at "\n\n")
(error "Missing blank line between rows")))
;;Load global parameters
;; Load global parameters.
(let ((widths (read (current-buffer)))
(n1 (char-after (point)))
(printers (read (current-buffer)))
......@@ -1434,12 +1436,12 @@ execute cell formulas or print functions."
(1value (eval def-printer))
(1value (eval printers))
(1value (eval head-row)))
;;Should be back at global-params
;; Should be back at global-params.
(forward-char 1)
(or (looking-at (replace-regexp-in-string "1" "[0-9]+"
ses-initial-global-parameters))
(error "Problem with column-defs or global-params"))
;;Check for overall newline count in definitions area
;; Check for overall newline count in definitions area.
(forward-line 3)
(let ((start (point)))
(ses-goto-data 'ses--numrows)
......@@ -1457,23 +1459,23 @@ Narrows the buffer to show only the print area. Gives it `read-only' and
(inhibit-point-motion-hooks t)
(was-modified (buffer-modified-p))
pos sym)
(ses-goto-data 0 0) ;;Include marker between print-area and data-area
(set-text-properties (point) (point-max) nil) ;Delete garbage props
(ses-goto-data 0 0) ; Include marker between print-area and data-area.
(set-text-properties (point) (point-max) nil) ; Delete garbage props.
(mapc 'delete-overlay (overlays-in (point-min) (point-max)))
;;The print area is read-only (except for our special commands) and uses a
;;special keymap.
;; The print area is read-only (except for our special commands) and uses a
;; special keymap.
(put-text-property (point-min) (1- (point)) 'read-only 'ses)
(put-text-property (point-min) (1- (point)) 'keymap 'ses-mode-print-map)
;;For the beginning of the buffer, we want the read-only and keymap