From 62f2c4386259f998442e8098d8a368835a36fb65 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vincent=20Bela=C3=AFche?= Date: Sun, 24 Dec 2023 13:02:14 +0100 Subject: [PATCH] Fix ses-formula-record * lisp/ses.el (ses-is-cell-sym-p): Tighten test with checking argument is a local variable. (ses-formula-record): Fix definition. (ses-rename-cell): Loosen test on new-name, conversely to 'ses-is-cell-sym-p' tightening. --- lisp/ses.el | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/lisp/ses.el b/lisp/ses.el index c86871fa83f..881fe92a940 100644 --- a/lisp/ses.el +++ b/lisp/ses.el @@ -556,13 +556,15 @@ the corresponding cell with name PROPERTY-NAME." (defun ses-is-cell-sym-p (sym) "Check whether SYM point at a cell of this spread sheet." - (let ((rowcol (get sym 'ses-cell))) - (and rowcol - (if (eq rowcol :ses-named) - (and ses--named-cell-hashmap (gethash sym ses--named-cell-hashmap)) - (and (< (car rowcol) ses--numrows) - (< (cdr rowcol) ses--numcols) - (eq (ses-cell-symbol (car rowcol) (cdr rowcol)) sym)))))) + (and (symbolp sym) + (local-variable-p sym) + (let ((rowcol (get sym 'ses-cell))) + (and rowcol + (if (eq rowcol :ses-named) + (and ses--named-cell-hashmap (gethash sym ses--named-cell-hashmap)) + (and (< (car rowcol) ses--numrows) + (< (cdr rowcol) ses--numcols) + (eq (ses-cell-symbol (car rowcol) (cdr rowcol)) sym))))))) (defun ses--cell (sym value formula printer references) "Load a cell SYM from the spreadsheet file. @@ -735,10 +737,8 @@ checking that it is a valid printer function." (defun ses-formula-record (formula) "If FORMULA is of the form \\='SYMBOL, add it to the list of symbolic formulas for this spreadsheet." - (when (and (eq (car-safe formula) 'quote) - (symbolp (cadr formula))) - (add-to-list 'ses--symbolic-formulas - (list (symbol-name (cadr formula)))))) + (and (ses-is-cell-sym-p formula) + (cl-pushnew (symbol-name formula) ses--symbolic-formulas :test #'string=))) (defun ses-column-letter (col) "Return the alphabetic name of column number COL. @@ -3677,9 +3677,8 @@ highlighted range in the spreadsheet." "Rename current cell." (interactive "*SEnter new name: ") (or - (and (local-variable-p new-name) - (ses-is-cell-sym-p new-name) - (error "Already a cell name")) + (and (ses-is-cell-sym-p new-name) + (error "Already a cell name")) (and (boundp new-name) (null (yes-or-no-p (format-message -- 2.39.2