1
;;; ess-site.el --- user customization of ess-mode
1
;;; ess-site.el --- user customization of ESS
3
3
;; Copyright (C) 1993 David M. Smith
4
;; Copyright (C) 1997--2001 A.J. Rossini, R.M. Heiberger, Martin
5
;; Maechler, Kurt Hornik, Rodney Sparapani.
4
;; Copyright (C) 1997--2004 A.J. Rossini, Rich M. Heiberger, Martin
5
;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
7
;; Author: David Smith <D.M.Smith@lancaster.ac.uk>
8
;; Maintainer: A.J. Rossini <rossini@biostat.washington.edu>
7
;; Original Author: David Smith <D.M.Smith@lancaster.ac.uk>
9
8
;; Created: 12 Nov 1993
10
;; Modified: $Date: 2002/01/21 03:21:26 $
11
;; Version: $Revision: 5.86 $
12
;; RCS: $Id: ess-site.el,v 5.86 2002/01/21 03:21:26 rmh Exp $
9
;; Maintainers: ESS-core <ESS-core@stat.math.ethz.ch>
14
11
;; Keywords: start up, configuration.
16
13
;; This file is part of ESS
170
170
;;; The following require sets the following ess-local-custom-available to
171
171
;;; true if custom is provided at this point. If we think it will be,
172
172
;;; then we can use the following (uncommented out) to make sure that
173
;;; it will be. (AJR).
173
;;; it will be. (AJR).
174
174
(require 'ess-emcs)
175
175
;; This will override what Emacs thinks it can detect.
176
176
;;(setq ess-local-custom-available t); if custom is available, uncomment
179
;;; (1.2) Uncomment the following 4 lines to fix the infopath, if needed.
180
;;(defun add-info-path (newpath)
181
;; (setq Info-default-directory-list
182
;; (cons (expand-file-name newpath) Info-default-directory-list)))
183
;;(add-info-path (concat ess-lisp-directory "/../doc/"))
178
;; SJE Thu 13 May 2004
179
;; Maybe ess-etc-directory should not be defcustom, since its value
180
;; depends on ess-lisp-directory, and is needed by other modes that are
181
;; loaded before the custom code.
182
(defvar ess-etc-directory nil
183
"*Location of the ESS etc/ directory.
184
The ESS etc directory stores various auxillary files that are useful
185
for ESS, such as icons.")
187
(defvar ess-etc-directory-list
188
'("../etc/" "../etc/ess/" "../../etc/ess/" "./etc/")
189
"*List of directories, relative to `ess-lisp-directory', to search for etc.")
191
(while (and (listp ess-etc-directory-list) (consp ess-etc-directory-list))
192
(setq ess-etc-directory
193
(expand-file-name (concat ess-lisp-directory "/"
194
(car ess-etc-directory-list))))
195
(if (file-directory-p ess-etc-directory)
196
(setq ess-etc-directory-list nil)
197
(setq ess-etc-directory nil)
198
(setq ess-etc-directory-list (cdr ess-etc-directory-list))
199
(when (null ess-etc-directory-list)
202
"ERROR:ess-site.el:ess-etc-directory\n"
203
"Relative to ess-lisp-directory\n"
204
"At least one of ../etc, ../etc/ess, ../../etc/ess must exist!"))
207
(defvar ess-info-directory nil
208
"*Location of the ESS info/ directory.
209
The ESS info directory stores the ESS info files.")
211
;;(1.2) If ess.info is not found, then ess-lisp-directory/../doc/info is added
212
;; resurrecting Stephen's version with a bug-fix & xemacs compatibility
215
(mapcar 'file-exists-p
216
(mapcar '(lambda (x) (concat (file-name-as-directory x) "ess.info"))
217
(if (featurep 'xemacs)
218
Info-directory-list Info-default-directory-list))))
219
(add-to-list (if (featurep 'xemacs)
220
'Info-directory-list 'Info-default-directory-list)
222
(concat ess-lisp-directory "/../doc/info/"))))
186
224
;;; (1.3) Files ending in .q and .S are considered to be S source files
187
225
;;; Files ending in .St are considered to be S transcript files
188
227
;;; NB: in standard Emacs, files ending in .s are assembler files. If you
189
;;; want to use assembler, comment the appropriate
228
;;; want to use assembler, you can comment the appropriate line below. Of
229
;;; course, different users will want different modes. If a user wants to
230
;;; restore default the default modes for assembly file extensions, the
231
;;; following can go into ~/.emacs:
233
;;; (add-hook 'ess-mode-hook 'ess-restore-asm-extns)
234
;;; (add-hook 'inferior-ess-mode-hook 'ess-restore-asm-extns)
192
236
(autoload 'Rd-mode "essddr" "Major mode for editing R documentation." t)
194
;; This fails in Emacs. How can it be done simply? Should it be
195
;; done? It works in XEmacs.
196
;; ;; get rid of assembler mode.
197
;; (set auto-mode-alist (remassoc "\\.[sS]\\'" auto-mode-alist))
198
;; Our current solution is as follows.
238
;; This is thanks to Ed L Cashin <ecashin@uga.edu>, 03 Mar 2004 :
239
(defun ess-restore-asm-extns ()
240
"take away the S-Plus mode association for .s and .S files added by ESS
241
Putting the following in ~/.emacs restores emacs' default association
242
between .s or .S files and assembly mode.
244
(add-hook 'ess-mode-hook 'ess-restore-asm-extns)
245
(add-hook 'inferior-ess-mode-hook 'ess-restore-asm-extns)
248
(if (assoc "\\.[qsS]\\'" auto-mode-alist)
250
(setq auto-mode-alist
251
(remassoc "\\.[qsS]\\'" auto-mode-alist))
252
;; put .q extention back
253
;; (add-to-list is in xemacs and GNU emacs)
254
(add-to-list 'auto-mode-alist '("\\.q\\'" . S-mode)))))
200
256
;; Be careful when editing the following. MISTAKES WILL RESULT IN
201
257
;; *.sty BEING TREATED AS ESS[S], rather than LaTeX-mode!
203
259
(if (assoc "\\.[rR]\\'" auto-mode-alist) nil
204
260
(setq auto-mode-alist
206
'(("\\.sp\\'" . S-mode) ;; re: Don MacQueen <macq@llnl.gov>
207
("\\.[qsS]\\'" . S-mode) ;; q,s,S
208
("\\.ssc\\'" . S-mode) ;; Splus 4.x script files.
209
("\\.[rR]\\'" . R-mode)
262
'(("\\.sp\\'" . S-mode) ;; re: Don MacQueen <macq@llnl.gov>
263
("\\.[qsS]\\'" . S-mode) ;; q,s,S [see ess-restore-asm-extns above!]
264
("\\.ssc\\'" . S-mode) ;; Splus 4.x script files.
265
("\\.[rR]\\'" . R-mode)
266
("\\.[rR]nw\\'" . Rnw-mode)
210
267
("\\.[rR]profile\\'" . R-mode)
268
("NAMESPACE\\'" . R-mode)
211
269
("\\.omg\\'" . omegahat-mode)
212
270
("\\.hat\\'" . omegahat-mode) ;; Duncan's pref'd...
213
271
("\\.lsp\\'" . XLS-mode)
214
272
("\\.do\\'" . STA-mode)
215
273
("\\.ado\\'" . STA-mode)
216
("\\.sas\\'" . SAS-mode)
217
("\\.SAS\\'" . SAS-mode)
218
;;("\\.lst\\'" . SAS-listing-mode);sasl
219
;; Too many *.log files, not only SAS :
220
;;("\\.log\\'" . SAS-log-mode);sasl
274
("\\.[Ss][Aa][Ss]\\'" . SAS-mode)
275
;; Many .log/.lst files, not just SAS
276
;;("\\.log\\'" . SAS-log-mode)
277
;;("\\.lst\\'" . SAS-listing-mode)
221
278
("\\.[Ss]t\\'" . S-transcript-mode)
222
279
("\\.[Ss]out" . S-transcript-mode)
223
280
("\\.[Rr]t\\'" . R-transcript-mode)
302
360
;;(setq-default inferior-Sqpe+6-SHOME-name "c:/progra~1/Insightful/SPLUS6")
303
361
;;(setq-default inferior-Sqpe+6-program-name "c:/progra~1/Insightful/SPLUS6/cmd/Sqpe.exe")
305
;;; These ddeclient values will be buffer-local on WS-Windows 9x/NT
363
;;; These ddeclient values will be buffer-local on MS-Windows 9x/NT
306
364
(setq-default inferior-ess-ddeclient "Initial")
307
365
(setq-default inferior-ess-client-name "Initial")
308
366
(setq-default inferior-ess-client-command "Initial")
368
;;; S-Plus 6 for Windows startup time depends on the amount of RAM and
369
;;; the processor speed. ESS needs to build a delay into the M-x S+6
370
;;; sequence to allow time for S-Plus 6 to open the Commands window.
371
;;; We then send several lines to the Commands window before returning
372
;;; control to the user. On a 300 MHz machine with 96MB of RAM the
373
;;; delay is 60 seconds. On a ???? MHz machine with 523MB the delay is
374
;;; 10 seconds. The user may need to adjust this number.
375
(defvar ess-S+6-startup-delay 15 ;; <- 2005-01-03; MM
376
"*Number of seconds to wait for the Commands window to appear before
377
sending `inferior-ess-language-start' to S-Plus.")
312
380
;;; see essd-els.el
327
395
;; (1.5) Require the needed dialects for your setup.
328
(if (< max-specpdl-size 700) ;;; ESS won't load at the default of 600
396
(if (< max-specpdl-size 700) ;;; ESS won't load at the default of 600
329
397
(setq max-specpdl-size 700))
331
399
(ess-message "[ess-site:] Before requiring dialect 'essd-** ....")
332
400
(ess-message "[ess-site:] require 'essd-r ...")
333
(require 'essd-r) ;; S and common variants
334
(ess-message "[ess-site:] require 'essd-s4 ...")
401
(require 'essd-r) ;; R
402
;; (ess-message "[ess-site:] require 'essd-s4 ...")
403
;; (require 'essd-s4) ; has become VERY RARE ..
336
405
;;(ess-message "[ess-site:] require 'essd-s3 ...")
337
406
;;(require 'essd-s3) ; THIS IS RARE. You probably do not have this.
408
;; "sp" refers to S-PLUS (MathSoft/StatSci/Insightful):
338
409
(ess-message "[ess-site:] require 'essd-sp3 ...")
339
(require 'essd-sp3) ;; "sp" refers to S-PLUS (MathSoft/StatSci).
341
412
(if ess-microsoft-p
343
414
(ess-message "[ess-site:] require 'essd-sp4 ...")
344
415
(require 'essd-sp4)
345
(ess-message "[ess-site:] require 'essdsp6w ...")
416
(ess-message "[ess-site:] require 'essd-sp6w ...")
417
(require 'essd-sp6w))
347
419
(ess-message "[ess-site:] require 'essd-sp5 ...")
348
420
(require 'essd-sp5)
349
421
(ess-message "[ess-site:] require 'essd-sp6 ...")
448
517
(fset 'S-transcript-mode 's-transcript-mode)
449
518
(fset 'S-mode 's-mode)
520
;;; Create functions for calling older versions of R and Sqpe.
521
(let ( (ess-sqpe-versions-created)
522
(ess-rterm-versions-created)
523
(ess-r-versions-created)
524
(ess-versions-created)
528
(setq ess-sqpe-versions-created
529
(ess-sqpe-versions-create)) ;; use ess-SHOME-versions
530
(setq ess-rterm-versions (ess-find-rterm))
531
(setq ess-rterm-versions-created
532
(ess-rterm-versions-create))) ;; use ess-rterm-versions
533
(setq ess-r-versions-created
534
(ess-r-versions-create))) ;; use ess-r-versions
536
;; Add the new defuns, if any, to the menu.
537
;; Check that each variable exists, before adding.
538
;; e.g. ess-sqpe-versions-created will not be created on Unix.
539
(setq ess-versions-created
541
(mapcar (lambda(x) (if (boundp x) (symbol-value x) nil))
542
'(ess-r-versions-created
543
ess-rterm-versions-created ess-sqpe-versions-created))))
545
(when ess-versions-created
546
;; new-menu will be a list of 3-vectors, of the form:
547
;; ["R-1.8.1" R-1.8.1 t]
548
(let (( new-menu (mapcar '(lambda(x) (vector x (intern x) t))
549
ess-versions-created)))
550
(easy-menu-add-item ess-mode-menu '("Start Process")
551
(cons "Other" new-menu)))))
454
554
;;; 3. Customization (and commented out examples) for your site
558
657
;;; There are two sets of alternatives.
559
658
;;; 1. Editing SAS-mode files.
560
659
;;; 1a. Default: TAB is bound to sas-indent-line.
561
;;; Current line is correctly indented as SAS code. Equivalent to
562
;;;(setq ess-sas-edit-keys-toggle 0) ;; default TAB in sas-mode
660
;;; Current line is correctly indented as SAS code. Equivalent to
661
;;;(setq ess-sas-edit-keys-toggle nil) ;; default TAB in sas-mode
563
662
;;; 1b. Optional: TAB is bound to tab-to-tab-stop and inserts up to 4
564
;;; columns at a time. C-TAB moves backwards and deletes characters
565
;;; up to 4 columns at a time.
566
;;; Uncomment the following line for the optional behavior.
567
;;;(setq ess-sas-edit-keys-toggle 1) ;; optional TAB and C-TAB in sas-mode
568
;;; Use the function call (ess-sas-edit-keys-toggle 0)
569
;;; or (ess-sas-edit-keys-toggle 1)
663
;;; columns at a time. C-TAB moves backwards and deletes characters
664
;;; up to 4 columns at a time.
665
;;; Uncomment the following line for the optional behavior.
666
;;;(setq ess-sas-edit-keys-toggle t) ;; optional TAB and C-TAB in sas-mode
667
;;; Use the function call (ess-sas-edit-keys-toggle)
570
668
;;; to change the setting after the first SAS-mode buffer has been created.
571
669
;;; 1c. You can also define C-TAB in all modes by specifying either
572
670
;;;(setq ess-sas-global-unix-keys t) ;; optional C-TAB bound in all modes
573
671
;;;(setq ess-sas-global-pc-keys t) ;; optional C-TAB bound in all modes
576
674
;;; 2. Managing submitted SAS jobs with function keys.
577
675
;;; 2a. Default: Function keys retain their global bindings.
582
680
;;;(setq ess-sas-global-pc-keys t) ;; [f2]--[f8] bound in all modes
584
682
;;; 3. If it is more convenient to have "*Async Shell Command*"
585
;;; in same-window-buffer-names, then uncomment the following line
683
;;; in same-window-buffer-names, then uncomment the following line
586
684
;;;(ess-same-window-async)
588
;;; 4. As of 5.1.19, a new and improved syntax highlighting scheme for .sas and .log
589
;;; files is available (press f10 to toggle between modes in .log). If you are
590
;;; using XEmacs v. 20.x, then you need this as well, since it works around a
591
;;; problem with make-regexp.el. Uncomment the next line for this feature:
592
;;;(setq ess-sas-run-make-regexp nil)
595
;(defvar sas-require-confirmation t
596
; "*Require confirmation when revisiting sas-output which has changed on disk.")
597
;;; added sas-program 4/29/94. user can specify a different version of sas.
598
686
;;;(defvar sas-program "sas" "*Name of program which runs sas.")
599
;;(defvar sas-pre-run-hook nil
600
;; "Hook to execute prior to running SAS vis submit-sas.")
601
;;(defvar sas-options-string ""
602
;; "*Options to be passed to sas as if typed on the command line.")
603
;;(defvar sas-indent-width 4 "*Amount to indent sas statements")
604
;;(defvar sas-notify t "*Beep and display message when job is done?") ;; added 4/7/94
605
;;(defvar sas-error-notify t
606
;; "*If sas-notify is t, then indicate errors in log file upon completion")
608
;;(defvar sas-get-options nil "Options to be passed to SAS in sas-get-dataset")
609
;;(defvar sas-get-options-history nil "History list of Options passed to SAS in sas-get-dataset")
610
;;(defvar sas-page-number-max-line 3
611
;; "*Number of lines from the page break in which to search for the page number")
612
;;(defvar sas-indent-ignore-comment "*"
613
;; "*Comments with start with this string are ignored in indentation.")
614
;;(defvar sas-notify-popup nil
615
;; "*If t (and sas-notify is also t), causes emacs to create a
616
;;popup window when the SAS job is finished.")
617
;;(defvar sas-tmp-libname "_tmp_" "*Libname to use for sas-get-dataset.")
619
;;; 5.0 Noweb and Literate Data Analysis configuration
621
;; already above [1.7]: (require 'ess-noweb)
688
;;;(defvar sas-indent-width 4 "*Amount to indent sas statements")
623
690
; Local variables section