diff options
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 15 | ||||
| -rw-r--r-- | lisp/ses.el | 150 |
2 files changed, 87 insertions, 78 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 234a84771f1..745346a903a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,13 +1,24 @@ | |||
| 1 | 2014-09-30 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2014-09-30 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * ses.el (ses--row, ses--col): New dyn-scoped vars, to replace row&col. | ||
| 4 | (ses-center, ses-center-span): Use them. | ||
| 5 | (ses-print-cell): Bind them while calling the printer. | ||
| 6 | (row, col, maxrow, maxcol): Don't declare as dynamically scoped. | ||
| 7 | (ses-dorange): Revert last change. | ||
| 8 | (ses-calculate-cell): Don't bind row&col dynamically while evaluating | ||
| 9 | the formula. | ||
| 10 | (ses-set-cell): Avoid `eval'. | ||
| 11 | (ses--time-check): Rename it from ses-time-check and turn it into | ||
| 12 | a macro. | ||
| 13 | |||
| 3 | * ses.el (ses-setup): Don't assume modifying the iteration var of | 14 | * ses.el (ses-setup): Don't assume modifying the iteration var of |
| 4 | dotimes affects the iteration (bug#18191). | 15 | dotimes affects the iteration (bug#18191). |
| 5 | 16 | ||
| 6 | 2014-09-30 Vincent Belaïche <vincentb1@users.sourceforge.net> | 17 | 2014-09-30 Vincent Belaïche <vincentb1@users.sourceforge.net> |
| 7 | 18 | ||
| 8 | * ses.el (ses-calculate-cell): bind row and col dynamically to | 19 | * ses.el (ses-calculate-cell): Bind row and col dynamically to |
| 9 | their values with 'cl-progv'. | 20 | their values with 'cl-progv'. |
| 10 | (ses-dorange): bind row, col, maxrow and maxcol dynamically to | 21 | (ses-dorange): Bind row, col, maxrow and maxcol dynamically to |
| 11 | their values with 'cl-progv', also use non-interned symbols for | 22 | their values with 'cl-progv', also use non-interned symbols for |
| 12 | row, minrow, maxrow, mincol and maxcol. | 23 | row, minrow, maxrow, mincol and maxcol. |
| 13 | (maxrow maxcol): New defvar, to make the compiler happy. | 24 | (maxrow maxcol): New defvar, to make the compiler happy. |
diff --git a/lisp/ses.el b/lisp/ses.el index 025c2c45073..ffd844d06bf 100644 --- a/lisp/ses.el +++ b/lisp/ses.el | |||
| @@ -561,7 +561,7 @@ macro to prevent propagate-on-load viruses." | |||
| 561 | ;;To save time later, we also calculate the total width of each line in the | 561 | ;;To save time later, we also calculate the total width of each line in the |
| 562 | ;;print area (excluding the terminating newline) | 562 | ;;print area (excluding the terminating newline) |
| 563 | (setq ses--col-widths widths | 563 | (setq ses--col-widths widths |
| 564 | ses--linewidth (apply '+ -1 (mapcar '1+ widths)) | 564 | ses--linewidth (apply #'+ -1 (mapcar #'1+ widths)) |
| 565 | ses--blank-line (concat (make-string ses--linewidth ?\s) "\n")) | 565 | ses--blank-line (concat (make-string ses--linewidth ?\s) "\n")) |
| 566 | t) | 566 | t) |
| 567 | 567 | ||
| @@ -573,7 +573,7 @@ them for safety. This is a macro to prevent propagate-on-load viruses." | |||
| 573 | (dotimes (x ses--numcols) | 573 | (dotimes (x ses--numcols) |
| 574 | (aset printers x (ses-safe-printer (aref printers x)))) | 574 | (aset printers x (ses-safe-printer (aref printers x)))) |
| 575 | (setq ses--col-printers printers) | 575 | (setq ses--col-printers printers) |
| 576 | (mapc 'ses-printer-record printers) | 576 | (mapc #'ses-printer-record printers) |
| 577 | t) | 577 | t) |
| 578 | 578 | ||
| 579 | (defmacro ses-default-printer (def) | 579 | (defmacro ses-default-printer (def) |
| @@ -592,37 +592,29 @@ for safety. This is a macro to prevent propagate-on-load viruses." | |||
| 592 | t) | 592 | t) |
| 593 | 593 | ||
| 594 | (defmacro ses-dorange (curcell &rest body) | 594 | (defmacro ses-dorange (curcell &rest body) |
| 595 | "Execute BODY repeatedly, with the variables `row', `col', | 595 | "Execute BODY repeatedly, with the variables `row' and `col' set to each |
| 596 | `maxrow' and `maxcol' dynamically scoped to each cell in the | 596 | cell in the range specified by CURCELL. The range is available in the |
| 597 | range specified by CURCELL." | 597 | variables `minrow', `maxrow', `mincol', and `maxcol'." |
| 598 | (declare (indent defun) (debug (form body))) | 598 | (declare (indent defun) (debug (form body))) |
| 599 | (let ((cur (make-symbol "cur")) | 599 | (let ((cur (make-symbol "cur")) |
| 600 | (min (make-symbol "min")) | 600 | (min (make-symbol "min")) |
| 601 | (max (make-symbol "max")) | 601 | (max (make-symbol "max")) |
| 602 | (r (make-symbol "r")) | 602 | (r (make-symbol "r")) |
| 603 | (c (make-symbol "c")) | 603 | (c (make-symbol "c"))) |
| 604 | (row (make-symbol "row")) | ||
| 605 | ;; The range is available in the variables `minrow', `maxrow', | ||
| 606 | ;; `mincol', and `maxcol'. | ||
| 607 | (minrow (make-symbol "minrow")) | ||
| 608 | (mincol (make-symbol "mincol")) | ||
| 609 | (maxrow (make-symbol "maxrow")) | ||
| 610 | (maxcol (make-symbol "maxcol")) ) | ||
| 611 | `(let* ((,cur ,curcell) | 604 | `(let* ((,cur ,curcell) |
| 612 | (,min (ses-sym-rowcol (if (consp ,cur) (car ,cur) ,cur))) | 605 | (,min (ses-sym-rowcol (if (consp ,cur) (car ,cur) ,cur))) |
| 613 | (,max (ses-sym-rowcol (if (consp ,cur) (cdr ,cur) ,cur)))) | 606 | (,max (ses-sym-rowcol (if (consp ,cur) (cdr ,cur) ,cur)))) |
| 614 | (let ((,minrow (car ,min)) | 607 | (let ((minrow (car ,min)) |
| 615 | (,maxrow (car ,max)) | 608 | (maxrow (car ,max)) |
| 616 | (,mincol (cdr ,min)) | 609 | (mincol (cdr ,min)) |
| 617 | (,maxcol (cdr ,max)) | 610 | (maxcol (cdr ,max))) |
| 618 | ,row) | 611 | (if (or (> minrow maxrow) (> mincol maxcol)) |
| 619 | (if (or (> ,minrow ,maxrow) (> ,mincol ,maxcol)) | ||
| 620 | (error "Empty range")) | 612 | (error "Empty range")) |
| 621 | (dotimes (,r (- ,maxrow ,minrow -1)) | 613 | (dotimes (,r (- maxrow minrow -1)) |
| 622 | (setq ,row (+ ,r ,minrow)) | 614 | (let ((row (+ ,r minrow))) |
| 623 | (dotimes (,c (- ,maxcol ,mincol -1)) | 615 | (dotimes (,c (- maxcol mincol -1)) |
| 624 | (cl-progv '(row col maxrow maxcol) (list ,row (+ ,c ,mincol) ,maxrow ,maxcol) | 616 | (let ((col (+ ,c mincol))) |
| 625 | ,@body))))))) | 617 | ,@body)))))))) |
| 626 | 618 | ||
| 627 | ;;Support for coverage testing. | 619 | ;;Support for coverage testing. |
| 628 | (defmacro 1value (form) | 620 | (defmacro 1value (form) |
| @@ -787,13 +779,12 @@ updated again." | |||
| 787 | (setq ses--header-hscroll -1)) | 779 | (setq ses--header-hscroll -1)) |
| 788 | 780 | ||
| 789 | ;;Split this code off into a function to avoid coverage-testing difficulties | 781 | ;;Split this code off into a function to avoid coverage-testing difficulties |
| 790 | (defun ses-time-check (format arg) | 782 | (defmacro ses--time-check (format &rest args) |
| 791 | "If `ses-start-time' is more than a second ago, call `message' with FORMAT | 783 | "If `ses-start-time' is more than a second ago, call `message' with FORMAT |
| 792 | and (eval ARG) and reset `ses-start-time' to the current time." | 784 | and ARGS and reset `ses-start-time' to the current time." |
| 793 | (when (> (- (float-time) ses-start-time) 1.0) | 785 | `(when (> (- (float-time) ses-start-time) 1.0) |
| 794 | (message format (eval arg)) | 786 | (message ,format ,@args) |
| 795 | (setq ses-start-time (float-time))) | 787 | (setq ses-start-time (float-time)))) |
| 796 | nil) | ||
| 797 | 788 | ||
| 798 | 789 | ||
| 799 | ;;---------------------------------------------------------------------------- | 790 | ;;---------------------------------------------------------------------------- |
| @@ -809,7 +800,8 @@ cell (ROW,COL). This is undoable. The cell's data will be updated through | |||
| 809 | (val ,val)) | 800 | (val ,val)) |
| 810 | (let* ((cell (ses-get-cell row col)) | 801 | (let* ((cell (ses-get-cell row col)) |
| 811 | (change | 802 | (change |
| 812 | ,(let ((field (eval field t))) | 803 | ,(let ((field (progn (cl-assert (eq (car field) 'quote)) |
| 804 | (cadr field)))) | ||
| 813 | (if (eq field 'value) | 805 | (if (eq field 'value) |
| 814 | `(ses-set-with-undo (ses-cell-symbol cell) val) | 806 | `(ses-set-with-undo (ses-cell-symbol cell) val) |
| 815 | ;; (let* ((slots (get 'ses-cell 'cl-struct-slots)) | 807 | ;; (let* ((slots (get 'ses-cell 'cl-struct-slots)) |
| @@ -946,9 +938,7 @@ the old and FORCE is nil." | |||
| 946 | (setq formula (ses-safe-formula (cadr formula))) | 938 | (setq formula (ses-safe-formula (cadr formula))) |
| 947 | (ses-set-cell row col 'formula formula)) | 939 | (ses-set-cell row col 'formula formula)) |
| 948 | (condition-case sig | 940 | (condition-case sig |
| 949 | (setq newval (cl-progv '(row col) | 941 | (setq newval (eval formula t)) |
| 950 | (list row col) | ||
| 951 | (eval formula))) | ||
| 952 | (error | 942 | (error |
| 953 | ;; Variable `sig' can't be nil. | 943 | ;; Variable `sig' can't be nil. |
| 954 | (nconc sig (list (ses-cell-symbol cell))) | 944 | (nconc sig (list (ses-cell-symbol cell))) |
| @@ -1140,6 +1130,9 @@ A single cell is appropriate unless some argument is 'needrange." | |||
| 1140 | ((memq 'needrange args) | 1130 | ((memq 'needrange args) |
| 1141 | (error "Need a range")))) | 1131 | (error "Need a range")))) |
| 1142 | 1132 | ||
| 1133 | (defvar ses--row) | ||
| 1134 | (defvar ses--col) | ||
| 1135 | |||
| 1143 | (defun ses-print-cell (row col) | 1136 | (defun ses-print-cell (row col) |
| 1144 | "Format and print the value of cell (ROW,COL) to the print area. | 1137 | "Format and print the value of cell (ROW,COL) to the print area. |
| 1145 | Use the cell's printer function. If the cell's new print form is too wide, | 1138 | Use the cell's printer function. If the cell's new print form is too wide, |
| @@ -1167,10 +1160,13 @@ preceding cell has spilled over." | |||
| 1167 | (ses-set-cell row col 'printer | 1160 | (ses-set-cell row col 'printer |
| 1168 | (setq printer (ses-safe-printer (cadr printer))))) | 1161 | (setq printer (ses-safe-printer (cadr printer))))) |
| 1169 | ;; Print the value. | 1162 | ;; Print the value. |
| 1170 | (setq text (ses-call-printer (or printer | 1163 | (setq text |
| 1171 | (ses-col-printer col) | 1164 | (let ((ses--row row) |
| 1172 | ses--default-printer) | 1165 | (ses--col col)) |
| 1173 | value)) | 1166 | (ses-call-printer (or printer |
| 1167 | (ses-col-printer col) | ||
| 1168 | ses--default-printer) | ||
| 1169 | value))) | ||
| 1174 | (if (consp ses-call-printer-return) | 1170 | (if (consp ses-call-printer-return) |
| 1175 | ;; Printer returned an error. | 1171 | ;; Printer returned an error. |
| 1176 | (setq sig ses-call-printer-return)))) | 1172 | (setq sig ses-call-printer-return)))) |
| @@ -1279,13 +1275,15 @@ printer signaled one (and \"%s\" is used as the default printer), else nil." | |||
| 1279 | (format (car printer) value) | 1275 | (format (car printer) value) |
| 1280 | "")) | 1276 | "")) |
| 1281 | (t | 1277 | (t |
| 1282 | (setq value (funcall | 1278 | (setq value |
| 1283 | (or (and (symbolp printer) | 1279 | (funcall |
| 1284 | (let ((locprn (gethash printer ses--local-printer-hashmap))) | 1280 | (or (and (symbolp printer) |
| 1285 | (and locprn | 1281 | (let ((locprn (gethash printer |
| 1286 | (ses--locprn-compiled locprn)))) | 1282 | ses--local-printer-hashmap))) |
| 1287 | printer) | 1283 | (and locprn |
| 1288 | (or value ""))) | 1284 | (ses--locprn-compiled locprn)))) |
| 1285 | printer) | ||
| 1286 | (or value ""))) | ||
| 1289 | (if (stringp value) | 1287 | (if (stringp value) |
| 1290 | value | 1288 | value |
| 1291 | (or (stringp (car-safe value)) | 1289 | (or (stringp (car-safe value)) |
| @@ -1411,8 +1409,8 @@ Newlines in the data are escaped." | |||
| 1411 | (with-temp-message " " | 1409 | (with-temp-message " " |
| 1412 | (save-excursion | 1410 | (save-excursion |
| 1413 | (while ses--deferred-write | 1411 | (while ses--deferred-write |
| 1414 | (ses-time-check "Writing... (%d cells left)" | 1412 | (ses--time-check "Writing... (%d cells left)" |
| 1415 | '(length ses--deferred-write)) | 1413 | (length ses--deferred-write)) |
| 1416 | (setq rowcol (pop ses--deferred-write) | 1414 | (setq rowcol (pop ses--deferred-write) |
| 1417 | row (car rowcol) | 1415 | row (car rowcol) |
| 1418 | col (cdr rowcol) | 1416 | col (cdr rowcol) |
| @@ -1702,7 +1700,7 @@ to each symbol." | |||
| 1702 | (let (row col) | 1700 | (let (row col) |
| 1703 | (setq ses-start-time (float-time)) | 1701 | (setq ses-start-time (float-time)) |
| 1704 | (while reform | 1702 | (while reform |
| 1705 | (ses-time-check "Fixing ses-ranges... (%d left)" '(length reform)) | 1703 | (ses--time-check "Fixing ses-ranges... (%d left)" (length reform)) |
| 1706 | (setq row (caar reform) | 1704 | (setq row (caar reform) |
| 1707 | col (cdar reform) | 1705 | col (cdar reform) |
| 1708 | reform (cdr reform)) | 1706 | reform (cdr reform)) |
| @@ -1799,7 +1797,7 @@ Does not execute cell formulas or print functions." | |||
| 1799 | (setq ses--data-marker (point-marker)) | 1797 | (setq ses--data-marker (point-marker)) |
| 1800 | (forward-char (1- (length ses-print-data-boundary))) | 1798 | (forward-char (1- (length ses-print-data-boundary))) |
| 1801 | ;; Initialize printer and symbol lists. | 1799 | ;; Initialize printer and symbol lists. |
| 1802 | (mapc 'ses-printer-record ses-standard-printer-functions) | 1800 | (mapc #'ses-printer-record ses-standard-printer-functions) |
| 1803 | (setq ses--symbolic-formulas nil) | 1801 | (setq ses--symbolic-formulas nil) |
| 1804 | 1802 | ||
| 1805 | ;; Load local printer definitions. | 1803 | ;; Load local printer definitions. |
| @@ -1848,10 +1846,10 @@ Does not execute cell formulas or print functions." | |||
| 1848 | (eq (car-safe head-row) 'ses-header-row) | 1846 | (eq (car-safe head-row) 'ses-header-row) |
| 1849 | (= n4 ?\n)) | 1847 | (= n4 ?\n)) |
| 1850 | (error "Invalid SES global parameters")) | 1848 | (error "Invalid SES global parameters")) |
| 1851 | (1value (eval widths)) | 1849 | (1value (eval widths t)) |
| 1852 | (1value (eval def-printer)) | 1850 | (1value (eval def-printer t)) |
| 1853 | (1value (eval printers)) | 1851 | (1value (eval printers t)) |
| 1854 | (1value (eval head-row))) | 1852 | (1value (eval head-row t))) |
| 1855 | ;; Should be back at global-params. | 1853 | ;; Should be back at global-params. |
| 1856 | (forward-char 1) | 1854 | (forward-char 1) |
| 1857 | (or (looking-at-p ses-initial-global-parameters-re) | 1855 | (or (looking-at-p ses-initial-global-parameters-re) |
| @@ -1875,7 +1873,7 @@ Narrows the buffer to show only the print area. Gives it `read-only' and | |||
| 1875 | (with-silent-modifications | 1873 | (with-silent-modifications |
| 1876 | (ses-goto-data 0 0) ; Include marker between print-area and data-area. | 1874 | (ses-goto-data 0 0) ; Include marker between print-area and data-area. |
| 1877 | (set-text-properties (point) (point-max) nil) ; Delete garbage props. | 1875 | (set-text-properties (point) (point-max) nil) ; Delete garbage props. |
| 1878 | (mapc 'delete-overlay (overlays-in (point-min) (point-max))) | 1876 | (mapc #'delete-overlay (overlays-in (point-min) (point-max))) |
| 1879 | ;; The print area is read-only (except for our special commands) and | 1877 | ;; The print area is read-only (except for our special commands) and |
| 1880 | ;; uses a special keymap. | 1878 | ;; uses a special keymap. |
| 1881 | (put-text-property (point-min) (1- (point)) 'read-only 'ses) | 1879 | (put-text-property (point-min) (1- (point)) 'read-only 'ses) |
| @@ -1925,7 +1923,7 @@ Delete overlays, remove special text properties." | |||
| 1925 | ;; Delete read-only, keymap, and intangible properties. | 1923 | ;; Delete read-only, keymap, and intangible properties. |
| 1926 | (set-text-properties (point-min) (point-max) nil) | 1924 | (set-text-properties (point-min) (point-max) nil) |
| 1927 | ;; Delete overlay. | 1925 | ;; Delete overlay. |
| 1928 | (mapc 'delete-overlay (overlays-in (point-min) (point-max))) | 1926 | (mapc #'delete-overlay (overlays-in (point-min) (point-max))) |
| 1929 | (unless was-modified | 1927 | (unless was-modified |
| 1930 | (restore-buffer-modified-p nil)))) | 1928 | (restore-buffer-modified-p nil)))) |
| 1931 | 1929 | ||
| @@ -2131,7 +2129,7 @@ Based on the current set of columns and `window-hscroll' position." | |||
| 2131 | (push (propertize (format " [row %d]" ses--header-row) | 2129 | (push (propertize (format " [row %d]" ses--header-row) |
| 2132 | 'display '((height (- 1)))) | 2130 | 'display '((height (- 1)))) |
| 2133 | result)) | 2131 | result)) |
| 2134 | (setq ses--header-string (apply 'concat (nreverse result))))) | 2132 | (setq ses--header-string (apply #'concat (nreverse result))))) |
| 2135 | 2133 | ||
| 2136 | 2134 | ||
| 2137 | ;;---------------------------------------------------------------------------- | 2135 | ;;---------------------------------------------------------------------------- |
| @@ -2186,10 +2184,10 @@ print area if NONARROW is nil." | |||
| 2186 | ;; These functions use the variables 'row' and 'col' that are dynamically bound | 2184 | ;; These functions use the variables 'row' and 'col' that are dynamically bound |
| 2187 | ;; by ses-print-cell. We define these variables at compile-time to make the | 2185 | ;; by ses-print-cell. We define these variables at compile-time to make the |
| 2188 | ;; compiler happy. | 2186 | ;; compiler happy. |
| 2189 | (defvar row) | 2187 | ;; (defvar row) |
| 2190 | (defvar col) | 2188 | ;; (defvar col) |
| 2191 | (defvar maxrow) | 2189 | ;; (defvar maxrow) |
| 2192 | (defvar maxcol) | 2190 | ;; (defvar maxcol) |
| 2193 | 2191 | ||
| 2194 | (defun ses-recalculate-cell () | 2192 | (defun ses-recalculate-cell () |
| 2195 | "Recalculate and reprint the current cell or range. | 2193 | "Recalculate and reprint the current cell or range. |
| @@ -2218,7 +2216,7 @@ to are recalculated first." | |||
| 2218 | ;; First, recalculate all cells that don't refer to other cells and | 2216 | ;; First, recalculate all cells that don't refer to other cells and |
| 2219 | ;; produce a list of cells with references. | 2217 | ;; produce a list of cells with references. |
| 2220 | (ses-dorange ses--curcell | 2218 | (ses-dorange ses--curcell |
| 2221 | (ses-time-check "Recalculating... %s" '(ses-cell-symbol row col)) | 2219 | (ses--time-check "Recalculating... %s" (ses-cell-symbol row col)) |
| 2222 | (condition-case nil | 2220 | (condition-case nil |
| 2223 | (progn | 2221 | (progn |
| 2224 | ;; The t causes an error if the cell has references. If no | 2222 | ;; The t causes an error if the cell has references. If no |
| @@ -2839,7 +2837,7 @@ SES attributes recording the contents of the cell as of the time of copying." | |||
| 2839 | ;;Avoid overflow situation | 2837 | ;;Avoid overflow situation |
| 2840 | (setq end (1- ses--data-marker))) | 2838 | (setq end (1- ses--data-marker))) |
| 2841 | (let* ((inhibit-point-motion-hooks t) | 2839 | (let* ((inhibit-point-motion-hooks t) |
| 2842 | (x (mapconcat 'ses-copy-region-helper | 2840 | (x (mapconcat #'ses-copy-region-helper |
| 2843 | (extract-rectangle beg (1- end)) "\n"))) | 2841 | (extract-rectangle beg (1- end)) "\n"))) |
| 2844 | (remove-text-properties 0 (length x) | 2842 | (remove-text-properties 0 (length x) |
| 2845 | '(read-only t | 2843 | '(read-only t |
| @@ -3144,7 +3142,7 @@ is non-nil. Newlines and tabs in the export text are escaped." | |||
| 3144 | (push "\t" result)) | 3142 | (push "\t" result)) |
| 3145 | ((< row maxrow) | 3143 | ((< row maxrow) |
| 3146 | (push "\n" result)))) | 3144 | (push "\n" result)))) |
| 3147 | (setq result (apply 'concat (nreverse result))) | 3145 | (setq result (apply #'concat (nreverse result))) |
| 3148 | (kill-new result))) | 3146 | (kill-new result))) |
| 3149 | 3147 | ||
| 3150 | 3148 | ||
| @@ -3617,7 +3615,7 @@ Use `math-format-value' as a printer for Calc objects." | |||
| 3617 | (setcdr (last result 2) nil) | 3615 | (setcdr (last result 2) nil) |
| 3618 | (setq result (cdr (nreverse result)))) | 3616 | (setq result (cdr (nreverse result)))) |
| 3619 | (unless reorient-x | 3617 | (unless reorient-x |
| 3620 | (setq result (mapcar 'nreverse result))) | 3618 | (setq result (mapcar #'nreverse result))) |
| 3621 | (when transpose | 3619 | (when transpose |
| 3622 | (let ((ret (mapcar (lambda (x) (list x)) (pop result))) iter) | 3620 | (let ((ret (mapcar (lambda (x) (list x)) (pop result))) iter) |
| 3623 | (while result | 3621 | (while result |
| @@ -3629,7 +3627,7 @@ Use `math-format-value' as a printer for Calc objects." | |||
| 3629 | 3627 | ||
| 3630 | (cl-flet ((vectorize-*1 | 3628 | (cl-flet ((vectorize-*1 |
| 3631 | (clean result) | 3629 | (clean result) |
| 3632 | (cons clean (cons (quote 'vec) (apply 'append result)))) | 3630 | (cons clean (cons (quote 'vec) (apply #'append result)))) |
| 3633 | (vectorize-*2 | 3631 | (vectorize-*2 |
| 3634 | (clean result) | 3632 | (clean result) |
| 3635 | (cons clean (cons (quote 'vec) | 3633 | (cons clean (cons (quote 'vec) |
| @@ -3637,7 +3635,7 @@ Use `math-format-value' as a printer for Calc objects." | |||
| 3637 | (cons clean (cons (quote 'vec) x))) | 3635 | (cons clean (cons (quote 'vec) x))) |
| 3638 | result))))) | 3636 | result))))) |
| 3639 | (pcase vectorize | 3637 | (pcase vectorize |
| 3640 | (`nil (cons clean (apply 'append result))) | 3638 | (`nil (cons clean (apply #'append result))) |
| 3641 | (`*1 (vectorize-*1 clean result)) | 3639 | (`*1 (vectorize-*1 clean result)) |
| 3642 | (`*2 (vectorize-*2 clean result)) | 3640 | (`*2 (vectorize-*2 clean result)) |
| 3643 | (`* (funcall (if (cdr result) | 3641 | (`* (funcall (if (cdr result) |
| @@ -3655,13 +3653,13 @@ Use `math-format-value' as a printer for Calc objects." | |||
| 3655 | 3653 | ||
| 3656 | (defun ses+ (&rest args) | 3654 | (defun ses+ (&rest args) |
| 3657 | "Compute the sum of the arguments, ignoring blanks." | 3655 | "Compute the sum of the arguments, ignoring blanks." |
| 3658 | (apply '+ (apply 'ses-delete-blanks args))) | 3656 | (apply #'+ (apply #'ses-delete-blanks args))) |
| 3659 | 3657 | ||
| 3660 | (defun ses-average (list) | 3658 | (defun ses-average (list) |
| 3661 | "Computes the sum of the numbers in LIST, divided by their length. Blanks | 3659 | "Computes the sum of the numbers in LIST, divided by their length. Blanks |
| 3662 | are ignored. Result is always floating-point, even if all args are integers." | 3660 | are ignored. Result is always floating-point, even if all args are integers." |
| 3663 | (setq list (apply 'ses-delete-blanks list)) | 3661 | (setq list (apply #'ses-delete-blanks list)) |
| 3664 | (/ (float (apply '+ list)) (length list))) | 3662 | (/ (float (apply #'+ list)) (length list))) |
| 3665 | 3663 | ||
| 3666 | (defmacro ses-select (fromrange test torange) | 3664 | (defmacro ses-select (fromrange test torange) |
| 3667 | "Select cells in FROMRANGE that are `equal' to TEST. | 3665 | "Select cells in FROMRANGE that are `equal' to TEST. |
| @@ -3670,7 +3668,7 @@ The ranges are macroexpanded but not evaluated so they should be | |||
| 3670 | either (ses-range BEG END) or (list ...). The TEST is evaluated." | 3668 | either (ses-range BEG END) or (list ...). The TEST is evaluated." |
| 3671 | (setq fromrange (cdr (macroexpand fromrange)) | 3669 | (setq fromrange (cdr (macroexpand fromrange)) |
| 3672 | torange (cdr (macroexpand torange)) | 3670 | torange (cdr (macroexpand torange)) |
| 3673 | test (eval test)) | 3671 | test (eval test t)) |
| 3674 | (or (= (length fromrange) (length torange)) | 3672 | (or (= (length fromrange) (length torange)) |
| 3675 | (error "ses-select: Ranges not same length")) | 3673 | (error "ses-select: Ranges not same length")) |
| 3676 | (let (result) | 3674 | (let (result) |
| @@ -3695,14 +3693,14 @@ either (ses-range BEG END) or (list ...). The TEST is evaluated." | |||
| 3695 | FILL is the fill character for centering (default = space). | 3693 | FILL is the fill character for centering (default = space). |
| 3696 | SPAN indicates how many additional rightward columns to include | 3694 | SPAN indicates how many additional rightward columns to include |
| 3697 | in width (default = 0)." | 3695 | in width (default = 0)." |
| 3698 | (let ((printer (or (ses-col-printer col) ses--default-printer)) | 3696 | (let ((printer (or (ses-col-printer ses--col) ses--default-printer)) |
| 3699 | (width (ses-col-width col)) | 3697 | (width (ses-col-width ses--col)) |
| 3700 | half) | 3698 | half) |
| 3701 | (or fill (setq fill ?\s)) | 3699 | (or fill (setq fill ?\s)) |
| 3702 | (or span (setq span 0)) | 3700 | (or span (setq span 0)) |
| 3703 | (setq value (ses-call-printer printer value)) | 3701 | (setq value (ses-call-printer printer value)) |
| 3704 | (dotimes (x span) | 3702 | (dotimes (x span) |
| 3705 | (setq width (+ width 1 (ses-col-width (+ col span (- x)))))) | 3703 | (setq width (+ width 1 (ses-col-width (+ ses--col span (- x)))))) |
| 3706 | ;; Set column width. | 3704 | ;; Set column width. |
| 3707 | (setq width (- width (string-width value))) | 3705 | (setq width (- width (string-width value))) |
| 3708 | (if (<= width 0) | 3706 | (if (<= width 0) |
| @@ -3715,11 +3713,11 @@ in width (default = 0)." | |||
| 3715 | "Print VALUE, centered within the span that starts in the current column | 3713 | "Print VALUE, centered within the span that starts in the current column |
| 3716 | and continues until the next nonblank column. | 3714 | and continues until the next nonblank column. |
| 3717 | FILL specifies the fill character (default = space)." | 3715 | FILL specifies the fill character (default = space)." |
| 3718 | (let ((end (1+ col))) | 3716 | (let ((end (1+ ses--col))) |
| 3719 | (while (and (< end ses--numcols) | 3717 | (while (and (< end ses--numcols) |
| 3720 | (memq (ses-cell-value row end) '(nil *skip*))) | 3718 | (memq (ses-cell-value ses--row end) '(nil *skip*))) |
| 3721 | (setq end (1+ end))) | 3719 | (setq end (1+ end))) |
| 3722 | (ses-center value (- end col 1) fill))) | 3720 | (ses-center value (- end ses--col 1) fill))) |
| 3723 | 3721 | ||
| 3724 | (defun ses-dashfill (value &optional span) | 3722 | (defun ses-dashfill (value &optional span) |
| 3725 | "Print VALUE centered using dashes. | 3723 | "Print VALUE centered using dashes. |