]> code.delx.au - gnu-emacs/blobdiff - lisp/ses.el
* lisp/descr-text.el (describe-char-unicode-data): Fix copy/paste errors.
[gnu-emacs] / lisp / ses.el
index 858833e9e5ebaf596524a36f2305395c75df9628..b2fd2bbe9a5df0a95135eef873918372fa77b61a 100644 (file)
@@ -446,10 +446,8 @@ is nil if SYM is not a symbol that names a cell."
                       (ses-get-cell (car rowcol) (cdr rowcol)))))))
 
 (defun ses-plist-delq (plist prop)
-  "Return PLIST after deletion of proprerty/value pair.
-
-PROP is the symbol identifying the property/value pair. PLIST may
-be modified by border effect."
+  "Return PLIST after deleting the first pair (if any) with symbol PROP.
+This can alter PLIST."
   (cond
    ((null plist) nil)
    ((eq (car plist) prop) (cddr plist))
@@ -1321,7 +1319,7 @@ printer signaled one (and \"%s\" is used as the default printer), else nil."
                           (and locprn
                                (ses--locprn-compiled locprn))))
                    printer)
-               (or value "")))
+               value))
        (if (stringp value)
            value
          (or (stringp (car-safe value))
@@ -1541,7 +1539,8 @@ 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.
+         ;; Constants pass through as-is.
+         formula)
       (dolist (cur formula)
        (setq rowcol (ses-sym-rowcol cur))
        (cond
@@ -3456,9 +3455,18 @@ highlighted range in the spreadsheet."
     (setq cell (or cell (ses-get-cell row col))
          old-name (ses-cell-symbol cell)
          new-rowcol (ses-decode-cell-symbol (symbol-name new-name)))
+    ;; when ses-rename-cell is called interactively, then 'sym' is the
+    ;; 'cursor-intangible' property of text at cursor position, while
+    ;; 'old-name' is the symbol stored in array cell at coordinate
+    ;; 'rowcol' corresponding to 'ses-cell' property of symbol
+    ;; 'sym'. Both must be the same.
+    (unless (eq sym old-name)
+      (error "Spreadsheet is broken, both symbols %S and %S refering to cell (%d,%d)" sym old-name row col))
     (if new-rowcol
+        ;; the new name is of A1 type, so we test that the coordinate
+        ;; inferred from new name
        (if (equal new-rowcol rowcol)
-         (put new-name 'ses-cell rowcol)
+            (put new-name 'ses-cell rowcol)
          (error "Not a valid name for this cell location"))
       (setq ses--named-cell-hashmap
             (or ses--named-cell-hashmap (make-hash-table :test 'eq)))
@@ -3472,7 +3480,7 @@ highlighted range in the spreadsheet."
        (setf (ses-cell-formula xcell)
               (ses-replace-name-in-formula
                (ses-cell-formula xcell)
-               sym
+               old-name
                new-name))))
     ;; Replace name by new name in reference list of cells to which renamed
     ;; cell refers to.
@@ -3480,11 +3488,14 @@ highlighted range in the spreadsheet."
       (let* ((x (ses-sym-rowcol ref))
             (xcell (ses-get-cell (car x) (cdr x))))
        (setf (ses-cell-references xcell)
-              (cons new-name (delq sym
+              (cons new-name (delq old-name
                                    (ses-cell-references xcell))))))
     (set (make-local-variable new-name) (symbol-value sym))
     (setf (ses-cell--symbol cell) new-name)
-    (makunbound sym)
+    ;; Unbind old name
+    (if (eq (get old-name 'ses-cell) :ses-named)
+        (ses--unbind-cell-name old-name)
+      (kill-local-variable old-name))
     (and curcell (setq ses--curcell new-name))
     (save-excursion
       (or curcell (ses-goto-print row col))