1 ;;; essd-els.el --- S-PLUS 3.x at another location customization
3 ;; Copyright (C) 1998 Richard M. Heiberger
4 ;; Copyright (C) 1999--2005 A.J. Rossini, Rich M. Heiberger, Martin
5 ;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
7 ;; Original Author: Richard M. Heiberger <rmh@fisher.stat.temple.edu>
8 ;; Created: December 1998
10 ;; Maintainers: ESS-core <ESS-core@stat.math.ethz.ch>
12 ;; Keywords: start up, configuration.
14 ;; This file is part of ESS.
16 ;; This file is free software; you can redistribute it and/or modify
17 ;; it under the terms of the GNU General Public License as published by
18 ;; the Free Software Foundation; either version 2, or (at your option)
21 ;; This file is distributed in the hope that it will be useful,
22 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
23 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 ;; GNU General Public License for more details.
26 ;; You should have received a copy of the GNU General Public License
27 ;; along with GNU Emacs; see the file COPYING. If not, write to
28 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
31 ;;; This file defines all the S-PLUS 3.x customizations for ess-mode.
33 ;;; Requires and Autoloads:
37 (autoload 'inferior-ess
"ess-inf" "Run an ESS process.")
38 (autoload 'ess-mode
"ess-mode" "Edit an ESS process.")
42 (defvar S
+elsewhere-dialect-name
"S+6"
43 "Name of 'dialect' for S-PLUS at another location.")
44 ;easily changeable in a user's .emacs
46 (defvar S
+elsewhere-customize-alist
48 '((ess-local-customize-alist .
'S
+elsewhere-customize-alist
)
49 (ess-dialect . S
+elsewhere-dialect-name
)
50 (ess-loop-timeout . ess-S-loop-timeout
);fixme: dialect spec.
51 (ess-object-name-db-file .
"ess-spelsewhere-namedb.el" )
52 (inferior-ess-program . inferior-S-elsewhere-program-name
)
53 (inferior-ess-help-command .
"help(\"%s\",pager=\"cat\",window=F)\n")
55 (inferior-ess-start-file . nil
) ;"~/.ess-S+3")
56 (inferior-ess-start-args .
"-i")
60 "Variables to customize for S+elsewhere")
63 (defun S+elsewhere
(&optional proc-name
)
64 "Call 'S-PLUS 3.x', the 'Real Thing' from StatSci.
65 This command is obsolete; please use `ess-remote' instead."
67 (setq ess-customize-alist S
+elsewhere-customize-alist
)
68 (ess-write-to-dribble-buffer
69 (format "\n(S+elsewhere): ess-dialect=%s, buf=%s\n" ess-dialect
72 (if inferior-ess-language-start
73 (ess-eval-linewise inferior-ess-language-start
)))
76 (defun S+elsewhere-mode
(&optional proc-name
)
77 "Major mode for editing S+3 source. See `ess-mode' for more help."
79 (setq ess-customize-alist S
+elsewhere-customize-alist
)
80 (ess-mode S
+elsewhere-customize-alist proc-name
))
82 (defun S+elsewhere-transcript-mode
()
83 "S-PLUS 3.x transcript mode."
85 (ess-transcript-mode S
+elsewhere-customize-alist
))
87 ;; This REALLY shouldn't need an editing mode. Just a transcript and
88 ;; an inferior process handler.
90 (defun ess-change-alist (item value alist
)
91 "Modify ALIST to set VALUE to ITEM.
92 If there is a pair whose car is ITEM, replace its cdr by VALUE.
93 If there is not such pair, create new pair (ITEM . VALUE) and
94 return new alist whose car is the new pair and cdr is ALIST.
95 \[tomo's ELIS like function]"
96 (let ((pair (assoc item alist
)))
101 (cons (cons item value
) alist
))))
104 (defun ess-select-alist-dialect ()
105 "Query user for an ESS dialect and return the matching customize-alist."
107 (let* ((dialects '("arc" "vst" "omg" "s3" "s4" "stata" "r" "sp3" "sp4"
108 "sqpe4" "sp5" "sp6" "sqpe6" "xls" "sas"))
109 (dialect (completing-read "Dialect (press TAB for choices): "
110 (mapcar '(lambda (x) (cons x
1)) dialects
)
113 ((string= dialect
"arc") ARC-customize-alist
)
114 ((string= dialect
"vst") VST-customize-alist
)
115 ((string= dialect
"omg") OMG-customize-alist
)
116 ((string= dialect
"s3") S3-customize-alist
)
117 ((string= dialect
"s4") S4-customize-alist
)
118 ((string= dialect
"stata") STA-customize-alist
)
119 ((string= dialect
"r") R-customize-alist
)
120 ((string= dialect
"sp3") S
+3-customize-alist
)
121 ((string= dialect
"sp4") S
+4-customize-alist
)
122 ((string= dialect
"sqpe4") Sqpe
+4-customize-alist
)
123 ((string= dialect
"sp5") S
+5-customize-alist
)
124 ((string= dialect
"sp6") S
+6-customize-alist
)
125 ((string= dialect
"sqpe6") Sqpe
+6-customize-alist
)
126 ((string= dialect
"xls") XLS-customize-alist
)
127 ((string= dialect
"sas") SAS-customize-alist
);was S+elsewhere-customize-alist?
128 (t S
+elsewhere-customize-alist
)
132 (defun ESS-elsewhere (&optional proc-name
)
133 "Call an inferior process from ELSEWHERE.
134 This command is obsolete; please use `ess-remote' instead."
136 ;; Need to select a elsewhere-customize-alist
137 (let ((elsewhere-customize-alist (ess-select-alist-dialect)))
138 (ess-change-alist 'inferior-ess-program
139 inferior-ESS-elsewhere-program-name
140 elsewhere-customize-alist
)
141 (setq ess-customize-alist elsewhere-customize-alist
)
142 (ess-write-to-dribble-buffer
143 (format "\n(ESS-elsewhere): ess-dialect=%s, buf=%s\n" ess-dialect
146 (if (equal ess-language
"S")
147 (if inferior-ess-language-start
148 (ess-eval-linewise inferior-ess-language-start
)))))
151 (defun ess-add-ess-process ()
152 "Execute this command from within a buffer running a process to add
153 the process to `ess-process-name-alist' and to make it the
154 `ess-current-process-name'. This command will normally be run in a
155 telnet buffer connected to another computer or in a shell or comint
156 buffer on the local computer."
158 (let ((proc (get-buffer-process (buffer-name))))
160 (error "No process is associated with this buffer.")
161 (setq ess-current-process-name
(process-name proc
))
162 (add-to-list 'ess-process-name-list
163 (list ess-current-process-name
)))))
166 ;;; ess-remote is constructed by looking at ess-add-process and
167 ;;; ESS-elsewhere and ess-multi and then simplifying.
170 (defun ess-remote (&optional proc-name
)
171 "Execute this command from within a buffer running a process. It
172 runs `ess-add-ess-process' to add the process to
173 `ess-process-name-alist' and to make it the
174 `ess-current-process-name'. It then prompts the user for an ESS
175 language and sets the editing characteristics appropriately.
177 To use this command, first start a process on a remote computer by
178 manual use of telnet, rlogin, ssh, or some other protocol. Start the
179 relevant program (\"S\" or \"R\" or \"sas -stdio\") in that buffer. Once
180 you are talking to S or R or SAS, then execute `ess-remote' to make
181 the current buffer an inferior-ess buffer with the right behavior for
182 the language you are currently working with. With S and R, use C-c
183 C-n to send lines over. With SAS, use C-c i
184 `ess-eval-line-and-step-invisibly' to send lines over invisibly."
187 (ess-add-ess-process)
188 ;; Need to select a remote-customize-alist
189 (let ((ess-customize-alist (ess-select-alist-dialect)))
190 (ess-write-to-dribble-buffer
191 (format "\n(ESS-remote): ess-dialect=%s, buf=%s\n" ess-dialect
193 (ess-setq-vars-local ess-customize-alist
)
195 (setq ess-local-process-name proc-name
)
196 (goto-char (point-max))
197 (if (equal ess-language
"S")
198 (if inferior-ess-language-start
200 ;; FIXME hack (not in line with using ess-customize-alist)
201 (setq ess-editor nil
)
203 (setq inferior-ess-language-start
(eval inferior-S-language-start
))
204 (ess-eval-linewise inferior-ess-language-start
))))
205 (if (equal ess-language
"SAS")
206 (progn (font-lock-mode 0)
209 (toggle-read-only nil
)
210 (font-lock-mode 1)))))
217 \f ; Local variables section
219 ;;; This file is automatically placed in Outline minor mode.
220 ;;; The file is structured as follows:
223 ;;; Subsections: ;;;*;;;
224 ;;; Components: defuns, defvars, defconsts
225 ;;; Random code beginning with a ;;;;* comment
229 ;;; outline-minor-mode: nil
230 ;;; mode: outline-minor
231 ;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*"
234 ;;; essd-els.el ends here