1 ;;; essd-s4.el --- S4 customization
3 ;; Copyright (C) 1997--2004 A.J. Rossini, Rich M. Heiberger, Martin
4 ;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
6 ;; Original Author: A.J. Rossini <rossini@stat.sc.edu>
7 ;; Created: 12 Jun 1997
8 ;; Maintainers: ESS-core <ESS-core@stat.math.ethz.ch>
10 ;; Keywords: start up, configuration.
12 ;; This file is part of ESS.
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)
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.
24 ;; You should have received a copy of the GNU General Public License
25 ;; along with GNU Emacs; see the file COPYING. If not, write to
26 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
29 ;;; DB contributed the changes from essd-sp3.el to
30 ;;; essd-s4.el. (removed the old ugly approach).
31 ;;; This file defines S4 customizations for ess-mode. Lots of thanks
32 ;;; to RMH and JMC for code and suggestions
38 (autoload 'inferior-ess
"ess-inf" "Run an ESS process.")
42 ;; Some of this is based on files from:
43 ;; Copyright (C) 1996, John M. Chambers.
45 (defvar S4-customize-alist
47 '((ess-local-customize-alist .
'S4-customize-alist
)
49 (ess-loop-timeout . ess-S-loop-timeout
);fixme: dialect spec.
50 (ess-change-sp-regexp . ess-S-change-sp-regexp
)
51 (ess-help-sec-keys-alist . ess-help-S3-sec-keys-alist
)
52 (ess-object-name-db-file .
"ess-s4-namedb.el")
53 (inferior-ess-program . inferior-S4-program-name
)
54 (inferior-ess-objects-command .
".SmodeObs(%d, pattern=\"%s\")\n")
55 ;;(inferior-ess-objects-pattern . ".*") ; for new s4 stuff
56 (inferior-ess-help-command .
"help(\"%s\")\n")
57 (inferior-ess-search-list-command .
".SmodePaths()\n")
58 (inferior-ess-load-command .
".SmodeLoad(\"%s\")\n")
59 (inferior-ess-dump-command .
".SmodeDump(\"%s\", \"%s\")\n")
61 (inferior-ess-start-file . nil
) ;"~/.ess-S3")
62 (inferior-ess-start-args .
"")
65 S
+common-cust-alist
); use S+ ones here; partly overwritten above!!
67 "Variables to customize for S4.")
69 ;; For loading up the S code required for the above.
70 ;;(add-hook 'ess-post-run-hook
74 ;; "if(exists(\"Sversion\")) library(emacs) else source(\""
77 ;; (if ess-mode-run-file2
79 ;; (concat "source(\"" ess-mode-run-file2 "\")\n")))))
83 "Call 'S version 4', from Bell Labs. New way to do it."
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)))
89 (if inferior-ess-language-start
90 (ess-eval-linewise inferior-ess-language-start
)))
93 (defun S4-mode (&optional proc-name
)
94 "Major mode for editing S4 source. See `ess-mode' for more help."
96 (setq ess-customize-alist S4-customize-alist
)
97 (ess-mode S4-customize-alist proc-name
)
98 (if ess-imenu-use-S
(ess-imenu-R)))
101 ;; From RMH: ALL THIS SHOULD BE INCORPORATED BY 5.0!
103 ;;; s4.el startup file
104 ;;; Richard M. Heiberger
105 ;;; rmh@astro.ocis.temple.edu
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
112 ;;(load-file "/disk05/s4/betaJun96/library/emacs/S-modeadds.el") ;; must come after (S)
115 ;;;;; S4 __Help, no longer S3 .Help
117 ;; ;; Must follow S-help
118 ;;; S-help.file line 270
119 ;;(defun S-get-help-files-list nil
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))))))
129 ;;;;; additional font-lock-keywords for S4
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
135 ;;;;(add-to-list 'S-inf-font-lock-keywords
136 ;;;; '("^R>" . font-lock-keyword-face) ; debug prompt
140 ;;; S-inf.el line 150
141 ;;(setq inferior-S-search-list-command "searchPaths()\n")
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)
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
156 ;;;;; fix to S-load-file to make C-c C-l work with S4
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.
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.
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.")
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))
181 ;; (set-buffer sbuffer)
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))
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)))
202 ;;; S-mode.el line 204
203 ;;(setq S-dump-error-re "Problem")
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."
210 ;; (S-make-buffer-current)
211 ;; (let ((errbuff (get-buffer S-error-buffer-name)))
213 ;; (error "You need to do a load first!")
214 ;; (set-buffer errbuff)
215 ;; (goto-char (point-max))
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-int
223 ;; (progn (re-search-backward "," nil t)
226 ;; (beg-pos (progn (goto-char (point-min))
227 ;; (re-search-forward ":" nil t)
229 ;; (errmess (buffer-substring beg-pos end-pos))
232 ;; (S-display-temp-buffer errbuff)
234 ;; (setq fbuffer (find-file-noselect filename))
236 ;; (set-buffer fbuffer)
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)))))
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)))
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)
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
270 ;; (if (< (point) start-of-output) (goto-char start-of-output))
271 ;; (not (looking-at inferior-S-primary-prompt)))))))
280 \f ; Local variables section
282 ;;; This file is automatically placed in Outline minor mode.
283 ;;; The file is structured as follows:
286 ;;; Subsections: ;;;*;;;
287 ;;; Components: defuns, defvars, defconsts
288 ;;; Random code beginning with a ;;;;* comment
292 ;;; outline-minor-mode: nil
293 ;;; mode: outline-minor
294 ;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*"
297 ;;; essd-s4.el ends here