aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Belaïche2016-07-29 13:44:14 +0200
committerVincent Belaïche2016-07-29 13:44:14 +0200
commit3c97b0f7589e06aeb1ab0147f0ee32974c32926d (patch)
tree12432507950aa2da886fb33514d1b62735a4af96
parent272391f1d63eae0c1002d62fa5e5b1d63a0da767 (diff)
downloademacs-3c97b0f7589e06aeb1ab0147f0ee32974c32926d.tar.gz
emacs-3c97b0f7589e06aeb1ab0147f0ee32974c32926d.zip
Fix ses-delete-blanks to delete only blanks + documentation.
* doc/misc/ses.texi (Quick Tutorial): Mention the '!' 'ses-range' modifier as an alternative to 'ses+'. (Advanced Features): Add a refernce to node 'Nonrelocatable references' concerning function 'ses-rename-cell'. (Standard formula functions): Mention the '!' 'ses-range' modifier as an alternative to 'ses-delete-blanks'. (More on cell printing): Fix fallback printer definition. Minor editorial formatting changes. (Nonrelocatable references): Document the use of 'ses-rename-cell' as a better way to make cell reference non-relocatable. (The data area): Document the presence of local printer definitions in the data area. * lisp/ses.el (ses-delete-blanks): Do not remove *error*. Any error in an argument should propagate into the using formula rather than being silently hidden !
-rw-r--r--doc/misc/ses.texi54
-rw-r--r--lisp/ses.el3
2 files changed, 44 insertions, 13 deletions
diff --git a/doc/misc/ses.texi b/doc/misc/ses.texi
index 58f9ba8ccf3..e443dfb6cbe 100644
--- a/doc/misc/ses.texi
+++ b/doc/misc/ses.texi
@@ -187,6 +187,14 @@ the end-points, e.g.:
187(The @code{apply} is necessary because @code{ses-range} produces a 187(The @code{apply} is necessary because @code{ses-range} produces a
188@emph{list} of values. This allows for more complex possibilities.) 188@emph{list} of values. This allows for more complex possibilities.)
189 189
190Alternatively you can use the @code{!} modifier of @code{ses-range} to
191remove blank cells which allows to use @code{+} instead of
192@code{ses+}:
193
194@lisp
195(apply '+ (ses-range A2 A5 !))
196@end lisp
197
190@c =================================================================== 198@c ===================================================================
191 199
192@node The Basics 200@node The Basics
@@ -595,8 +603,8 @@ Pops up a menu to set the current row as the header, or revert to
595column letters. 603column letters.
596@item M-x ses-rename-cell 604@item M-x ses-rename-cell
597@findex ses-rename-cell 605@findex ses-rename-cell
598Rename a cell from a standard A1-like name to any 606Rename a cell from a standard A1-like name to any string that can be a
599string. 607valid local variable name (See also @ref{Nonrelocatable references}).
600@item M-x ses-repair-cell-reference-all 608@item M-x ses-repair-cell-reference-all
601@findex ses-repair-cell-reference-all 609@findex ses-repair-cell-reference-all
602When you interrupt a cell formula update by clicking @kbd{C-g}, then 610When you interrupt a cell formula update by clicking @kbd{C-g}, then
@@ -791,8 +799,17 @@ are some useful functions to call from your formulas:
791 799
792@table @code 800@table @code
793@item (ses-delete-blanks &rest @var{args}) 801@item (ses-delete-blanks &rest @var{args})
794Returns a list from which all blank cells (value is either @code{nil} or 802Returns a list from which all blank cells (value is either @code{nil}
795'*skip*) have been deleted. 803or '*skip*) have been deleted. Order of args is reverted. Please note
804that @code{ses-range} has a @code{!} modifier that allows to remove
805blanks, so it is possible to write:
806@lisp
807(ses-range A1 A5 !)
808@end lisp
809instead of
810@lisp
811(apply 'ses-delete-blanks (ses-range A1 A5 <))
812@end lisp
796 813
797@item (ses+ &rest @var{args}) 814@item (ses+ &rest @var{args})
798Sum of non-blank arguments. 815Sum of non-blank arguments.
@@ -842,9 +859,9 @@ this to undo the effect of @kbd{t}.
842@end table 859@end table
843 860
844When a printer function signals an error, the fallback printer 861When a printer function signals an error, the fallback printer
845@samp{"%s"} is substituted. This is useful when your column printer 862@samp{"%S"} is substituted. This is useful when your column printer
846is numeric-only and you use a string as a cell value. Note that the 863is numeric-only and you use a string as a cell value. Note that the
847standard default printer is ``%.7g'' which is numeric-only, so cells 864standard default printer is @samp{"%.7g"} which is numeric-only, so cells
848that are empty of contain strings will use the fallback printer. 865that are empty of contain strings will use the fallback printer.
849@kbd{c} on such cells will display ``Format specifier doesn't match 866@kbd{c} on such cells will display ``Format specifier doesn't match
850argument type''. 867argument type''.
@@ -986,7 +1003,18 @@ can type ahead without worrying about the glitch.
986@kbd{C-u C-y} relocates none of the cell-references. What about mixed 1003@kbd{C-u C-y} relocates none of the cell-references. What about mixed
987cases? 1004cases?
988 1005
989You can use 1006The best way is to rename cells that you do not want to be relocatable
1007by using @code{ses-rename-cell}.
1008@findex ses-rename-cell
1009Cells that do not have an A1-like name style are not relocated on
1010yank. Using this method, the concerned cells won't be relocated
1011whatever formula they appear in. Please note however that when a
1012formula contains some range @code{(ses-range @var{cell1} @var{cell2})}
1013then in the yanked formula each range bound @var{cell1} and
1014@var{cell2} are relocated, or not, indepently, depending on whether
1015they are A1-like or renamed.
1016
1017An alternative method is to use
990@lisp 1018@lisp
991(symbol-value 'B3) 1019(symbol-value 'B3)
992@end lisp 1020@end lisp
@@ -994,7 +1022,8 @@ to make an @dfn{absolute reference}. The formula relocator skips over
994quoted things, so this will not be relocated when pasted or when 1022quoted things, so this will not be relocated when pasted or when
995rows/columns are inserted/deleted. However, B3 will not be recorded 1023rows/columns are inserted/deleted. However, B3 will not be recorded
996as a dependency of this cell, so this cell will not be updated 1024as a dependency of this cell, so this cell will not be updated
997automatically when B3 is changed. 1025automatically when B3 is changed, this is why using
1026@code{ses-rename-cell} is most of the time preferable.
998 1027
999The variables @code{row} and @code{col} are dynamically bound while a 1028The variables @code{row} and @code{col} are dynamically bound while a
1000cell formula is being evaluated. You can use 1029cell formula is being evaluated. You can use
@@ -1011,12 +1040,13 @@ kind of dependency is also not recorded.
1011@findex ses-reconstruct-all 1040@findex ses-reconstruct-all
1012 1041
1013Begins with an 014 character, followed by sets of cell-definition 1042Begins with an 014 character, followed by sets of cell-definition
1014macros for each row, followed by column-widths, column-printers, 1043macros for each row, followed by the set of local printer
1044defintitions, followed by column-widths, column-printers,
1015default-printer, and header-row. Then there's the global parameters 1045default-printer, and header-row. Then there's the global parameters
1016(file-format ID, numrows, numcols) and the local variables (specifying 1046(file-format ID, row count, column count, local printer count) and the
1017@acronym{SES} mode for the buffer, etc.). 1047local variables (specifying @acronym{SES} mode for the buffer, etc.).
1018 1048
1019When a @acronym{SES} file is loaded, first the numrows and numcols values are 1049When a @acronym{SES} file is loaded, first the global parameters are
1020loaded, then the entire data area is @code{eval}ed, and finally the local 1050loaded, then the entire data area is @code{eval}ed, and finally the local
1021variables are processed. 1051variables are processed.
1022 1052
diff --git a/lisp/ses.el b/lisp/ses.el
index 0b38af41a8b..b379ef1f9c6 100644
--- a/lisp/ses.el
+++ b/lisp/ses.el
@@ -1,3 +1,4 @@
1
1;;; ses.el -- Simple Emacs Spreadsheet -*- lexical-binding:t -*- 2;;; ses.el -- Simple Emacs Spreadsheet -*- lexical-binding:t -*-
2 3
3;; Copyright (C) 2002-2016 Free Software Foundation, Inc. 4;; Copyright (C) 2002-2016 Free Software Foundation, Inc.
@@ -3746,7 +3747,7 @@ Use `math-format-value' as a printer for Calc objects."
3746 "Return ARGS reversed, with the blank elements (nil and *skip*) removed." 3747 "Return ARGS reversed, with the blank elements (nil and *skip*) removed."
3747 (let (result) 3748 (let (result)
3748 (dolist (cur args) 3749 (dolist (cur args)
3749 (unless (memq cur '(nil *skip* *error*)) 3750 (unless (memq cur '(nil *skip*))
3750 (push cur result))) 3751 (push cur result)))
3751 result)) 3752 result))
3752 3753