From 316e68a7952719c0450933eb956163ea4248d088 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vincent=20Bela=C3=AFche?= Date: Fri, 20 Jul 2012 23:09:04 +0200 Subject: [PATCH] * ses.el (ses-rename-cell): Set new name also in reference list of cells of which the renamed cell depends. --- lisp/ChangeLog | 5 +++++ lisp/ses.el | 21 ++++++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 969f36c8457..f5f0de2d4c7 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2012-07-20 Vincent Belaïche + + * ses.el (ses-rename-cell): Set new name also in reference list of + cells of which the renamed cell depends. + 2012-07-20 Masatake YAMATO * term/x-win.el (x-menu-bar-open): Use `frame-parameter' diff --git a/lisp/ses.el b/lisp/ses.el index 201d9cbf10b..14294103d51 100644 --- a/lisp/ses.el +++ b/lisp/ses.el @@ -3209,17 +3209,28 @@ highlighted range in the spreadsheet." new-name))) (error "Already a bound cell name"))) (let* ((rowcol (ses-sym-rowcol ses--curcell)) - (cell (ses-get-cell (car rowcol) (cdr rowcol)))) + (row (car rowcol)) + (col (cdr rowcol)) + (cell (ses-get-cell row col))) (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)))) + ;; replace name by new name in formula of cells refering to renamed cell + (dolist (ref (ses-cell-references cell)) + (let* ((x (ses-sym-rowcol ref)) + (xcell (ses-get-cell (car x) (cdr x)))) (ses-cell-set-formula (car rowcol) (cdr rowcol) (ses-replace-name-in-formula - (ses-cell-formula cell) + (ses-cell-formula xcell) ses--curcell new-name)))) + ;; replace name by new name in reference list of cells to which renamed cell refers to + (dolist (ref (ses-formula-references (ses-cell-formula cell))) + (let* ((x (ses-sym-rowcol ref)) + (xrow (car x)) + (xcol (cdr x))) + (ses-set-cell xrow xcol 'references + (cons new-name (delq ses--curcell + (ses-cell-references xrow xcol)))))) (push new-name ses--renamed-cell-symb-list) (set new-name (symbol-value ses--curcell)) (aset cell 0 new-name) -- 2.39.2