diff options
| author | Vincent Belaïche | 2011-12-19 07:30:36 +0100 |
|---|---|---|
| committer | Vincent Belaïche | 2011-12-19 07:30:36 +0100 |
| commit | 34c5fb55c88617ae0b0721d653d833bc73a4e623 (patch) | |
| tree | 9dc426b9505cd43359d7d2160e515c0b694f1ed3 | |
| parent | 99d990817cac77ba755b4e31722c44f6f6bbe3b0 (diff) | |
| download | emacs-34c5fb55c88617ae0b0721d653d833bc73a4e623.tar.gz emacs-34c5fb55c88617ae0b0721d653d833bc73a4e623.zip | |
Ooops... undo changes of 2011-12-11T14:49:48Z!vincentb1@users.sourceforge.net, as trunk branch is feature frozen, and 2011-12-11T14:49:48Z!vincentb1@users.sourceforge.net was a feature addition.
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/ses.el | 109 |
2 files changed, 20 insertions, 95 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9be0d2f1a3c..7d5da3a41c0 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2011-12-19 Vincent Belaïche <vincentb1@users.sourceforge.net> | ||
| 2 | |||
| 3 | * ses.el: Ooops... undo changes of 2011-12-11T14:49:48Z!vincentb1@users.sourceforge.net, as trunk | ||
| 4 | branch is feature frozen, and 2011-12-11T14:49:48Z!vincentb1@users.sourceforge.net was a feature | ||
| 5 | addition. | ||
| 6 | |||
| 1 | 2011-12-18 Jan Djärv <jan.h.d@swipnet.se> | 7 | 2011-12-18 Jan Djärv <jan.h.d@swipnet.se> |
| 2 | 8 | ||
| 3 | * term/ns-win.el (ns-get-selection-internal) | 9 | * term/ns-win.el (ns-get-selection-internal) |
diff --git a/lisp/ses.el b/lisp/ses.el index 403651695a8..d5947472c1a 100644 --- a/lisp/ses.el +++ b/lisp/ses.el | |||
| @@ -674,13 +674,6 @@ for this spreadsheet." | |||
| 674 | (put sym 'ses-cell (cons xrow xcol)) | 674 | (put sym 'ses-cell (cons xrow xcol)) |
| 675 | (make-local-variable sym))))) | 675 | (make-local-variable sym))))) |
| 676 | 676 | ||
| 677 | (defun ses-create-cell-variable (sym row col) | ||
| 678 | "Create a buffer-local variable for cell with symbol | ||
| 679 | SYM at position ROW COL. Return nil in case of failure." | ||
| 680 | (unless (local-variable-p sym) | ||
| 681 | (make-local-variable sym) | ||
| 682 | (put sym 'ses-cell (cons row col)))) | ||
| 683 | |||
| 684 | ;; We do not delete the ses-cell properties for the cell-variables, in | 677 | ;; We do not delete the ses-cell properties for the cell-variables, in |
| 685 | ;; case a formula that refers to this cell is in the kill-ring and is | 678 | ;; case a formula that refers to this cell is in the kill-ring and is |
| 686 | ;; later pasted back in. | 679 | ;; later pasted back in. |
| @@ -1406,8 +1399,7 @@ removed. Example: | |||
| 1406 | Sets `ses-relocate-return' to 'delete if cell-references were removed." | 1399 | Sets `ses-relocate-return' to 'delete if cell-references were removed." |
| 1407 | (let (rowcol result) | 1400 | (let (rowcol result) |
| 1408 | (if (or (atom formula) (eq (car formula) 'quote)) | 1401 | (if (or (atom formula) (eq (car formula) 'quote)) |
| 1409 | (if (and (setq rowcol (ses-sym-rowcol formula)) | 1402 | (if (setq rowcol (ses-sym-rowcol formula)) |
| 1410 | (string-match "\\`[A-Z]+[0-9]+\\'" (symbol-name formula))) | ||
| 1411 | (ses-relocate-symbol formula rowcol | 1403 | (ses-relocate-symbol formula rowcol |
| 1412 | startrow startcol rowincr colincr) | 1404 | startrow startcol rowincr colincr) |
| 1413 | formula) ; Pass through as-is. | 1405 | formula) ; Pass through as-is. |
| @@ -1515,15 +1507,14 @@ if the range was altered." | |||
| 1515 | the rectangle (MINROW,MINCOL)..(NUMROWS,NUMCOLS) by adding ROWINCR and COLINCR | 1507 | the rectangle (MINROW,MINCOL)..(NUMROWS,NUMCOLS) by adding ROWINCR and COLINCR |
| 1516 | to each symbol." | 1508 | to each symbol." |
| 1517 | (let (reform) | 1509 | (let (reform) |
| 1518 | (let (mycell newval xrow) | 1510 | (let (mycell newval) |
| 1519 | (dotimes-with-progress-reporter | 1511 | (dotimes-with-progress-reporter |
| 1520 | (row ses--numrows) "Relocating formulas..." | 1512 | (row ses--numrows) "Relocating formulas..." |
| 1521 | (dotimes (col ses--numcols) | 1513 | (dotimes (col ses--numcols) |
| 1522 | (setq ses-relocate-return nil | 1514 | (setq ses-relocate-return nil |
| 1523 | mycell (ses-get-cell row col) | 1515 | mycell (ses-get-cell row col) |
| 1524 | newval (ses-relocate-formula (ses-cell-formula mycell) | 1516 | newval (ses-relocate-formula (ses-cell-formula mycell) |
| 1525 | minrow mincol rowincr colincr) | 1517 | minrow mincol rowincr colincr)) |
| 1526 | xrow (- row rowincr)) | ||
| 1527 | (ses-set-cell row col 'formula newval) | 1518 | (ses-set-cell row col 'formula newval) |
| 1528 | (if (eq ses-relocate-return 'range) | 1519 | (if (eq ses-relocate-return 'range) |
| 1529 | ;; This cell contains a (ses-range X Y) where a cell has been | 1520 | ;; This cell contains a (ses-range X Y) where a cell has been |
| @@ -1539,22 +1530,8 @@ to each symbol." | |||
| 1539 | minrow mincol rowincr colincr)) | 1530 | minrow mincol rowincr colincr)) |
| 1540 | (ses-set-cell row col 'references newval) | 1531 | (ses-set-cell row col 'references newval) |
| 1541 | (and (>= row minrow) (>= col mincol) | 1532 | (and (>= row minrow) (>= col mincol) |
| 1542 | (let ((sym (ses-cell-symbol row col)) | 1533 | (ses-set-cell row col 'symbol |
| 1543 | (xcol (- col colincr))) | 1534 | (ses-create-cell-symbol row col)))))) |
| 1544 | (if (and | ||
| 1545 | sym | ||
| 1546 | (>= xrow 0) | ||
| 1547 | (>= xcol 0) | ||
| 1548 | (null (eq sym | ||
| 1549 | (ses-create-cell-symbol xrow xcol)))) | ||
| 1550 | ;; This is a renamed cell, do not update the cell | ||
| 1551 | ;; name, but just update the coordinate property. | ||
| 1552 | (put sym 'ses-cell (cons row col)) | ||
| 1553 | (ses-set-cell row col 'symbol | ||
| 1554 | (setq sym (ses-create-cell-symbol row col))) | ||
| 1555 | (unless (and (boundp sym) (local-variable-p sym)) | ||
| 1556 | (set (make-local-variable sym) nil) | ||
| 1557 | (put sym 'ses-cell (cons row col)))))) ))) | ||
| 1558 | ;; Relocate the cell values. | 1535 | ;; Relocate the cell values. |
| 1559 | (let (oldval myrow mycol xrow xcol) | 1536 | (let (oldval myrow mycol xrow xcol) |
| 1560 | (cond | 1537 | (cond |
| @@ -1567,17 +1544,11 @@ to each symbol." | |||
| 1567 | (setq mycol (+ col mincol) | 1544 | (setq mycol (+ col mincol) |
| 1568 | xrow (- myrow rowincr) | 1545 | xrow (- myrow rowincr) |
| 1569 | xcol (- mycol colincr)) | 1546 | xcol (- mycol colincr)) |
| 1570 | (let ((sym (ses-cell-symbol myrow mycol)) | 1547 | (if (and (< xrow ses--numrows) (< xcol ses--numcols)) |
| 1571 | (xsym (ses-create-cell-symbol xrow xcol))) | 1548 | (setq oldval (ses-cell-value xrow xcol)) |
| 1572 | ;; Make the value relocation only when if the cell is not | 1549 | ;; Cell is off the end of the array. |
| 1573 | ;; a renamed cell. Otherwise this is not needed. | 1550 | (setq oldval (symbol-value (ses-create-cell-symbol xrow xcol)))) |
| 1574 | (and (eq sym xsym) | 1551 | (ses-set-cell myrow mycol 'value oldval)))) |
| 1575 | (ses-set-cell myrow mycol 'value | ||
| 1576 | (if (and (< xrow ses--numrows) (< xcol ses--numcols)) | ||
| 1577 | (ses-cell-value xrow xcol) | ||
| 1578 | ;;Cell is off the end of the array | ||
| 1579 | (symbol-value xsym)))))))) | ||
| 1580 | |||
| 1581 | ((and (wholenump rowincr) (wholenump colincr)) | 1552 | ((and (wholenump rowincr) (wholenump colincr)) |
| 1582 | ;; Insertion of rows and/or columns. Run the loop backwards. | 1553 | ;; Insertion of rows and/or columns. Run the loop backwards. |
| 1583 | (let ((disty (1- ses--numrows)) | 1554 | (let ((disty (1- ses--numrows)) |
| @@ -1687,6 +1658,7 @@ Does not execute cell formulas or print functions." | |||
| 1687 | (message "Upgrading from SES-1 file format"))) | 1658 | (message "Upgrading from SES-1 file format"))) |
| 1688 | (or (= ses--file-format 2) | 1659 | (or (= ses--file-format 2) |
| 1689 | (error "This file needs a newer version of the SES library code")) | 1660 | (error "This file needs a newer version of the SES library code")) |
| 1661 | (ses-create-cell-variable-range 0 (1- ses--numrows) 0 (1- ses--numcols)) | ||
| 1690 | ;; Initialize cell array. | 1662 | ;; Initialize cell array. |
| 1691 | (setq ses--cells (make-vector ses--numrows nil)) | 1663 | (setq ses--cells (make-vector ses--numrows nil)) |
| 1692 | (dotimes (row ses--numrows) | 1664 | (dotimes (row ses--numrows) |
| @@ -1706,10 +1678,11 @@ Does not execute cell formulas or print functions." | |||
| 1706 | (dotimes (row ses--numrows) | 1678 | (dotimes (row ses--numrows) |
| 1707 | (dotimes (col ses--numcols) | 1679 | (dotimes (col ses--numcols) |
| 1708 | (let* ((x (read (current-buffer))) | 1680 | (let* ((x (read (current-buffer))) |
| 1709 | (sym (car-safe (cdr-safe x)))) | 1681 | (rowcol (ses-sym-rowcol (car-safe (cdr-safe x))))) |
| 1710 | (or (and (looking-at "\n") | 1682 | (or (and (looking-at "\n") |
| 1711 | (eq (car-safe x) 'ses-cell) | 1683 | (eq (car-safe x) 'ses-cell) |
| 1712 | (ses-create-cell-variable sym row col)) | 1684 | (eq row (car rowcol)) |
| 1685 | (eq col (cdr rowcol))) | ||
| 1713 | (error "Cell-def error")) | 1686 | (error "Cell-def error")) |
| 1714 | (eval x))) | 1687 | (eval x))) |
| 1715 | (or (looking-at "\n\n") | 1688 | (or (looking-at "\n\n") |
| @@ -3166,60 +3139,6 @@ highlighted range in the spreadsheet." | |||
| 3166 | (mouse-set-point event) | 3139 | (mouse-set-point event) |
| 3167 | (ses-insert-ses-range)) | 3140 | (ses-insert-ses-range)) |
| 3168 | 3141 | ||
| 3169 | (defun ses-replace-name-in-formula (formula old-name new-name) | ||
| 3170 | (let ((new-formula formula)) | ||
| 3171 | (unless (and (consp formula) | ||
| 3172 | (eq (car-safe formula) 'quote)) | ||
| 3173 | (while formula | ||
| 3174 | (let ((elt (car-safe formula))) | ||
| 3175 | (cond | ||
| 3176 | ((consp elt) | ||
| 3177 | (setcar formula (ses-replace-name-in-formula elt old-name new-name))) | ||
| 3178 | ((and (symbolp elt) | ||
| 3179 | (eq (car-safe formula) old-name)) | ||
| 3180 | (setcar formula new-name)))) | ||
| 3181 | (setq formula (cdr formula)))) | ||
| 3182 | new-formula)) | ||
| 3183 | |||
| 3184 | (defun ses-rename-cell (new-name) | ||
| 3185 | "Rename current cell." | ||
| 3186 | (interactive "*SEnter new name: ") | ||
| 3187 | (ses-check-curcell) | ||
| 3188 | (or | ||
| 3189 | (and (local-variable-p new-name) | ||
| 3190 | (ses-sym-rowcol new-name) | ||
| 3191 | (error "Already a cell name")) | ||
| 3192 | (and (boundp new-name) | ||
| 3193 | (null (yes-or-no-p (format "`%S' is already bound outside this buffer, continue? " | ||
| 3194 | new-name))) | ||
| 3195 | (error "Already a bound cell name"))) | ||
| 3196 | (let* ((rowcol (ses-sym-rowcol ses--curcell)) | ||
| 3197 | (cell (ses-get-cell (car rowcol) (cdr rowcol)))) | ||
| 3198 | (dolist (reference (ses-cell-references (car rowcol) (cdr rowcol))) | ||
| 3199 | (let* ((rowcol (ses-sym-rowcol reference)) | ||
| 3200 | (cell (ses-get-cell (car rowcol) (cdr rowcol)))) | ||
| 3201 | (ses-cell-set-formula (car rowcol) | ||
| 3202 | (cdr rowcol) | ||
| 3203 | (ses-replace-name-in-formula | ||
| 3204 | (ses-cell-formula cell) | ||
| 3205 | ses--curcell | ||
| 3206 | new-name)))) | ||
| 3207 | (put new-name 'ses-cell rowcol) | ||
| 3208 | (set new-name (symbol-value ses--curcell)) | ||
| 3209 | (aset cell 0 new-name) | ||
| 3210 | (put ses--curcell 'ses-cell nil) | ||
| 3211 | (makunbound ses--curcell) | ||
| 3212 | (setq ses--curcell new-name) | ||
| 3213 | (let* ((pos (point)) | ||
| 3214 | (inhibit-read-only t) | ||
| 3215 | (col (current-column)) | ||
| 3216 | (end (save-excursion | ||
| 3217 | (move-to-column (1+ col)) | ||
| 3218 | (if (eolp) | ||
| 3219 | (+ pos (ses-col-width col) 1) | ||
| 3220 | (point))))) | ||
| 3221 | (put-text-property pos end 'intangible new-name))) ) | ||
| 3222 | |||
| 3223 | 3142 | ||
| 3224 | ;;---------------------------------------------------------------------------- | 3143 | ;;---------------------------------------------------------------------------- |
| 3225 | ;; Checking formulas for safety | 3144 | ;; Checking formulas for safety |