;;; ses.el -- Simple Emacs Spreadsheet -*- coding: utf-8 -*-
-;; Copyright (C) 2002-2011 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2012 Free Software Foundation, Inc.
;; Author: Jonathan Yavner <jyavner@member.fsf.org>
;; Maintainer: Vincent Belaïche <vincentb1@users.sourceforge.net>
(defgroup ses nil
"Simple Emacs Spreadsheet."
+ :tag "SES"
:group 'applications
:prefix "ses-"
:version "21.1")
ses--numcols ses--numrows ses--symbolic-formulas
ses--data-marker ses--params-marker (ses--Dijkstra-attempt-nb . 0)
ses--Dijkstra-weight-bound
+ ;; This list is useful to speed-up clean-up of symbols when
+ ;; an area containing renamed cell is deleted.
+ ses--renamed-cell-symb-list
;; Global variables that we override
mode-line-process next-line-add-newlines transient-mark-mode)
"Buffer-local variables used by SES.")
(make-local-variable sym)))))
(defun ses-create-cell-variable (sym row col)
- "Create a buffer-local variable for cell with symbol
-SYM at position ROW COL. Return nil in case of failure."
+ "Create a buffer-local variable `SYM' for cell at position (ROW, COL).
+
+SYM is the symbol for that variable, ROW and COL are integers for
+row and column of the cell, with numbering starting from 0.
+
+Return nil in case of failure."
(unless (local-variable-p sym)
(make-local-variable sym)
(put sym 'ses-cell (cons row col))))
(let (sym)
(dotimes (row (1+ (- maxrow minrow)))
(dotimes (col (1+ (- maxcol mincol)))
- (setq sym (ses-create-cell-symbol (+ row minrow) (+ col mincol)))
+ (let ((xrow (+ row minrow)) (xcol (+ col mincol)))
+ (setq sym (if (and (< xrow ses--numrows) (< xcol ses--numcols))
+ (ses-cell-symbol xrow xcol)
+ (ses-create-cell-symbol xrow xcol))))
(if (boundp sym)
(push `(apply ses-set-with-undo ,sym ,(symbol-value sym))
buffer-undo-list))
(defcustom ses-self-reference-early-detection nil
"True if cycle detection is early for cells that refer to themselves."
+ :version "24.1"
:type 'boolean
:group 'ses)
(or
(and (local-variable-p new-name)
(ses-sym-rowcol new-name)
+ ;; this test is needed because ses-cell property of deleted cells
+ ;; is not deleted in case of subsequent undo
+ (memq new-name ses--renamed-cell-symb-list)
(error "Already a cell name"))
(and (boundp new-name)
(null (yes-or-no-p (format "`%S' is already bound outside this buffer, continue? "
(error "Already a bound cell name")))
(let* ((rowcol (ses-sym-rowcol ses--curcell))
(cell (ses-get-cell (car rowcol) (cdr rowcol))))
+ (put new-name 'ses-cell rowcol)
(dolist (reference (ses-cell-references (car rowcol) (cdr rowcol)))
(let* ((rowcol (ses-sym-rowcol reference))
(cell (ses-get-cell (car rowcol) (cdr rowcol))))
(ses-cell-formula cell)
ses--curcell
new-name))))
- (put new-name 'ses-cell rowcol)
+ (push new-name ses--renamed-cell-symb-list)
(set new-name (symbol-value ses--curcell))
(aset cell 0 new-name)
(put ses--curcell 'ses-cell nil)
(point)))))
(put-text-property pos end 'intangible new-name))) )
-
;;----------------------------------------------------------------------------
;; Checking formulas for safety
;;----------------------------------------------------------------------------