Initial Commit
[packages] / xemacs-packages / ess / etc / ess-s4.S
1 #### This is a dump of the S library used by S-mode with Version 4 of S.
2 #### (from John Chambers ??)
3
4 #### S-mode session functions.
5 #### assign(..., where=0) makes them last only for the current session.
6
7 ### Martin Maechler:  see also ./ess-sp3.S
8 ###                   which uses assign(.., wh=0) which seems better
9
10 ".SmodeDump" <- function(x, name)
11 {
12     ## dump function for S-mode
13     assign(".SmodeTmp", options(error = dump.calls), where = 0, i = T)
14     on.exit( {
15         options(.SmodeTmp)
16         remove(".SmodeTmp", where = 0)
17     } )
18     dump(x, file = name)
19 }
20 ".SmodeLoad" <- function(x)
21 {
22     ## skeleton of a dump.calls interface, enough to keep s-mode
23     ## informed that an error took place.
24     pseudo <- function()
25         cat(get.message(), "Dumped\n", sep = "", file = "|stderr")
26     ## source function for S-mode
27     assign(".SmodeTmp", options(error = pseudo), where = 0, i = T)
28     on.exit( {
29         options(.SmodeTmp)
30         remove(".SmodeTmp", where = 0)
31     } )
32     invisible(source(x))
33 }
34
35 ".SmodeObs" <- function(where, pattern)
36 {
37     if(pattern == "") objects(where) else objects(where, pattern)
38 }
39
40 ".SmodePaths" <- function()
41 {
42     ## the paths for the directories in the search list
43     temp <- search()
44     value <- character(length(temp))
45     for(i in seq(along.with = temp)) {
46         obj <- database.object(i)
47         if(is.character(obj) && length(obj) == 1)
48             value[[i]] <- obj
49     }
50     value
51 }
52
53 "smode.lvsave" <-
54     c(".Last.value",
55       ".SmodeDump", ".SmodeLoad", ".SmodeObs", ".SmodePaths",
56       "smode.lvsave")