aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorVincent Belaïche2014-01-03 15:18:24 +0100
committerVincent Belaïche2014-01-03 15:18:24 +0100
commite9c04e8bf2a24811a1c335b826816055b6bbf5dc (patch)
tree989542dd963842851a62aafe0d9fc50352b81ed7 /lisp
parentfdaecc05fee5a61cfb83654e39eaf888757b471c (diff)
downloademacs-e9c04e8bf2a24811a1c335b826816055b6bbf5dc.tar.gz
emacs-e9c04e8bf2a24811a1c335b826816055b6bbf5dc.zip
Reverted 2014-01-02T21:05:34Z!vincentb1@users.sourceforge.net.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog28
-rw-r--r--lisp/ses.el243
2 files changed, 23 insertions, 248 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index f74ede68cd1..df00ef0bacf 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -45,34 +45,6 @@
45 * mail/rmail.el (rmail-get-coding-function): Variable. 45 * mail/rmail.el (rmail-get-coding-function): Variable.
46 (rmail-get-coding-system): Use it. 46 (rmail-get-coding-system): Use it.
47 47
482014-01-02 Vincent Belaïche <vincentb1@users.sourceforge.net>
49
50 * ses.el (ses-initial-global-parameters-re): New defconst, a
51 specific regexp is needed now that ses.el can handle both
52 file-format 2 (no local printers) and 3 (may have local printers).
53 (silence compiler): Add local variables needed for local printer
54 handling.
55 (ses-set-localvars): Handle hashmap initialisation.
56 (ses-paramlines-plist): Add param-line for number of local printers.
57 (ses-paramfmt-plist): New defconst, needed for code factorization
58 between functions `ses-set-parameter' and
59 `ses-file-format-extend-paramter-list'
60 (ses-make-local-printer-info): New defsubst.
61 (ses-locprn-get-compiled, ses-locprn-compiled-aset)
62 (ses-locprn-get-def, ses-locprn-def-aset, ses-locprn-get-number)
63 (ses-cell-printer-aset): New defmacro.
64 (ses-local-printer-compile): New defun.
65 (ses-local-printer): New defmacro.
66 (ses-printer-validate, ses-call-printer): Add support for local
67 printer functions.
68 (ses-file-format-extend-paramter-list): New defun.
69 (ses-set-parameter): Use const `ses-paramfmt-plist' for code factorization.
70 (ses-load): Add support for local
71 printer functions.
72 (ses-read-printer): Update docstring and add support for local printer functions.
73 (ses-refresh-local-printer, ses-define-local-printer): New defun.
74 (ses-safe-printer): Add support for local printer functions.
75
762013-12-31 Eli Zaretskii <eliz@gnu.org> 482013-12-31 Eli Zaretskii <eliz@gnu.org>
77 49
78 * international/mule-conf.el: Unify the charset indian-is13194. 50 * international/mule-conf.el: Unify the charset indian-is13194.
diff --git a/lisp/ses.el b/lisp/ses.el
index cdf479398ed..feaa7bd91d4 100644
--- a/lisp/ses.el
+++ b/lisp/ses.el
@@ -238,10 +238,6 @@ Each function is called with ARG=1."
238 "\n( ;Global parameters (these are read first)\n 2 ;SES file-format\n 1 ;numrows\n 1 ;numcols\n)\n\n" 238 "\n( ;Global parameters (these are read first)\n 2 ;SES file-format\n 1 ;numrows\n 1 ;numcols\n)\n\n"
239 "Initial contents for the three-element list at the bottom of the data area.") 239 "Initial contents for the three-element list at the bottom of the data area.")
240 240
241(defconst ses-initial-global-parameters-re
242 "\n( ;Global parameters (these are read first)\n [23] ;SES file-format\n [0-9]+ ;numrows\n [0-9]+ ;numcols\n\\( [0-9]+ ;numlocprn\n\\)?)\n\n"
243 "Match Global parameters for .")
244
245(defconst ses-initial-file-trailer 241(defconst ses-initial-file-trailer
246 ";; Local Variables:\n;; mode: ses\n;; End:\n" 242 ";; Local Variables:\n;; mode: ses\n;; End:\n"
247 "Initial contents for the file-trailer area at the bottom of the file.") 243 "Initial contents for the file-trailer area at the bottom of the file.")
@@ -275,17 +271,11 @@ default printer and then modify its output.")
275;; Local variables and constants 271;; Local variables and constants
276;;---------------------------------------------------------------------------- 272;;----------------------------------------------------------------------------
277 273
278(eval-and-compile ; silence compiler 274(eval-and-compile
279 (defconst ses-localvars 275 (defconst ses-localvars
280 '(ses--blank-line ses--cells ses--col-printers 276 '(ses--blank-line ses--cells ses--col-printers
281 ses--col-widths ses--curcell ses--curcell-overlay 277 ses--col-widths ses--curcell ses--curcell-overlay
282 ses--default-printer 278 ses--default-printer
283 (ses--local-printer-hashmap . :hashmap)
284 ;; the list is there to remember the order of local printers like there
285 ;; are written to the SES filen which service the hashmap does not
286 ;; provide.
287 ses--local-printer-list
288 (ses--numlocprn . 0); count of local printers
289 ses--deferred-narrow ses--deferred-recalc 279 ses--deferred-narrow ses--deferred-recalc
290 ses--deferred-write ses--file-format 280 ses--deferred-write ses--file-format
291 ses--named-cell-hashmap 281 ses--named-cell-hashmap
@@ -308,20 +298,7 @@ default printer and then modify its output.")
308 ((symbolp x) 298 ((symbolp x)
309 (set (make-local-variable x) nil)) 299 (set (make-local-variable x) nil))
310 ((consp x) 300 ((consp x)
311 (cond 301 (set (make-local-variable (car x)) (cdr x)))
312 ((integerp (cdr x))
313 (set (make-local-variable (car x)) (cdr x)))
314 ((eq (cdr x) :hashmap)
315 (set (make-local-variable (car x))
316 (if (boundp (car x))
317 (let ((xv (symbol-value (car x))))
318 (if (hash-table-p xv)
319 (clrhash xv)
320 (warn "Unexpected value of symbol %S, should be a hash table" x)
321 (make-hash-table :test 'eq)))
322 (make-hash-table :test 'eq))))
323 (t (error "Unexpected initializer `%S' in list `ses-localvars' for entry %S"
324 (cdr x) (car x)) ) ))
325 (t (error "Unexpected elements `%S' in list `ses-localvars'" x)))))) 302 (t (error "Unexpected elements `%S' in list `ses-localvars'" x))))))
326 303
327(eval-when-compile ; silence compiler 304(eval-when-compile ; silence compiler
@@ -333,21 +310,10 @@ default printer and then modify its output.")
333(defconst ses-paramlines-plist 310(defconst ses-paramlines-plist
334 '(ses--col-widths -5 ses--col-printers -4 ses--default-printer -3 311 '(ses--col-widths -5 ses--col-printers -4 ses--default-printer -3
335 ses--header-row -2 ses--file-format 1 ses--numrows 2 312 ses--header-row -2 ses--file-format 1 ses--numrows 2
336 ses--numcols 3 ses--numlocprn 4) 313 ses--numcols 3)
337 "Offsets from 'Global parameters' line to various parameter lines in the 314 "Offsets from 'Global parameters' line to various parameter lines in the
338data area of a spreadsheet.") 315data area of a spreadsheet.")
339 316
340(defconst ses-paramfmt-plist
341 '(ses--col-widths "(ses-column-widths %S)"
342 ses--col-printers "(ses-column-printers %S)"
343 ses--default-printer "(ses-default-printer %S)"
344 ses--header-row "(ses-header-row %S)"
345 ses--file-format " %S ;SES file-format"
346 ses--numrows " %S ;numrows"
347 ses--numcols " %S ;numcols"
348 ses--numlocprn " %S ;numlocprn")
349 "Formats of 'Global parameters' various parameters in the data
350area of a spreadsheet.")
351 317
352;; 318;;
353;; "Side-effect variables". They are set in one function, altered in 319;; "Side-effect variables". They are set in one function, altered in
@@ -388,30 +354,6 @@ when to emit a progress message.")
388 property-list) 354 property-list)
389 (vector symbol formula printer references property-list)) 355 (vector symbol formula printer references property-list))
390 356
391(defsubst ses-make-local-printer-info (def &optional compiled-def number)
392 (let ((v (vector def
393 (or compiled-def (ses-local-printer-compile def))
394 (or number ses--numlocprn)
395 nil)))
396 (push v ses--local-printer-list)
397 (aset v 3 ses--local-printer-list)
398 v))
399
400(defmacro ses-locprn-get-compiled (locprn)
401 `(aref ,locprn 1))
402
403(defmacro ses-locprn-compiled-aset (locprn compiled)
404 `(aset ,locprn 1 ,compiled))
405
406(defmacro ses-locprn-get-def (locprn)
407 `(aref ,locprn 0))
408
409(defmacro ses-locprn-def-aset (locprn def)
410 `(aset ,locprn 0 ,def))
411
412(defmacro ses-locprn-get-number (locprn)
413 `(aref ,locprn 2))
414
415(defmacro ses-cell-symbol (row &optional col) 357(defmacro ses-cell-symbol (row &optional col)
416 "From a CELL or a pair (ROW,COL), get the symbol that names the local-variable holding its value. (0,0) => A1." 358 "From a CELL or a pair (ROW,COL), get the symbol that names the local-variable holding its value. (0,0) => A1."
417 `(aref ,(if col `(ses-get-cell ,row ,col) row) 0)) 359 `(aref ,(if col `(ses-get-cell ,row ,col) row) 0))
@@ -429,10 +371,6 @@ when to emit a progress message.")
429 "From a CELL or a pair (ROW,COL), get the function that prints its value." 371 "From a CELL or a pair (ROW,COL), get the function that prints its value."
430 `(aref ,(if col `(ses-get-cell ,row ,col) row) 2)) 372 `(aref ,(if col `(ses-get-cell ,row ,col) row) 2))
431 373
432(defmacro ses-cell-printer-aset (cell printer)
433 "From a CELL set the printer that prints its value."
434 `(aset ,cell 2 ,printer))
435
436(defmacro ses-cell-references (row &optional col) 374(defmacro ses-cell-references (row &optional col)
437 "From a CELL or a pair (ROW,COL), get the list of symbols for cells whose 375 "From a CELL or a pair (ROW,COL), get the list of symbols for cells whose
438functions refer to its value." 376functions refer to its value."
@@ -612,29 +550,6 @@ PRINTER are deferred until first use."
612 (set sym value) 550 (set sym value)
613 sym) 551 sym)
614 552
615(defun ses-local-printer-compile (printer)
616 "Convert local printer function into faster printer
617definition."
618 (cond
619 ((functionp printer) printer)
620 ((stringp printer)
621 `(lambda (x) (format ,printer x)))
622 (t (error "Invalid printer %S" printer))))
623
624(defmacro ses-local-printer (printer-name printer-def)
625 "Define a local printer with name PRINTER-NAME and definition
626PRINTER-DEF. Return the printer info."
627 (or
628 (and (symbolp printer-name)
629 (ses-printer-validate printer-def))
630 (error "Invalid local printer definition"))
631 (and (gethash printer-name ses--local-printer-hashmap)
632 (error "Duplicate printer definition %S" printer-name))
633 (add-to-list 'ses-read-printer-history (symbol-name printer-name))
634 (puthash printer-name
635 (ses-make-local-printer-info (ses-safe-printer printer-def))
636 ses--local-printer-hashmap))
637
638(defmacro ses-column-widths (widths) 553(defmacro ses-column-widths (widths)
639 "Load the vector of column widths from the spreadsheet file. This is a 554 "Load the vector of column widths from the spreadsheet file. This is a
640macro to prevent propagate-on-load viruses." 555macro to prevent propagate-on-load viruses."
@@ -748,8 +663,6 @@ is a vector--if a symbol, the new vector is assigned as the symbol's value."
748 "Signal an error if PRINTER is not a valid SES cell printer." 663 "Signal an error if PRINTER is not a valid SES cell printer."
749 (or (not printer) 664 (or (not printer)
750 (stringp printer) 665 (stringp printer)
751 ;; printer is a local printer
752 (and (symbolp printer) (gethash printer ses--local-printer-hashmap))
753 (functionp printer) 666 (functionp printer)
754 (and (stringp (car-safe printer)) (not (cdr printer))) 667 (and (stringp (car-safe printer)) (not (cdr printer)))
755 (error "Invalid printer function")) 668 (error "Invalid printer function"))
@@ -1347,13 +1260,7 @@ printer signaled one (and \"%s\" is used as the default printer), else nil."
1347 (format (car printer) value) 1260 (format (car printer) value)
1348 "")) 1261 ""))
1349 (t 1262 (t
1350 (setq value (funcall 1263 (setq value (funcall printer (or value "")))
1351 (or (and (symbolp printer)
1352 (let ((locprn (gethash printer ses--local-printer-hashmap)))
1353 (and locprn
1354 (ses-locprn-get-compiled locprn))))
1355 printer)
1356 (or value "")))
1357 (if (stringp value) 1264 (if (stringp value)
1358 value 1265 value
1359 (or (stringp (car-safe value)) 1266 (or (stringp (car-safe value))
@@ -1426,22 +1333,6 @@ ses--default-printer, ses--numrows, or ses--numcols."
1426 (goto-char ses--params-marker) 1333 (goto-char ses--params-marker)
1427 (forward-line def)))) 1334 (forward-line def))))
1428 1335
1429(defun ses-file-format-extend-paramter-list (new-file-format)
1430 "Extend the global parameters list when file format is updated
1431from 2 to 3. This happens when local printer function are added
1432to a sheet that was created with SES version 2. This is not
1433undoable. Return nil when there was no change, and non nil otherwise."
1434 (save-excursion
1435 (cond
1436 ((and (= ses--file-format 2) (= 3 new-file-format))
1437 (ses-set-parameter 'ses--file-format 3 )
1438 (ses-widen)
1439 (goto-char ses--params-marker)
1440 (forward-line (plist-get ses-paramlines-plist 'ses--numlocprn ))
1441 (insert (format (plist-get ses-paramfmt-plist 'ses--numlocprn) ses--numlocprn)
1442 ?\n)
1443 t) )))
1444
1445(defun ses-set-parameter (def value &optional elem) 1336(defun ses-set-parameter (def value &optional elem)
1446 "Set parameter DEF to VALUE (with undo) and write the value to the data area. 1337 "Set parameter DEF to VALUE (with undo) and write the value to the data area.
1447See `ses-goto-data' for meaning of DEF. Newlines in the data are escaped. 1338See `ses-goto-data' for meaning of DEF. Newlines in the data are escaped.
@@ -1451,7 +1342,13 @@ If ELEM is specified, it is the array subscript within DEF to be set to VALUE."
1451 ;; in case one of them is being changed. 1342 ;; in case one of them is being changed.
1452 (ses-goto-data def) 1343 (ses-goto-data def)
1453 (let ((inhibit-read-only t) 1344 (let ((inhibit-read-only t)
1454 (fmt (plist-get ses-paramfmt-plist 1345 (fmt (plist-get '(ses--col-widths "(ses-column-widths %S)"
1346 ses--col-printers "(ses-column-printers %S)"
1347 ses--default-printer "(ses-default-printer %S)"
1348 ses--header-row "(ses-header-row %S)"
1349 ses--file-format " %S ;SES file-format"
1350 ses--numrows " %S ;numrows"
1351 ses--numcols " %S ;numcols")
1455 def)) 1352 def))
1456 oldval) 1353 oldval)
1457 (if elem 1354 (if elem
@@ -1837,38 +1734,29 @@ Does not execute cell formulas or print functions."
1837 (search-backward ";; Local Variables:\n" nil t) 1734 (search-backward ";; Local Variables:\n" nil t)
1838 (backward-list 1) 1735 (backward-list 1)
1839 (setq ses--params-marker (point-marker)) 1736 (setq ses--params-marker (point-marker))
1840 (let* ((params (ignore-errors (read (current-buffer)))) 1737 (let ((params (ignore-errors (read (current-buffer)))))
1841 (params-len (safe-length params))) 1738 (or (and (= (safe-length params) 3)
1842 (or (and (>= params-len 3)
1843 (<= params-len 4)
1844 (numberp (car params)) 1739 (numberp (car params))
1845 (numberp (cadr params)) 1740 (numberp (cadr params))
1846 (>= (cadr params) 0) 1741 (>= (cadr params) 0)
1847 (numberp (nth 2 params)) 1742 (numberp (nth 2 params))
1848 (> (nth 2 params) 0) 1743 (> (nth 2 params) 0))
1849 (or (<= params-len 3)
1850 (let ((numlocprn (nth 3 params)))
1851 (and (integerp numlocprn) (>= numlocprn 0)))))
1852 (error "Invalid SES file")) 1744 (error "Invalid SES file"))
1853 (setq ses--file-format (car params) 1745 (setq ses--file-format (car params)
1854 ses--numrows (cadr params) 1746 ses--numrows (cadr params)
1855 ses--numcols (nth 2 params) 1747 ses--numcols (nth 2 params))
1856 ses--numlocprn (or (nth 3 params) 0))
1857 (when (= ses--file-format 1) 1748 (when (= ses--file-format 1)
1858 (let (buffer-undo-list) ; This is not undoable. 1749 (let (buffer-undo-list) ; This is not undoable.
1859 (ses-goto-data 'ses--header-row) 1750 (ses-goto-data 'ses--header-row)
1860 (insert "(ses-header-row 0)\n") 1751 (insert "(ses-header-row 0)\n")
1861 (ses-set-parameter 'ses--file-format 3) 1752 (ses-set-parameter 'ses--file-format 2)
1862 (message "Upgrading from SES-1 file format"))) 1753 (message "Upgrading from SES-1 file format")))
1863 (or (> ses--file-format 3) 1754 (or (= ses--file-format 2)
1864 (error "This file needs a newer version of the SES library code")) 1755 (error "This file needs a newer version of the SES library code"))
1865 ;; Initialize cell array. 1756 ;; Initialize cell array.
1866 (setq ses--cells (make-vector ses--numrows nil)) 1757 (setq ses--cells (make-vector ses--numrows nil))
1867 (dotimes (row ses--numrows) 1758 (dotimes (row ses--numrows)
1868 (aset ses--cells row (make-vector ses--numcols nil))) 1759 (aset ses--cells row (make-vector ses--numcols nil))))
1869 ;; initialize local printer map.
1870 (clrhash ses--local-printer-hashmap))
1871
1872 ;; Skip over print area, which we assume is correct. 1760 ;; Skip over print area, which we assume is correct.
1873 (goto-char (point-min)) 1761 (goto-char (point-min))
1874 (forward-line ses--numrows) 1762 (forward-line ses--numrows)
@@ -1879,22 +1767,7 @@ Does not execute cell formulas or print functions."
1879 (forward-char (1- (length ses-print-data-boundary))) 1767 (forward-char (1- (length ses-print-data-boundary)))
1880 ;; Initialize printer and symbol lists. 1768 ;; Initialize printer and symbol lists.
1881 (mapc 'ses-printer-record ses-standard-printer-functions) 1769 (mapc 'ses-printer-record ses-standard-printer-functions)
1882 (setq ses--symbolic-formulas nil) 1770 (setq ses--symbolic-formulas nil)
1883
1884 ;; Load local printer definitions.
1885 ;; This must be loaded *BEFORE* cells and column printers because the latters
1886 ;; may call them.
1887 (save-excursion
1888 (forward-line (* ses--numrows (1+ ses--numcols)))
1889 (let ((numlocprn ses--numlocprn))
1890 (setq ses--numlocprn 0)
1891 (dotimes (lp numlocprn)
1892 (let ((x (read (current-buffer))))
1893 (or (and (looking-at-p "\n")
1894 (eq (car-safe x) 'ses-local-printer)
1895 (eval x))
1896 (error "local printer-def error"))
1897 (setq ses--numlocprn (1+ ses--numlocprn))))))
1898 ;; Load cell definitions. 1771 ;; Load cell definitions.
1899 (dotimes (row ses--numrows) 1772 (dotimes (row ses--numrows)
1900 (dotimes (col ses--numcols) 1773 (dotimes (col ses--numcols)
@@ -1907,8 +1780,6 @@ Does not execute cell formulas or print functions."
1907 (eval x))) 1780 (eval x)))
1908 (or (looking-at-p "\n\n") 1781 (or (looking-at-p "\n\n")
1909 (error "Missing blank line between rows"))) 1782 (error "Missing blank line between rows")))
1910 ;; Skip local printer function declaration --- that were already loaded.
1911 (forward-line (+ 2 ses--numlocprn))
1912 ;; Load global parameters. 1783 ;; Load global parameters.
1913 (let ((widths (read (current-buffer))) 1784 (let ((widths (read (current-buffer)))
1914 (n1 (char-after (point))) 1785 (n1 (char-after (point)))
@@ -1933,7 +1804,8 @@ Does not execute cell formulas or print functions."
1933 (1value (eval head-row))) 1804 (1value (eval head-row)))
1934 ;; Should be back at global-params. 1805 ;; Should be back at global-params.
1935 (forward-char 1) 1806 (forward-char 1)
1936 (or (looking-at-p ses-initial-global-parameters-re) 1807 (or (looking-at-p (replace-regexp-in-string "1" "[0-9]+"
1808 ses-initial-global-parameters))
1937 (error "Problem with column-defs or global-params")) 1809 (error "Problem with column-defs or global-params"))
1938 ;; Check for overall newline count in definitions area. 1810 ;; Check for overall newline count in definitions area.
1939 (forward-line 3) 1811 (forward-line 3)
@@ -2517,10 +2389,8 @@ cells."
2517;;---------------------------------------------------------------------------- 2389;;----------------------------------------------------------------------------
2518 2390
2519(defun ses-read-printer (prompt default) 2391(defun ses-read-printer (prompt default)
2520 "Common code for functions `ses-read-cell-printer', `ses-read-column-printer', 2392 "Common code for `ses-read-cell-printer', `ses-read-column-printer', and `ses-read-default-printer'.
2521`ses-read-default-printer' and `ses-define-local-printer'. 2393PROMPT should end with \": \". Result is t if operation was canceled."
2522PROMPT should end with \": \". Result is t if operation was
2523canceled."
2524 (barf-if-buffer-read-only) 2394 (barf-if-buffer-read-only)
2525 (if (eq default t) 2395 (if (eq default t)
2526 (setq default "") 2396 (setq default "")
@@ -2540,7 +2410,6 @@ canceled."
2540 (or (not new) 2410 (or (not new)
2541 (stringp new) 2411 (stringp new)
2542 (stringp (car-safe new)) 2412 (stringp (car-safe new))
2543 (and (symbolp new) (gethash new ses--local-printer-hashmap))
2544 (ses-warn-unsafe new 'unsafep-function) 2413 (ses-warn-unsafe new 'unsafep-function)
2545 (setq new t))) 2414 (setq new t)))
2546 new)) 2415 new))
@@ -3474,71 +3343,6 @@ highlighted range in the spreadsheet."
3474 (symbol-name new-name))) 3343 (symbol-name new-name)))
3475 (force-mode-line-update))) 3344 (force-mode-line-update)))
3476 3345
3477(defun ses-refresh-local-printer (name compiled-value)
3478 "Refresh printout of spreadsheet for all cells with printer
3479 defined to local printer named NAME using the value COMPILED-VALUE for this printer"
3480 (message "Refreshing cells using printer %S" name)
3481 (let (new-print)
3482 (dotimes (row ses--numrows)
3483 (dotimes (col ses--numcols)
3484 (let ((cell-printer (ses-cell-printer row col)))
3485 (when (eq cell-printer name)
3486 (unless new-print
3487 (setq new-print t)
3488 (ses-begin-change))
3489 (ses-print-cell row col)))))))
3490
3491(defun ses-define-local-printer (printer-name)
3492 "Define a local printer with name PRINTER-NAME."
3493 (interactive "*SEnter printer name: ")
3494 (let* ((cur-printer (gethash printer-name ses--local-printer-hashmap))
3495 (default (and (vectorp cur-printer) (ses-locprn-get-def cur-printer)))
3496 printer-def-text
3497 create-printer
3498 (new-printer (ses-read-printer (format "Enter definition of printer %S: " printer-name) default)))
3499 (cond
3500 ;; cancelled operation => do nothing
3501 ((eq new-printer t))
3502 ;; no change => do nothing
3503 ((and (vectorp cur-printer) (equal new-printer default)))
3504 ;; re-defined printer
3505 ((vectorp cur-printer)
3506 (setq create-printer 0)
3507 (ses-locprn-def-aset cur-printer new-printer)
3508 (ses-refresh-local-printer
3509 printer-name
3510 (ses-locprn-compiled-aset cur-printer (ses-local-printer-compile new-printer))))
3511 ;; new definition
3512 (t
3513 (setq create-printer 1)
3514 (puthash printer-name
3515 (setq cur-printer
3516 (ses-make-local-printer-info new-printer))
3517 ses--local-printer-hashmap)))
3518 (when create-printer
3519 (setq printer-def-text
3520 (concat
3521 "(ses-local-printer "
3522 (symbol-name printer-name)
3523 " "
3524 (prin1-to-string (ses-locprn-get-def cur-printer))
3525 ")"))
3526 (save-excursion
3527 (ses-goto-data ses--numrows
3528 (ses-locprn-get-number cur-printer))
3529 (let ((inhibit-read-only t))
3530 ;; Special undo since it's outside the narrowed buffer.
3531 (let (buffer-undo-list)
3532 (if (= create-printer 0)
3533 (delete-region (point) (line-end-position))
3534 (insert ?\n)
3535 (backward-char))
3536 (insert printer-def-text)
3537 (when (= create-printer 1)
3538 (ses-file-format-extend-paramter-list 3)
3539 (ses-set-parameter 'ses--numlocprn (+ ses--numlocprn create-printer))) ))))) )
3540
3541
3542;;---------------------------------------------------------------------------- 3346;;----------------------------------------------------------------------------
3543;; Checking formulas for safety 3347;; Checking formulas for safety
3544;;---------------------------------------------------------------------------- 3348;;----------------------------------------------------------------------------
@@ -3548,7 +3352,6 @@ highlighted range in the spreadsheet."
3548 (if (or (stringp printer) 3352 (if (or (stringp printer)
3549 (stringp (car-safe printer)) 3353 (stringp (car-safe printer))
3550 (not printer) 3354 (not printer)
3551 (and (symbolp printer) (gethash printer ses--local-printer-hashmap))
3552 (ses-warn-unsafe printer 'unsafep-function)) 3355 (ses-warn-unsafe printer 'unsafep-function))
3553 printer 3356 printer
3554 'ses-unsafe)) 3357 'ses-unsafe))