Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
2701 views
1
;;; ess-s4-d.el --- S4 customization
2
3
;; Copyright (C) 1997--2004 A.J. Rossini, Richard M. Heiberger, Martin
4
;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
5
6
;; Author: A.J. Rossini <[email protected]>
7
;; Created: 12 Jun 1997
8
;; Maintainer: ESS-core <[email protected]>
9
10
;; Keywords: languages
11
12
;; This file is part of ESS.
13
14
;; This file is free software; you can redistribute it and/or modify
15
;; it under the terms of the GNU General Public License as published by
16
;; the Free Software Foundation; either version 2, or (at your option)
17
;; any later version.
18
19
;; This file is distributed in the hope that it will be useful,
20
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
;; GNU General Public License for more details.
23
24
;; A copy of the GNU General Public License is available at
25
;; http://www.r-project.org/Licenses/
26
27
28
;;; Commentary:
29
30
;; DB contributed the changes from ess-s3-d.el to
31
;; ess-s4-d.el (removed the old ugly approach).
32
;; This file defines S4 customizations for ess-mode. Lots of thanks
33
;; to RMH and JMC for code and suggestions
34
35
;;; Code:
36
37
(autoload 'inferior-ess "ess-inf" "Run an ESS process.")
38
39
(require 'ess-s-l)
40
41
;; Some of this is based on files from:
42
;; Copyright (C) 1996, John M. Chambers.
43
44
(defvar S4-customize-alist
45
(append
46
'((ess-local-customize-alist . 'S4-customize-alist)
47
(ess-dialect . "S4")
48
(ess-loop-timeout . ess-S-loop-timeout);fixme: dialect spec.
49
(ess-change-sp-regexp . ess-S-change-sp-regexp)
50
(ess-help-sec-keys-alist . ess-help-S3-sec-keys-alist)
51
(ess-object-name-db-file . "ess-s4-namedb.el")
52
(inferior-ess-program . inferior-S4-program-name)
53
(inferior-ess-objects-command . ".SmodeObs(%d, pattern=\"%s\")\n")
54
;;(inferior-ess-objects-pattern . ".*") ; for new s4 stuff
55
(inferior-ess-help-command . "help(\"%s\")\n")
56
(inferior-ess-help-filetype . nil)
57
(inferior-ess-search-list-command . ".SmodePaths()\n")
58
(ess-load-command . ".SmodeLoad(\"%s\")\n")
59
(inferior-ess-dump-command . ".SmodeDump(\"%s\", \"%s\")\n")
60
61
(inferior-ess-start-file . nil) ;"~/.ess-S3")
62
(inferior-ess-start-args . "")
63
(ess-STERM . "iESS")
64
)
65
S+common-cust-alist); use S+ ones here; partly overwritten above!!
66
67
"Variables to customize for S4.")
68
69
;; For loading up the S code required for the above.
70
;;(add-hook 'ess-post-run-hook
71
;; (lambda ()
72
;; (ess-command
73
;; (concat
74
;; "if(exists(\"Sversion\")) library(emacs) else source(\""
75
;; ess-mode-run-file
76
;; "\")\n"))
77
;; (if ess-mode-run-file2
78
;; (ess-command
79
;; (concat "source(\"" ess-mode-run-file2 "\")\n")))))
80
81
82
(defun S4 ()
83
"Call 'S version 4', from Bell Labs. New way to do it."
84
(interactive)
85
(setq ess-customize-alist S4-customize-alist)
86
(ess-write-to-dribble-buffer
87
(format "\n(S4): ess-dialect=%s, buf=%s\n" ess-dialect (current-buffer)))
88
(inferior-ess)
89
(if inferior-ess-language-start
90
(ess-eval-linewise inferior-ess-language-start)))
91
92
93
(defun S4-mode (&optional proc-name)
94
"Major mode for editing S4 source. See `ess-mode' for more help."
95
(interactive)
96
(setq ess-customize-alist S4-customize-alist)
97
(ess-mode S4-customize-alist proc-name)
98
(if ess-imenu-use-S (ess-imenu-S)))
99
100
101
;; From RMH: ALL THIS SHOULD BE INCORPORATED BY 5.0!
102
103
;;; s4.el startup file
104
;;; Richard M. Heiberger
105
;;; [email protected]
106
;;
107
;;(load "S")
108
;;(setq inferior-S-program "/disk05/s4/betaJun96/S")
109
;;(setq S-plus nil) ;; needed for non S-plus
110
;;(add-to-list 'load-path "/disk05/s4/betaJun96") ;; S-namedb.el is here
111
;;(S)
112
;;(load-file "/disk05/s4/betaJun96/library/emacs/S-modeadds.el") ;; must come after (S)
113
;;
114
;;
115
;;;;; S4 __Help, no longer S3 .Help
116
;;(load "S-help")
117
;; ;; Must follow S-help
118
;;; S-help.file line 270
119
;;(defun S-get-help-files-list nil
120
;; (mapcar 'list
121
;; (apply 'append
122
;; (mapcar (lambda (dirname)
123
;; (if (file-directory-p dirname)
124
;; (directory-files dirname)))
125
;; (mapcar (lambda (str) (concat str "/__Help"))
126
;; (S-search-list))))))
127
;;
128
;;
129
;;;;; additional font-lock-keywords for S4
130
;;
131
;;;;*;; based on S-inf.el line 107
132
;;;;(add-to-list 'S-inf-font-lock-keywords
133
;;;; '("\\<\\(^Problem\\|^Warning\\|^Error\\|Debug ?\\|Browsing in frame of\\|Local Variables\\)\\>" . font-lock-reference-face) ; S-inf problems
134
;;;;)
135
;;;;(add-to-list 'S-inf-font-lock-keywords
136
;;;; '("^R>" . font-lock-keyword-face) ; debug prompt
137
;;;;)
138
;;(inferior-S-mode)
139
;;
140
;;; S-inf.el line 150
141
;;(setq inferior-S-search-list-command "searchPaths()\n")
142
;;
143
;;;; fontify S-transcript-mode
144
;;;; overwrites S-trans.el lines 60-69
145
;;;;(setq S-trans-font-lock-keywords S-inf-font-lock-keywords)
146
;;
147
;;(load "S-mode")
148
;; ;; Must follow S-mode
149
;;;;*;; based on S-mode.el line 219
150
;;(add-to-list 'S-mode-font-lock-keywords
151
;; '("\\<\\(setGeneric\\|removeGeneric\\|setMethod\\|unsetMethod\\|setReplaceGeneric\\|setReplaceMethod\\|standardGeneric\\|setIs\\|setClass\\|representation\\)\\>" . font-lock-function-name-face) ; S4 method functions
152
;;)
153
;;
154
;;
155
;;
156
;;;;; fix to S-load-file to make C-c C-l work with S4
157
;;
158
;;;When a file sourced into S4 by C-c C-l has a syntax error
159
;;;without the following changes, the system
160
;;;freezes until it is released with ^G. The reason is that the error
161
;;;messages, including the `Debug ?' request, go to the *S-errors*
162
;;;buffer. The *S-errors* buffer is not switched to, and couldn't accept
163
;;;a response if it were.
164
;;;
165
;;;The fix requires three modification to S-inf.el and two to S-mode.el.
166
;;;The correction to S-check-source noted in smode.cmt is also necessary.
167
;;;
168
;;
169
;;; S-inf.el line 92 NEW variable
170
;;(defvar inferior-S-debug-prompt "Debug \\? (y|n): "
171
;; "The expression S uses to offer to initiate debug tracing.")
172
;;
173
;;; S-inf.el line 458
174
;;(defun inferior-S-wait-for-prompt ()
175
;; "Wait until the S process is ready for input."
176
;; (let* ((cbuffer (current-buffer))
177
;; (sprocess (get-S-process S-current-process-name))
178
;; (sbuffer (process-buffer sprocess))
179
;; r
180
;; (timeout 0))
181
;; (set-buffer sbuffer)
182
;; (while (progn
183
;; (if (not (eq (process-status sprocess) 'run))
184
;; (S-error "S process has died unexpectedly.")
185
;; (if (> (setq timeout (1+ timeout)) S-loop-timeout)
186
;; (S-error "Timeout waiting for prompt. Check inferior-S-prompt or S-loop-timeout."))
187
;; (accept-process-output)
188
;; (goto-char (point-max))
189
;;(setq end (point))
190
;; (beginning-of-line)
191
;;(setq e (buffer-substring (point) end))
192
;;(if (equal e inferior-S-debug-prompt)
193
;; (S-error "Debug prompt"))
194
;; (setq r (looking-at inferior-S-prompt))
195
;; (not (or r (looking-at ".*\\?\\s *"))))))
196
;; (goto-char (point-max))
197
;; (set-buffer cbuffer)
198
;; (symbol-value r)))
199
;;
200
;;
201
;;
202
;;; S-mode.el line 204
203
;;(setq S-dump-error-re "Problem")
204
;;
205
;;;; S-mode.el line 655
206
;;(defun S-parse-errors (showerr)
207
;; "Jump to error in last loaded S source file.
208
;;With prefix argument, only shows the errors S reported."
209
;; (interactive "P")
210
;; (S-make-buffer-current)
211
;; (let ((errbuff (get-buffer S-error-buffer-name)))
212
;; (if (not errbuff)
213
;; (error "You need to do a load first!")
214
;; (set-buffer errbuff)
215
;; (goto-char (point-max))
216
;; (if
217
;; (re-search-backward ", file \"" nil t)
218
;; (let* ((beg-pos (progn (re-search-forward "\"" nil t) (point)))
219
;; (end-pos (progn (re-search-forward "\"" nil t) (- (point) 1)))
220
;; (filename (buffer-substring beg-pos end-pos))
221
;; (fbuffer (get-file-buffer filename))
222
;; (linenum (string-to-number
223
;; (progn (re-search-backward "," nil t)
224
;; (current-word))))
225
;; (end-pos (point))
226
;; (beg-pos (progn (goto-char (point-min))
227
;; (re-search-forward ":" nil t)
228
;; (1+ (point))))
229
;; (errmess (buffer-substring beg-pos end-pos))
230
;; )
231
;; (if showerr
232
;; (S-display-temp-buffer errbuff)
233
;; (if fbuffer nil
234
;; (setq fbuffer (find-file-noselect filename))
235
;; (save-excursion
236
;; (set-buffer fbuffer)
237
;; (S-mode)))
238
;; (pop-to-buffer fbuffer)
239
;; (goto-line linenum))
240
;; (princ errmess t))
241
;; (message "Not a syntax error.")
242
;; (S-display-temp-buffer errbuff)))))
243
;;
244
;;
245
;;
246
;;;; S-inf.el line 584
247
;;(defun S-prompt-wait (proc &optional start-of-output)
248
;; "Wait for a prompt to appear at BOL of current buffer
249
;;PROC is the S process. Does not change point"
250
;; (if start-of-output nil (setq start-of-output (point-min)))
251
;; (save-excursion
252
;; (while (progn
253
;; ;; get output if there is some ready
254
;; (accept-process-output proc 0 500)
255
;; (goto-char (marker-position (process-mark proc)))
256
;; (beginning-of-line)
257
;;
258
;; (if (re-search-forward inferior-S-debug-prompt nil t)
259
;; (if (equal (get-buffer S-error-buffer-name)
260
;; (get-buffer S-error-buffer-name))
261
;; (let* ((sprocess (get-S-process S-current-process-name))
262
;; (sbuffer (process-buffer sprocess)))
263
;; (set-buffer sbuffer)
264
;; (process-send-string sprocess "n\n")
265
;; (accept-process-output sprocess)
266
;; (beginning-of-line); delete inferior-S-debug-prompt
267
;; (kill-line)
268
;; (insert "> ")))
269
;;
270
;; (if (< (point) start-of-output) (goto-char start-of-output))
271
;; (not (looking-at inferior-S-primary-prompt)))))))
272
;;
273
274
275
276
; Provide package
277
278
(provide 'ess-s4-d)
279
280
; Local variables section
281
282
;;; This file is automatically placed in Outline minor mode.
283
;;; The file is structured as follows:
284
;;; Chapters: ^L ;
285
;;; Sections: ;;*;;
286
;;; Subsections: ;;;*;;;
287
;;; Components: defuns, defvars, defconsts
288
;;; Random code beginning with a ;;;;* comment
289
290
;;; Local variables:
291
;;; mode: emacs-lisp
292
;;; outline-minor-mode: nil
293
;;; mode: outline-minor
294
;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*"
295
;;; End:
296
297
;;; ess-s4-d.el ends here
298
299