[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/lisp/ses.el
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] Changes to emacs/lisp/ses.el |
Date: |
Sun, 21 Nov 2004 20:27:19 -0500 |
Index: emacs/lisp/ses.el
diff -c emacs/lisp/ses.el:1.9 emacs/lisp/ses.el:1.10
*** emacs/lisp/ses.el:1.9 Tue May 4 16:13:43 2004
--- emacs/lisp/ses.el Mon Nov 22 01:21:07 2004
***************
*** 1,4 ****
! ;;; ses.el -- Simple Emacs Spreadsheet
;; Copyright (C) 2002,03,04 Free Software Foundation, Inc.
--- 1,4 ----
! ;;; ses.el -- Simple Emacs Spreadsheet -*- coding: utf-8 -*-
;; Copyright (C) 2002,03,04 Free Software Foundation, Inc.
***************
*** 23,29 ****
--- 23,32 ----
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
+ ;;; Commentary:
+
;;; To-do list:
+
;; * Use $ or ⦠for truncated fields
;; * Add command to make a range of columns be temporarily invisible.
;; * Allow paste of one cell to a range of cells -- copy formula to each.
***************
*** 35,46 ****
;; * Left-margin column for row number.
;; * Move a row by dragging its number in the left-margin.
(require 'unsafep)
!
;;;----------------------------------------------------------------------------
! ;;;; User-customizable variables
!
;;;----------------------------------------------------------------------------
(defgroup ses nil
"Simple Emacs Spreadsheet"
--- 38,52 ----
;; * Left-margin column for row number.
;; * Move a row by dragging its number in the left-margin.
+
+ ;;; Code:
+
(require 'unsafep)
! ;;----------------------------------------------------------------------------
! ;; User-customizable variables
! ;;----------------------------------------------------------------------------
(defgroup ses nil
"Simple Emacs Spreadsheet"
***************
*** 66,73 ****
function))
(defcustom ses-after-entry-functions '(forward-char)
! "Things to do after entering a value into a cell. An abnormal hook that
! usually runs a cursor-movement function. Each function is called with ARG=1."
:group 'ses
:type 'hook
:options '(forward-char backward-char next-line previous-line))
--- 72,80 ----
function))
(defcustom ses-after-entry-functions '(forward-char)
! "Things to do after entering a value into a cell.
! An abnormal hook that usually runs a cursor-movement function.
! Each function is called with ARG=1."
:group 'ses
:type 'hook
:options '(forward-char backward-char next-line previous-line))
***************
*** 78,86 ****
:type 'hook)
!
;;;----------------------------------------------------------------------------
! ;;;; Global variables and constants
!
;;;----------------------------------------------------------------------------
(defvar ses-read-cell-history nil
"List of formulas that have been typed in.")
--- 85,93 ----
:type 'hook)
! ;;----------------------------------------------------------------------------
! ;; Global variables and constants
! ;;----------------------------------------------------------------------------
(defvar ses-read-cell-history nil
"List of formulas that have been typed in.")
***************
*** 92,98 ****
"Context menu when mouse-3 is used on the header-line in an SES buffer."
'("SES header row"
["Set current row" ses-set-header-row t]
! ["Unset row" ses-unset-header-row (> header-row 0)]))
(defconst ses-mode-map
(let ((keys `("\C-c\M-\C-l" ses-reconstruct-all
--- 99,105 ----
"Context menu when mouse-3 is used on the header-line in an SES buffer."
'("SES header row"
["Set current row" ses-set-header-row t]
! ["Unset row" ses-unset-header-row (> ses--header-row 0)]))
(defconst ses-mode-map
(let ((keys `("\C-c\M-\C-l" ses-reconstruct-all
***************
*** 208,221 ****
map))
(defconst ses-print-data-boundary "\n\014\n"
! "Marker string denoting the boundary between print area and data area")
(defconst ses-initial-global-parameters
"\n( ;Global parameters (these are read first)\n 2 ;SES file-format\n 1
;numrows\n 1 ;numcols\n)\n\n"
! "Initial contents for the three-element list at the bottom of the data
area")
(defconst ses-initial-file-trailer
! ";;; Local Variables:\n;;; mode: ses\n;;; End:\n"
"Initial contents for the file-trailer area at the bottom of the file.")
(defconst ses-initial-file-contents
--- 215,228 ----
map))
(defconst ses-print-data-boundary "\n\014\n"
! "Marker string denoting the boundary between print area and data area.")
(defconst ses-initial-global-parameters
"\n( ;Global parameters (these are read first)\n 2 ;SES file-format\n 1
;numrows\n 1 ;numcols\n)\n\n"
! "Initial contents for the three-element list at the bottom of the data
area.")
(defconst ses-initial-file-trailer
! ";; Local Variables:\n;; mode: ses\n;; End:\n"
"Initial contents for the file-trailer area at the bottom of the file.")
(defconst ses-initial-file-contents
***************
*** 231,240 ****
ses-initial-file-trailer)
"The initial contents of an empty spreadsheet.")
- (defconst ses-cell-size 4
- "A cell consists of a SYMBOL, a FORMULA, a PRINTER-function, and a list of
- REFERENCES.")
-
(defconst ses-paramlines-plist
'(ses--col-widths 2 ses--col-printers 3 ses--default-printer 4
ses--header-row 5 ses--file-format 8 ses--numrows 9
--- 238,243 ----
***************
*** 271,283 ****
(set x nil)))
! ;;;
! ;;; "Side-effect variables". They are set in one function, altered in
! ;;; another as a side effect, then read back by the first, as a way of
! ;;; passing back more than one value. These declarations are just to make
! ;;; the compiler happy, and to conform to standard Emacs-Lisp practice (I
! ;;; think the make-local-variable trick above is cleaner).
! ;;;
(defvar ses-relocate-return nil
"Set by `ses-relocate-formula' and `ses-relocate-range', read by
--- 274,286 ----
(set x nil)))
! ;;
! ;; "Side-effect variables". They are set in one function, altered in
! ;; another as a side effect, then read back by the first, as a way of
! ;; passing back more than one value. These declarations are just to make
! ;; the compiler happy, and to conform to standard Emacs-Lisp practice (I
! ;; think the make-local-variable trick above is cleaner).
! ;;
(defvar ses-relocate-return nil
"Set by `ses-relocate-formula' and `ses-relocate-range', read by
***************
*** 296,309 ****
when to emit a progress message.")
!
;;;----------------------------------------------------------------------------
! ;;;; Macros
!
;;;----------------------------------------------------------------------------
(defmacro ses-get-cell (row col)
"Return the cell structure that stores information about cell (ROW,COL)."
`(aref (aref ses--cells ,row) ,col))
(defmacro ses-cell-symbol (row &optional col)
"From a CELL or a pair (ROW,COL), get the symbol that names the
local-variable holding its value. (0,0) => A1."
`(aref ,(if col `(ses-get-cell ,row ,col) row) 0))
--- 299,317 ----
when to emit a progress message.")
! ;;----------------------------------------------------------------------------
! ;; Macros
! ;;----------------------------------------------------------------------------
(defmacro ses-get-cell (row col)
"Return the cell structure that stores information about cell (ROW,COL)."
`(aref (aref ses--cells ,row) ,col))
+ ;; We might want to use defstruct here, but cells are explicitly used as
+ ;; arrays in ses-set-cell, so we'd need to fix this first. --Stef
+ (defsubst ses-make-cell (&optional symbol formula printer references)
+ (vector symbol formula printer references))
+
(defmacro ses-cell-symbol (row &optional col)
"From a CELL or a pair (ROW,COL), get the symbol that names the
local-variable holding its value. (0,0) => A1."
`(aref ,(if col `(ses-get-cell ,row ,col) row) 0))
***************
*** 355,361 ****
(setq printer `(ses-safe-printer ,printer)))
(aset (aref ses--cells (car rowcol))
(cdr rowcol)
! (vector sym formula printer references)))
(set sym value)
sym)
--- 363,369 ----
(setq printer `(ses-safe-printer ,printer)))
(aset (aref ses--cells (car rowcol))
(cdr rowcol)
! (ses-make-cell sym formula printer references)))
(set sym value)
sym)
***************
*** 455,463 ****
form)
!
;;;----------------------------------------------------------------------------
! ;;;; Utility functions
!
;;;----------------------------------------------------------------------------
(defun ses-vector-insert (array idx new)
"Create a new vector which is one larger than ARRAY and has NEW inserted
--- 463,471 ----
form)
! ;;----------------------------------------------------------------------------
! ;; Utility functions
! ;;----------------------------------------------------------------------------
(defun ses-vector-insert (array idx new)
"Create a new vector which is one larger than ARRAY and has NEW inserted
***************
*** 538,546 ****
(put sym 'ses-cell (cons xrow xcol))
(make-local-variable sym)))))
! ;;;We do not delete the ses-cell properties for the cell-variables, in case a
! ;;;formula that refers to this cell is in the kill-ring and is later pasted
! ;;;back in.
(defun ses-destroy-cell-variable-range (minrow maxrow mincol maxcol)
"Destroy buffer-local variables for cells. This is undoable."
(let (sym)
--- 546,554 ----
(put sym 'ses-cell (cons xrow xcol))
(make-local-variable sym)))))
! ;;We do not delete the ses-cell properties for the cell-variables, in case a
! ;;formula that refers to this cell is in the kill-ring and is later pasted
! ;;back in.
(defun ses-destroy-cell-variable-range (minrow maxrow mincol maxcol)
"Destroy buffer-local variables for cells. This is undoable."
(let (sym)
***************
*** 570,578 ****
nil)
!
;;;----------------------------------------------------------------------------
! ;;;; The cells
!
;;;----------------------------------------------------------------------------
(defun ses-set-cell (row col field val)
"Install VAL as the contents for field FIELD (named by a quoted symbol) of
--- 578,586 ----
nil)
! ;;----------------------------------------------------------------------------
! ;; The cells
! ;;----------------------------------------------------------------------------
(defun ses-set-cell (row col field val)
"Install VAL as the contents for field FIELD (named by a quoted symbol) of
***************
*** 634,641 ****
the old and FORCE is nil."
(let ((cell (ses-get-cell row col))
formula-error printer-error)
! (let ((symbol (ses-cell-symbol cell))
! (oldval (ses-cell-value cell))
(formula (ses-cell-formula cell))
newval)
(if (eq (car-safe formula) 'ses-safe-formula)
--- 642,648 ----
the old and FORCE is nil."
(let ((cell (ses-get-cell row col))
formula-error printer-error)
! (let ((oldval (ses-cell-value cell))
(formula (ses-cell-formula cell))
newval)
(if (eq (car-safe formula) 'ses-safe-formula)
***************
*** 717,733 ****
(goto-char pos)))
!
;;;----------------------------------------------------------------------------
! ;;;; The print area
!
;;;----------------------------------------------------------------------------
(defun ses-in-print-area ()
"Returns t if point is in print area of spreadsheet."
(eq (get-text-property (point) 'keymap) 'ses-mode-print-map))
! ;;;We turn off point-motion-hooks and explicitly position the cursor, in case
! ;;;the intangible properties have gotten screwed up (e.g., when
! ;;;ses-goto-print is called during a recursive ses-print-cell).
(defun ses-goto-print (row col)
"Move point to print area for cell (ROW,COL)."
(let ((inhibit-point-motion-hooks t))
--- 724,740 ----
(goto-char pos)))
! ;;----------------------------------------------------------------------------
! ;; The print area
! ;;----------------------------------------------------------------------------
(defun ses-in-print-area ()
"Returns t if point is in print area of spreadsheet."
(eq (get-text-property (point) 'keymap) 'ses-mode-print-map))
! ;;We turn off point-motion-hooks and explicitly position the cursor, in case
! ;;the intangible properties have gotten screwed up (e.g., when
! ;;ses-goto-print is called during a recursive ses-print-cell).
(defun ses-goto-print (row col)
"Move point to print area for cell (ROW,COL)."
(let ((inhibit-point-motion-hooks t))
***************
*** 772,782 ****
(error "Need a range"))))
(defun ses-print-cell (row col)
! "Format and print the value of cell (ROW,COL) to the print area, using the
! cell's printer function. If the cell's new print form is too wide, it will
! spill over into the following cell, but will not run off the end of the row
! or overwrite the next non-nil field. Result is nil for normal operation, or
! the error signal if the printer function failed and the cell was formatted
with \"%s\". If the cell's value is *skip*, nothing is printed because the
preceding cell has spilled over."
(catch 'ses-print-cell
--- 779,789 ----
(error "Need a range"))))
(defun ses-print-cell (row col)
! "Format and print the value of cell (ROW,COL) to the print area.
! Use the cell's printer function. If the cell's new print form is too wide,
! it will spill over into the following cell, but will not run off the end of
the
! row or overwrite the next non-nil field. Result is nil for normal operation,
! or the error signal if the printer function failed and the cell was formatted
with \"%s\". If the cell's value is *skip*, nothing is printed because the
preceding cell has spilled over."
(catch 'ses-print-cell
***************
*** 948,963 ****
(ses-print-cell (car rowcol) (cdr rowcol)))))
!
;;;----------------------------------------------------------------------------
! ;;;; The data area
!
;;;----------------------------------------------------------------------------
(defun ses-goto-data (def &optional col)
"Move point to data area for (DEF,COL). If DEF is a row
number, COL is the column number for a data cell -- otherwise DEF
is one of the symbols ses--col-widths, ses--col-printers,
ses--default-printer, ses--numrows, or ses--numcols."
! (if (< (point-max) (buffer-size))
(setq ses--deferred-narrow t))
(widen)
(let ((inhibit-point-motion-hooks t)) ;In case intangible attrs are wrong
--- 955,972 ----
(ses-print-cell (car rowcol) (cdr rowcol)))))
! ;;----------------------------------------------------------------------------
! ;; The data area
! ;;----------------------------------------------------------------------------
!
! (defun ses-narrowed-p () (/= (- (point-max) (point-min)) (buffer-size)))
(defun ses-goto-data (def &optional col)
"Move point to data area for (DEF,COL). If DEF is a row
number, COL is the column number for a data cell -- otherwise DEF
is one of the symbols ses--col-widths, ses--col-printers,
ses--default-printer, ses--numrows, or ses--numcols."
! (if (ses-narrowed-p)
(setq ses--deferred-narrow t))
(widen)
(let ((inhibit-point-motion-hooks t)) ;In case intangible attrs are wrong
***************
*** 971,980 ****
(forward-line (+ (* ses--numrows (+ ses--numcols 2)) def)))))
(defun ses-set-parameter (def value &optional elem)
! "Sets parameter DEF to VALUE (with undo) and writes the value to the data
! area. See `ses-goto-data' for meaning of DEF. Newlines in the data
! are escaped. If ELEM is specified, it is the array subscript within DEF to
! be set to VALUE."
(save-excursion
;;We call ses-goto-data early, using the old values of numrows and
;;numcols in case one of them is being changed.
--- 980,988 ----
(forward-line (+ (* ses--numrows (+ ses--numcols 2)) def)))))
(defun ses-set-parameter (def value &optional elem)
! "Set parameter DEF to VALUE (with undo) and write the value to the data
area.
! See `ses-goto-data' for meaning of DEF. Newlines in the data are escaped.
! If ELEM is specified, it is the array subscript within DEF to be set to
VALUE."
(save-excursion
;;We call ses-goto-data early, using the old values of numrows and
;;numcols in case one of them is being changed.
***************
*** 995,1002 ****
(insert (format fmt (symbol-value def))))))
(defun ses-write-cells ()
! "`ses--deferred-write' is a list of (ROW,COL) for cells to be written from
! buffer-local variables to data area. Newlines in the data are escaped."
(let* ((inhibit-read-only t)
(print-escape-newlines t)
rowcol row col cell sym formula printer text)
--- 1003,1010 ----
(insert (format fmt (symbol-value def))))))
(defun ses-write-cells ()
! "Write cells in `ses--deferred-write' from local variables to data area.
! Newlines in the data are escaped."
(let* ((inhibit-read-only t)
(print-escape-newlines t)
rowcol row col cell sym formula printer text)
***************
*** 1041,1049 ****
(message " "))))
!
;;;----------------------------------------------------------------------------
! ;;;; Formula relocation
!
;;;----------------------------------------------------------------------------
(defun ses-formula-references (formula &optional result-so-far)
"Produce a list of symbols for cells that this formula's value
--- 1049,1057 ----
(message " "))))
! ;;----------------------------------------------------------------------------
! ;; Formula relocation
! ;;----------------------------------------------------------------------------
(defun ses-formula-references (formula &optional result-so-far)
"Produce a list of symbols for cells that this formula's value
***************
*** 1284,1292 ****
(message nil))))
!
;;;----------------------------------------------------------------------------
! ;;;; Undo control
!
;;;----------------------------------------------------------------------------
(defadvice undo-more (around ses-undo-more activate preactivate)
"Define a meaning for conses in buffer-undo-list whose car is a symbol
--- 1292,1300 ----
(message nil))))
! ;;----------------------------------------------------------------------------
! ;; Undo control
! ;;----------------------------------------------------------------------------
(defadvice undo-more (around ses-undo-more activate preactivate)
"Define a meaning for conses in buffer-undo-list whose car is a symbol
***************
*** 1308,1314 ****
ad-do-it
;;Here is some extra code for SES mode.
(setq ses--deferred-narrow
! (or ses--deferred-narrow (< (point-max) (buffer-size))))
(widen)
(condition-case x
ad-do-it
--- 1316,1322 ----
ad-do-it
;;Here is some extra code for SES mode.
(setq ses--deferred-narrow
! (or ses--deferred-narrow (ses-narrowed-p)))
(widen)
(condition-case x
ad-do-it
***************
*** 1353,1361 ****
t))
!
;;;----------------------------------------------------------------------------
! ;;;; Startup for major mode
!
;;;----------------------------------------------------------------------------
(defun ses-load ()
"Parse the current buffer and sets up buffer-local variables. Does not
--- 1361,1369 ----
t))
! ;;----------------------------------------------------------------------------
! ;; Startup for major mode
! ;;----------------------------------------------------------------------------
(defun ses-load ()
"Parse the current buffer and sets up buffer-local variables. Does not
***************
*** 1363,1372 ****
(widen)
;;Read our global parameters, which should be a 3-element list
(goto-char (point-max))
! (search-backward ";;; Local Variables:\n" nil t)
(backward-list 1)
! (let ((params (condition-case nil (read (current-buffer)) (error nil)))
! sym)
(or (and (= (safe-length params) 3)
(numberp (car params))
(numberp (cadr params))
--- 1371,1379 ----
(widen)
;;Read our global parameters, which should be a 3-element list
(goto-char (point-max))
! (search-backward ";; Local Variables:\n" nil t)
(backward-list 1)
! (let ((params (condition-case nil (read (current-buffer)) (error nil))))
(or (and (= (safe-length params) 3)
(numberp (car params))
(numberp (cadr params))
***************
*** 1481,1487 ****
(put-text-property pos end 'intangible sym)))
;;Adding these properties did not actually alter the text
(unless was-modified
! (set-buffer-modified-p nil)
(buffer-disable-undo)
(buffer-enable-undo)))
;;Create the underlining overlay. It's impossible for (point) to be 2,
--- 1488,1494 ----
(put-text-property pos end 'intangible sym)))
;;Adding these properties did not actually alter the text
(unless was-modified
! (restore-buffer-modified-p nil)
(buffer-disable-undo)
(buffer-enable-undo)))
;;Create the underlining overlay. It's impossible for (point) to be 2,
***************
*** 1494,1501 ****
overlay, remove special text properties."
(widen)
(let ((inhibit-read-only t)
! (was-modified (buffer-modified-p))
! end)
;;Delete read-only, keymap, and intangible properties
(set-text-properties (point-min) (point-max) nil)
;;Delete overlay
--- 1501,1507 ----
overlay, remove special text properties."
(widen)
(let ((inhibit-read-only t)
! (was-modified (buffer-modified-p)))
;;Delete read-only, keymap, and intangible properties
(set-text-properties (point-min) (point-max) nil)
;;Delete overlay
***************
*** 1639,1688 ****
(message (error-message-string err))))
nil) ;Make coverage-tester happy
- (defun ses-header-string-left-offset ()
- "Number of characters in left fringe and left scrollbar (if any)."
- (let ((left-fringe (round (or (frame-parameter nil 'left-fringe) 0)
- (frame-char-width)))
- (left-scrollbar (if (not (eq (frame-parameter nil
- 'vertical-scroll-bars)
- 'left))
- 0
- (let ((x (frame-parameter nil 'scroll-bar-width)))
- ;;Non-toolkil bar is always 14 pixels?
- (unless x (setq x 14))
- ;;Always round up
- (ceiling x (frame-char-width))))))
- (+ left-fringe left-scrollbar)))
-
(defun ses-create-header-string ()
! "Sets up `ses--header-string' as the buffer's header line, based on the
! current set of columns and window-scroll position."
! (let* ((left-offset (ses-header-string-left-offset))
! (totwidth (- left-offset (window-hscroll)))
! result width result x)
;;Leave room for the left-side fringe and scrollbar
! (push (make-string left-offset ? ) result)
(dotimes (col ses--numcols)
(setq width (ses-col-width col)
totwidth (+ totwidth width 1))
! (if (= totwidth (+ left-offset 1))
;;Scrolled so intercolumn space is leftmost
(push " " result))
! (when (> totwidth (+ left-offset 1))
(if (> ses--header-row 0)
(save-excursion
(ses-goto-print (1- ses--header-row) col)
(setq x (buffer-substring-no-properties (point)
(+ (point) width)))
! (if (>= width (- totwidth left-offset))
! (setq x (substring x (- width totwidth left-offset -1))))
! (push (propertize x 'face ses-box-prop) result))
! (setq x (ses-column-letter col))
(push (propertize x 'face ses-box-prop) result)
! (push (propertize (make-string (- width (length x)) ?.)
'display `((space :align-to ,(1- totwidth)))
'face ses-box-prop)
! result))
;;Allow the following space to be squished to make room for the 3-D box
;;Coverage test ignores properties, thinks this is always a space!
(push (1value (propertize " " 'display `((space :align-to ,totwidth))))
--- 1645,1681 ----
(message (error-message-string err))))
nil) ;Make coverage-tester happy
(defun ses-create-header-string ()
! "Set up `ses--header-string' as the buffer's header line.
! Based on the current set of columns and `window-hscroll' position."
! (let ((totwidth (- (window-hscroll)))
! result width x)
;;Leave room for the left-side fringe and scrollbar
! (push (propertize " " 'display '((space :align-to 0))) result)
(dotimes (col ses--numcols)
(setq width (ses-col-width col)
totwidth (+ totwidth width 1))
! (if (= totwidth 1)
;;Scrolled so intercolumn space is leftmost
(push " " result))
! (when (> totwidth 1)
(if (> ses--header-row 0)
(save-excursion
(ses-goto-print (1- ses--header-row) col)
(setq x (buffer-substring-no-properties (point)
(+ (point) width)))
! ;; Strip trailing space.
! (if (string-match "[ \t]+\\'" x)
! (setq x (substring x 0 (match-beginning 0))))
! ;; Cut off excess text.
! (if (>= (length x) totwidth)
! (setq x (substring x 0 (- totwidth -1)))))
! (setq x (ses-column-letter col)))
(push (propertize x 'face ses-box-prop) result)
! (push (propertize "."
'display `((space :align-to ,(1- totwidth)))
'face ses-box-prop)
! result)
;;Allow the following space to be squished to make room for the 3-D box
;;Coverage test ignores properties, thinks this is always a space!
(push (1value (propertize " " 'display `((space :align-to ,totwidth))))
***************
*** 1694,1702 ****
(setq ses--header-string (apply 'concat (nreverse result)))))
!
;;;----------------------------------------------------------------------------
! ;;;; Redisplay and recalculation
!
;;;----------------------------------------------------------------------------
(defun ses-jump (sym)
"Move point to cell SYM."
--- 1687,1695 ----
(setq ses--header-string (apply 'concat (nreverse result)))))
! ;;----------------------------------------------------------------------------
! ;; Redisplay and recalculation
! ;;----------------------------------------------------------------------------
(defun ses-jump (sym)
"Move point to cell SYM."
***************
*** 1814,1820 ****
(interactive "*")
(ses-begin-change)
;;Reconstruct reference lists.
! (let (refs x yrow ycol)
;;Delete old reference lists
(ses-dotimes-msg (row ses--numrows) "Deleting references..."
(dotimes (col ses--numcols)
--- 1807,1813 ----
(interactive "*")
(ses-begin-change)
;;Reconstruct reference lists.
! (let (x yrow ycol)
;;Delete old reference lists
(ses-dotimes-msg (row ses--numrows) "Deleting references..."
(dotimes (col ses--numcols)
***************
*** 1830,1841 ****
(cons (ses-cell-symbol row col)
(ses-cell-references yrow ycol)))))))
;;Delete everything and reconstruct basic data area
! (if (< (point-max) (buffer-size))
(setq ses--deferred-narrow t))
(widen)
(let ((inhibit-read-only t))
(goto-char (point-max))
! (if (search-backward ";;; Local Variables:\n" nil t)
(delete-region (point-min) (point))
;;Buffer is quite screwed up - can't even save the user-specified locals
(delete-region (point-min) (point-max))
--- 1823,1834 ----
(cons (ses-cell-symbol row col)
(ses-cell-references yrow ycol)))))))
;;Delete everything and reconstruct basic data area
! (if (ses-narrowed-p)
(setq ses--deferred-narrow t))
(widen)
(let ((inhibit-read-only t))
(goto-char (point-max))
! (if (search-backward ";; Local Variables:\n" nil t)
(delete-region (point-min) (point))
;;Buffer is quite screwed up - can't even save the user-specified locals
(delete-region (point-min) (point-max))
***************
*** 1862,1870 ****
(goto-char (point-min)))
!
;;;----------------------------------------------------------------------------
! ;;;; Input of cell formulas
!
;;;----------------------------------------------------------------------------
(defun ses-edit-cell (row col newval)
"Display current cell contents in minibuffer, for editing. Returns nil if
--- 1855,1863 ----
(goto-char (point-min)))
! ;;----------------------------------------------------------------------------
! ;; Input of cell formulas
! ;;----------------------------------------------------------------------------
(defun ses-edit-cell (row col newval)
"Display current cell contents in minibuffer, for editing. Returns nil if
***************
*** 1968,1976 ****
(ses-clear-cell (car rowcol) (cdr rowcol))))))
!
;;;----------------------------------------------------------------------------
! ;;;; Input of cell-printer functions
!
;;;----------------------------------------------------------------------------
(defun ses-read-printer (prompt default)
"Common code for `ses-read-cell-printer', `ses-read-column-printer', and
`ses-read-default-printer'.
--- 1961,1969 ----
(ses-clear-cell (car rowcol) (cdr rowcol))))))
! ;;----------------------------------------------------------------------------
! ;; Input of cell-printer functions
! ;;----------------------------------------------------------------------------
(defun ses-read-printer (prompt default)
"Common code for `ses-read-cell-printer', `ses-read-column-printer', and
`ses-read-default-printer'.
***************
*** 2009,2015 ****
right-justified) or a list of one string (will be left-justified)."
(interactive
(let ((default t)
! prompt x)
(ses-check-curcell 'range)
;;Default is none if not all cells in range have same printer
(catch 'ses-read-cell-printer
--- 2002,2008 ----
right-justified) or a list of one string (will be left-justified)."
(interactive
(let ((default t)
! x)
(ses-check-curcell 'range)
;;Default is none if not all cells in range have same printer
(catch 'ses-read-cell-printer
***************
*** 2059,2067 ****
(ses-reprint-all t)))
!
;;;----------------------------------------------------------------------------
! ;;;; Spreadsheet size adjustments
!
;;;----------------------------------------------------------------------------
(defun ses-insert-row (count)
"Insert a new row before the current one. With prefix, insert COUNT rows
--- 2052,2060 ----
(ses-reprint-all t)))
! ;;----------------------------------------------------------------------------
! ;; Spreadsheet size adjustments
! ;;----------------------------------------------------------------------------
(defun ses-insert-row (count)
"Insert a new row before the current one. With prefix, insert COUNT rows
***************
*** 2085,2091 ****
;;the call to ses-relocate-all.
(setq newrow (make-vector ses--numcols nil))
(dotimes (col ses--numcols)
! (aset newrow col (make-vector ses-cell-size nil)))
(setq ses--cells (ses-vector-insert ses--cells row newrow))
(push `(ses-vector-delete ses--cells ,row 1) buffer-undo-list)
(insert ses--blank-line))
--- 2078,2084 ----
;;the call to ses-relocate-all.
(setq newrow (make-vector ses--numcols nil))
(dotimes (col ses--numcols)
! (aset newrow col (ses-make-cell)))
(setq ses--cells (ses-vector-insert ses--cells row newrow))
(push `(ses-vector-delete ses--cells ,row 1) buffer-undo-list)
(insert ses--blank-line))
***************
*** 2122,2129 ****
(or (> count 0) (signal 'args-out-of-range nil))
(let ((inhibit-quit t)
(inhibit-read-only t)
! (row (car (ses-sym-rowcol ses--curcell)))
! pos)
(setq count (min count (- ses--numrows row)))
(ses-begin-change)
(ses-set-parameter 'ses--numrows (- ses--numrows count))
--- 2115,2121 ----
(or (> count 0) (signal 'args-out-of-range nil))
(let ((inhibit-quit t)
(inhibit-read-only t)
! (row (car (ses-sym-rowcol ses--curcell))))
(setq count (min count (- ses--numrows row)))
(ses-begin-change)
(ses-set-parameter 'ses--numrows (- ses--numrows count))
***************
*** 2149,2158 ****
(ses-jump-safe ses--curcell))
(defun ses-insert-column (count &optional col width printer)
! "Insert a new column before COL (default is the current one). With prefix,
! insert COUNT columns before current one. If COL is specified, the new
! column(s) get the specified WIDTH and PRINTER (otherwise they're taken from
! the current column)."
(interactive "*p")
(ses-check-curcell)
(or (> count 0) (signal 'args-out-of-range nil))
--- 2141,2150 ----
(ses-jump-safe ses--curcell))
(defun ses-insert-column (count &optional col width printer)
! "Insert a new column before COL (default is the current one).
! With prefix, insert COUNT columns before current one.
! If COL is specified, the new column(s) get the specified WIDTH and PRINTER
! \(otherwise they're taken from the current column)."
(interactive "*p")
(ses-check-curcell)
(or (> count 0) (signal 'args-out-of-range nil))
***************
*** 2181,2188 ****
(setq has-skip t))
(ses-aset-with-undo ses--cells row
(ses-vector-insert (aref ses--cells row)
! col
! (make-vector ses-cell-size nil)))
;;Insert empty lines in cell data area (will be replaced by
;;ses-relocate-all)
(ses-goto-data row col)
--- 2173,2179 ----
(setq has-skip t))
(ses-aset-with-undo ses--cells row
(ses-vector-insert (aref ses--cells row)
! col (ses-make-cell)))
;;Insert empty lines in cell data area (will be replaced by
;;ses-relocate-all)
(ses-goto-data row col)
***************
*** 2217,2223 ****
(inhibit-read-only t)
(rowcol (ses-sym-rowcol ses--curcell))
(width 0)
! new col origrow has-skip)
(setq origrow (car rowcol)
col (cdr rowcol)
count (min count (- ses--numcols col)))
--- 2208,2214 ----
(inhibit-read-only t)
(rowcol (ses-sym-rowcol ses--curcell))
(width 0)
! col origrow has-skip)
(setq origrow (car rowcol)
col (cdr rowcol)
count (min count (- ses--numcols col)))
***************
*** 2320,2328 ****
(ses-print-cell-new-width row col))))
!
;;;----------------------------------------------------------------------------
! ;;;; Cut and paste, import and export
!
;;;----------------------------------------------------------------------------
(defadvice copy-region-as-kill (around ses-copy-region-as-kill
activate preactivate)
--- 2311,2319 ----
(ses-print-cell-new-width row col))))
! ;;----------------------------------------------------------------------------
! ;; Cut and paste, import and export
! ;;----------------------------------------------------------------------------
(defadvice copy-region-as-kill (around ses-copy-region-as-kill
activate preactivate)
***************
*** 2654,2662 ****
(kill-new result)))
!
;;;----------------------------------------------------------------------------
! ;;;; Other user commands
!
;;;----------------------------------------------------------------------------
(defun ses-unset-header-row ()
"Select the default header row."
--- 2645,2653 ----
(kill-new result)))
! ;;----------------------------------------------------------------------------
! ;; Other user commands
! ;;----------------------------------------------------------------------------
(defun ses-unset-header-row ()
"Select the default header row."
***************
*** 2829,2837 ****
(ses-insert-ses-range))
!
;;;----------------------------------------------------------------------------
! ;;;; Checking formulas for safety
!
;;;----------------------------------------------------------------------------
(defun ses-safe-printer (printer)
"Returns PRINTER if safe, or the substitute printer `ses-unsafe' otherwise."
--- 2820,2828 ----
(ses-insert-ses-range))
! ;;----------------------------------------------------------------------------
! ;; Checking formulas for safety
! ;;----------------------------------------------------------------------------
(defun ses-safe-printer (printer)
"Returns PRINTER if safe, or the substitute printer `ses-unsafe' otherwise."
***************
*** 2862,2870 ****
formula checker)))))
!
;;;----------------------------------------------------------------------------
! ;;;; Standard formulas
!
;;;----------------------------------------------------------------------------
(defmacro ses-range (from to)
"Expands to a list of cell-symbols for the range. The range automatically
--- 2853,2861 ----
formula checker)))))
! ;;----------------------------------------------------------------------------
! ;; Standard formulas
! ;;----------------------------------------------------------------------------
(defmacro ses-range (from to)
"Expands to a list of cell-symbols for the range. The range automatically
***************
*** 2880,2887 ****
"Return ARGS reversed, with the blank elements (nil and *skip*) removed."
(let (result)
(dolist (cur args)
! (and cur (not (eq cur '*skip*))
! (push cur result)))
result))
(defun ses+ (&rest args)
--- 2871,2878 ----
"Return ARGS reversed, with the blank elements (nil and *skip*) removed."
(let (result)
(dolist (cur args)
! (unless (memq cur '(nil *skip*))
! (push cur result)))
result))
(defun ses+ (&rest args)
***************
*** 2916,2924 ****
(put x 'side-effect-free t))
!
;;;----------------------------------------------------------------------------
! ;;;; Standard print functions
!
;;;----------------------------------------------------------------------------
;;These functions use the variables 'row' and 'col' that are
;;dynamically bound by ses-print-cell. We define these varables at
--- 2907,2915 ----
(put x 'side-effect-free t))
! ;;----------------------------------------------------------------------------
! ;; Standard print functions
! ;;----------------------------------------------------------------------------
;;These functions use the variables 'row' and 'col' that are
;;dynamically bound by ses-print-cell. We define these varables at
***************
*** 2982,2986 ****
(provide 'ses)
! ;;; arch-tag: 88c1ccf0-4293-4824-8c5d-0757b52217f3
! ;; ses.el ends here.
--- 2973,2977 ----
(provide 'ses)
! ;; arch-tag: 88c1ccf0-4293-4824-8c5d-0757b52217f3
! ;;; ses.el ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] Changes to emacs/lisp/ses.el,
Stefan Monnier <=