]> code.delx.au - gnu-emacs/blobdiff - lisp/ses.el
Spelling fixes.
[gnu-emacs] / lisp / ses.el
index 2e23e49810a4eefb50650bfa54fe46ef0ff38516..6c9d0a7a50d7869ba09a36538a9efd4dd5b41527 100644 (file)
@@ -43,7 +43,7 @@
 ;; working fine in most cases, however failed in some cases of several path
 ;; racing together.
 ;;
-;; The current algorithm is based on Dijksta algorithm.  The ``cycle length'' is
+;; The current algorithm is based on Dijkstra's algorithm.  The cycle length is
 ;; stored in some cell property. In order not to reset in all cells such
 ;; property at each update, the cycle length is stored in this property along
 ;; with some update attempt id that is incremented at each update. The current
@@ -56,6 +56,7 @@
 ;;; Code:
 
 (require 'unsafep)
+(eval-when-compile (require 'cl))
 
 
 ;;----------------------------------------------------------------------------
@@ -272,18 +273,18 @@ default printer and then modify its output.")
 (eval-and-compile
   (defconst ses-localvars
     '(ses--blank-line ses--cells ses--col-printers
-      ses--col-widths (ses--curcell . nil) ses--curcell-overlay
+      ses--col-widths ses--curcell ses--curcell-overlay
       ses--default-printer
-      ses--deferred-narrow (ses--deferred-recalc
-      . nil) (ses--deferred-write . nil) ses--file-format
+      ses--deferred-narrow ses--deferred-recalc
+      ses--deferred-write ses--file-format
       (ses--header-hscroll . -1) ; Flag for "initial recalc needed"
       ses--header-row ses--header-string ses--linewidth
       ses--numcols ses--numrows ses--symbolic-formulas
-      ses--data-marker ses--params-marker (ses--Dijkstra-attempt-nb
-      . 0) ses--Dijkstra-weight-bound
+      ses--data-marker ses--params-marker (ses--Dijkstra-attempt-nb . 0)
+      ses--Dijkstra-weight-bound
       ;; Global variables that we override
       mode-line-process next-line-add-newlines transient-mark-mode)
-    "Buffer-local variables used by SES."))
+    "Buffer-local variables used by SES.")
 
 (defun ses-set-localvars ()
   "Set buffer-local and initialize some SES variables."
@@ -292,8 +293,11 @@ default printer and then modify its output.")
      ((symbolp x)
       (set (make-local-variable x) nil))
      ((consp x)
-       (set (make-local-variable (car x)) (cdr x)))
-     (error "Unexpected elements `%S' in list `ses-localvars'"))))
+      (set (make-local-variable (car x)) (cdr x)))
+     (t (error "Unexpected elements `%S' in list `ses-localvars'" x))))))
+
+(eval-when-compile                     ; silence compiler
+  (ses-set-localvars))
 
 ;;; This variable is documented as being permitted in file-locals:
 (put 'ses--symbolic-formulas 'safe-local-variable 'consp)
@@ -670,9 +674,9 @@ for this spreadsheet."
        (put sym 'ses-cell (cons xrow xcol))
        (make-local-variable sym)))))
 
-;;We do not delete the ses-cell properties for the cell-variables, in case a
-;;formula that refers to this cell is in the kill-ring and is later pasted
-;;back in.
+;; We do not delete the ses-cell properties for the cell-variables, in
+;; case a formula that refers to this cell is in the kill-ring and is
+;; later pasted back in.
 (defun ses-destroy-cell-variable-range (minrow maxrow mincol maxcol)
   "Destroy buffer-local variables for cells.  This is undoable."
   (let (sym)
@@ -976,7 +980,7 @@ if the cell's value is unchanged and FORCE is nil."
        (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.
+    ;; save-excursion's marker will move past the cell.
     (goto-char pos)))
 
 
@@ -1139,7 +1143,7 @@ preceding cell has spilled over."
        (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
+       ;; inherited (is it a bug that only unpropertized strings actually
        ;; inherit from surrounding text?)
        (set-text-properties 0 (length x) nil x)
        (insert-and-inherit x)
@@ -1170,17 +1174,19 @@ The variable `ses-call-printer-return' is set to t if the printer used
 parenthesis to request left-justification, or the error-signal if the
 printer signaled one (and \"%s\" is used as the default printer), else nil."
   (setq ses-call-printer-return nil)
-  (unless value
-    (setq value ""))
   (condition-case signal
       (cond
        ((stringp printer)
-       (format printer value))
+       (if value
+           (format printer value)
+         ""))
        ((stringp (car-safe printer))
        (setq ses-call-printer-return t)
-       (format (car printer) value))
+       (if value
+           (format (car printer) value)
+         ""))
        (t
-       (setq value (funcall printer value))
+       (setq value (funcall printer (or value "")))
        (if (stringp value)
            value
          (or (stringp (car-safe value))
@@ -1309,7 +1315,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 noticeably faster than (format "%S %S %S %S %S")
          (setq text    (concat "(ses-cell "
                                (symbol-name sym)
                                " "
@@ -1365,7 +1371,7 @@ first reference is found."
     result-so-far)
 
 (defsubst ses-relocate-symbol (sym rowcol startrow startcol rowincr colincr)
-  "Relocate one symbol SYM, whichs corresponds to ROWCOL (a cons of ROW and
+  "Relocate one symbol SYM, which corresponds to ROWCOL (a cons of ROW and
 COL).  Cells starting at (STARTROW,STARTCOL) are being shifted
 by (ROWINCR,COLINCR)."
   (let ((row (car rowcol))
@@ -2714,7 +2720,7 @@ When inserting cells, the formulas are usually relocated to keep the same
 relative references to neighboring cells.  This is best if the formulas
 generally refer to other cells within the yanked text.  You can use the C-u
 prefix to specify insertion without relocation, which is best when the
-formulas refer to cells outsite the yanked text.
+formulas refer to cells outside the yanked text.
 
 When inserting formulas, the text is treated as a string constant if it doesn't
 make sense as a sexp or would otherwise be considered a symbol.  Use 'sym to
@@ -3198,7 +3204,7 @@ By passing in REST some flags one can configure the way the range
 is read and how it is formatted.
 
 In the sequel we assume that cells A1, B1, A2 B2 have respective values
-1 2 3 and 4 for examplication.
+1 2 3 and 4.
 
 Readout direction is specified by a `>v', '`>^', `<v', `<^',
 `v>', `v<', `^>', `^<' flag. For historical reasons, in absence
@@ -3224,7 +3230,7 @@ vector or a matrix depending on the number of rows, `*1' will
 flatten the result to a one row vector, and `*2' will make a
 matrix whatever the number of rows.
 
-Warning: interaction with Calc is expermimental and may produce
+Warning: interaction with Calc is experimental and may produce
 confusing results if you are not aware of Calc data format. Use
 `math-format-value' as a printer for Calc objects."
   (let (result-row
@@ -3342,10 +3348,8 @@ TEST is evaluated."
 ;; These functions use the variables 'row' and 'col' that are dynamically bound
 ;; by ses-print-cell.  We define these variables at compile-time to make the
 ;; compiler happy.
-(eval-when-compile
-  (dolist (x '(row col))
-    (make-local-variable x)
-    (set x nil)))
+(defvar row)
+(defvar col)
 
 (defun ses-center (value &optional span fill)
   "Print VALUE, centered within column.  FILL is the fill character for