*** empty log message ***
[ess.git] / lisp / ess-site.el
blobd0a3027e786906fb55d6c4c956a5a363f7026824
1 ;;; ess-site.el --- user customization of ESS
3 ;; Copyright (C) 1993 David M. Smith
4 ;; Copyright (C) 1997--2006 A.J. Rossini, Rich M. Heiberger, Martin
5 ;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
7 ;; Original Author: David Smith <D.M.Smith@lancaster.ac.uk>
8 ;; Created: 12 Nov 1993
9 ;; Maintainers: ESS-core <ESS-core@stat.math.ethz.ch>
11 ;; Keywords: start up, configuration.
13 ;; This file is part of ESS
15 ;; This file is free software; you can redistribute it and/or modify
16 ;; it under the terms of the GNU General Public License as published by
17 ;; the Free Software Foundation; either version 2, or (at your option)
18 ;; any later version.
20 ;; This file is distributed in the hope that it will be useful,
21 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 ;; GNU General Public License for more details.
25 ;; You should have received a copy of the GNU General Public License
26 ;; along with GNU Emacs; see the file COPYING. If not, write to
27 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
29 ;;; Commentary:
31 ;;; This file defines all the site-specific customizations for ESS.
32 ;;; It should be edited on a per-site basis. Read the comments (1.1
33 ;;; in Section 1 to see if ess-site.el must be edited. The final
34 ;;; directory location of this file must be supplied in
35 ;;; ess-lisp-directory. The editing of remaining sections is
36 ;;; optional. It should then be byte-compiled, and users who wish to
37 ;;; use ESS should add the line:
38 ;;; (load "/PATH/TO/THIS/FILE/ess-site")
39 ;;; (where /PATH/TO/THIS/FILE is the path to ess-site.elc: i.e. the
40 ;;; value of ess-lisp-directory, below) to their .emacs file.
41 ;;;
42 ;;; Alternatively, if the file is already in a directory specified by
43 ;;; the load-path variable:
44 ;;; (require 'ess-site)
45 ;;; will work.
46 ;;;
47 ;;; with XEmacs, this is simply:
48 ;;; (add-path "/path/to/ess/lisp-directory")
49 ;;; with Emacs (and in general):
50 ;;; (setq load-path (cons "/path/to/ess/lisp-directory" load-path)
51 ;;;
53 ;; provide here; otherwise we'll get infinite loops of (require ..):
54 (provide 'ess-site)
56 ;;; Code:
58 ;;;; 1. Load path, autoloads, and major modes
59 ;;;; ========================================
60 ;;;
61 ;;; (1.1) For most users the variable ess-lisp-directory will
62 ;;; automatically be set correctly. If you are working with an old
63 ;;; emacs, one in which file-truename is not defined, then you might
64 ;;; need to change the value of ess-lisp-directory to the directory
65 ;;; which is to contain the file ess-site.elc. This is probably the
66 ;;; current directory, or the value of LISPDIR if it was set in the
67 ;;; Makefile.
69 (eval-and-compile
71 ;; Not important in XEmacs, if unpacking from ../xemacs/site-lisp/
72 ;; directory.
74 ;; WARNING: with Emacs 20.2 (and 20.3 in one case),
75 ;; ======= MUST USE ONE OF THE NON-DEFAULT SETTINGS BELOW
77 ;; NOTE again: MOST people should NOT change anything here !!!
78 ;; ==== ==== ================
80 ;; A nice default
81 (defvar ess-lisp-directory
82 (if (and (boundp 'load-file-name) load-file-name)
83 ;; A nice default
84 (directory-file-name (file-name-directory
85 (file-truename load-file-name)))
86 (defun find-load-file-directory nil
87 "Locate directory in which load-file sits."
88 (interactive)
89 (let ((load-file-directory)
90 (beg (point)))
91 (list-command-history)
92 (set-buffer "*Command History*")
93 (goto-char (point-min))
94 (search-forward "(load-file ")
95 (goto-char (1+ (match-end 0)))
96 (setq beg (point))
97 (end-of-line)(search-backward "/")
98 (goto-char (match-end 0))
99 (setq load-file-directory
100 (expand-file-name (buffer-substring beg (point))))
101 (kill-buffer "*Command History*")
102 load-file-directory))
103 (directory-file-name (find-load-file-directory)))
104 "Directory containing ess-site.el and other ESS files.")
106 ;; NON DEFAULTS:
107 ;;(defvar ess-lisp-directory
108 ;;(directory-file-name "/usr/local/lib/xemacs/site-lisp/ess-/lisp"))
109 ;; >> or replace "ess-" above by "ESS" which would be a symbolic link..
110 ;; >> This way, your .emacs (or default.el or site-start.el)
111 ;; >> won't have to change with each version of ESS
113 ;; example of "local" or personal use
114 ;;(defvar ess-lisp-directory
115 ;;(directory-file-name "/stat2/faculty/rossini/ESS/lisp"))
117 ;; emacs 19.28 doesn't have functions we need, therefore we provide them
118 ;; by using files from emacs 19.29
119 (if (and (equal emacs-major-version 19) (equal emacs-minor-version 28))
120 (progn
121 (require 'cl) ; rassoc
122 ;; add-to-list taken from subr.el
123 ;; we use functions not in 19.28, so include them
124 (load-file (concat ess-lisp-directory "/19.29/extras.el"))
125 (load-file (concat ess-lisp-directory "/19.29/easymenu.el"))
126 ;; (if window-system ;; essl-sas wants these even without window-system
127 (progn
128 ;; comment and reference faces
129 (load-file (concat ess-lisp-directory
130 "/19.29/faces.el"))
131 ;; font-lock features not in 19.28
132 (load-file (concat ess-lisp-directory
133 "/19.29/font-lock.el")))))
136 ;; emacs 19.28 and 19.29 don't have functions we need.
137 (if (not (fboundp 'file-name-sans-extension))
138 ;; take the definition from emacs-20.6/lisp/files.el:
139 (defun file-name-sans-extension (filename)
140 "Return FILENAME sans final \"extension\".
141 The extension, in a file name, is the part that follows the last `.'."
142 (save-match-data
143 (let ((file (file-name-sans-versions
144 (file-name-nondirectory filename)))
145 directory)
146 (if (string-match "\\.[^.]*\\'" file)
147 (if (setq directory (file-name-directory filename))
148 (expand-file-name (substring file 0 (match-beginning 0))
149 directory)
150 (substring file 0 (match-beginning 0)))
151 filename)))))
153 (add-to-list 'load-path (file-name-as-directory ess-lisp-directory))
155 ;; Need these as early as here [also in ./ess-comp.el] :
156 (if (not (boundp 'ess-show-load-messages))
157 (defvar ess-show-load-messages nil
158 "If t, show many more \"loading ..\" messages."))
159 (if (not (fboundp 'ess-message))
160 (defun ess-message (msg)
161 "Shortcut for \\[message] only if `ess-show-load-messages' is non-nil."
162 (if ess-show-load-messages (message msg))))); eval-*-compile
164 ;; DEBUG: (setq ess-show-load-messages t); instead of nil above
166 (ess-message "[ess-site:] after (eval-and-compile ..)")
167 ;; load code to figure out what version/strain of Emacs we are running
168 ;; must come *AFTER* load-path is set !
170 ;;; The following require sets the following ess-local-custom-available to
171 ;;; true if custom is provided at this point. If we think it will be,
172 ;;; then we can use the following (uncommented out) to make sure that
173 ;;; it will be. (AJR).
174 (require 'ess-emcs)
175 ;; This will override what Emacs thinks it can detect.
176 ;;(setq ess-local-custom-available t); if custom is available, uncomment
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/ess/" "../etc/" "../../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)
200 (beep 0) (beep 0)
201 (message (concat
202 "ERROR:ess-site.el:ess-etc-directory\n"
203 "Relative to ess-lisp-directory, one of the following must exist:\n"
204 "../etc/ess, ../etc, ../../etc/ess or ./etc"))
205 (sit-for 4))))
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
213 (unless
214 ;; challenge: can this become more elegant?
215 (member t
216 (mapcar 'file-exists-p
217 (mapcar
218 '(lambda(x) (concat (file-name-as-directory x) "ess.info"))
219 (if (featurep 'xemacs) Info-directory-list
220 Info-default-directory-list))))
221 (add-to-list (if (featurep 'xemacs)
222 'Info-directory-list 'Info-default-directory-list)
223 (expand-file-name "../doc/info/" ess-lisp-directory)))
225 ;;; (1.3) Files ending in .q and .S are considered to be S source files
226 ;;; Files ending in .St are considered to be S transcript files
228 ;;; NB: in standard Emacs, files ending in .s are assembler files. If you
229 ;;; want to use assembler, you can comment the appropriate line below. Of
230 ;;; course, different users will want different modes. If a user wants to
231 ;;; restore default the default modes for assembly file extensions, the
232 ;;; following can go into ~/.emacs:
234 ;;; (add-hook 'ess-mode-hook 'ess-restore-asm-extns)
235 ;;; (add-hook 'inferior-ess-mode-hook 'ess-restore-asm-extns)
237 (autoload 'Rd-mode "essddr" "Major mode for editing R documentation." t)
239 ;; This is thanks to Ed L Cashin <ecashin@uga.edu>, 03 Mar 2004 :
240 (defun ess-restore-asm-extns ()
241 "take away the S-Plus mode association for .s and .S files added by ESS
242 Putting the following in ~/.emacs restores emacs' default association
243 between .s or .S files and assembly mode.
245 (add-hook 'ess-mode-hook 'ess-restore-asm-extns)
246 (add-hook 'inferior-ess-mode-hook 'ess-restore-asm-extns)
248 (interactive)
249 (if (assoc "\\.[qsS]\\'" auto-mode-alist)
250 (progn
251 (setq auto-mode-alist
252 (remassoc "\\.[qsS]\\'" auto-mode-alist))
253 ;; put .q extention back
254 ;; (add-to-list is in xemacs and GNU emacs)
255 (add-to-list 'auto-mode-alist '("\\.q\\'" . S-mode)))))
257 ;; Be careful when editing the following. MISTAKES WILL RESULT IN
258 ;; *.sty BEING TREATED AS ESS[S], rather than LaTeX-mode!
260 (if (assoc "\\.[rR]\\'" auto-mode-alist) nil
261 (setq auto-mode-alist
262 (append
263 '(("\\.sp\\'" . S-mode) ;; re: Don MacQueen <macq@llnl.gov>
264 ("\\.[qsS]\\'" . S-mode) ;; q,s,S [see ess-restore-asm-extns above!]
265 ("\\.ssc\\'" . S-mode) ;; Splus 4.x script files.
266 ("\\.[rR]\\'" . R-mode)
267 ("\\.[rR]nw\\'" . Rnw-mode)
268 ("\\.[rR]profile\\'" . R-mode)
269 ("NAMESPACE\\'" . R-mode)
270 ("\\.omg\\'" . omegahat-mode)
271 ("\\.hat\\'" . omegahat-mode) ;; Duncan's pref'd...
272 ("\\.lsp\\'" . XLS-mode)
273 ("\\.do\\'" . STA-mode)
274 ("\\.ado\\'" . STA-mode)
275 ("\\.[Ss][Aa][Ss]\\'" . SAS-mode)
276 ;; Many .log/.lst files, not just SAS
277 ;;("\\.log\\'" . SAS-log-mode)
278 ;;("\\.lst\\'" . SAS-listing-mode)
279 ("\\.[Ss]t\\'" . S-transcript-mode)
280 ("\\.[Ss]out" . S-transcript-mode)
281 ("\\.[Rr]t\\'" . R-transcript-mode)
282 ("\\.[Rr]out" . R-transcript-mode)
283 ("\\.Rd\\'" . Rd-mode)
284 ("\\.[Bb][Uu][Gg]\\'" . ess-bugs-mode)
285 ("\\.[Bb][Oo][Gg]\\'" . ess-bugs-mode)
286 ("\\.[Bb][Mm][Dd]\\'" . ess-bugs-mode)
288 auto-mode-alist)))
290 ;; (1.4) Customize the dialects for your setup.
292 ;;; AS OF ESS 5.1.14, if you are using Emacs 20.x, x>3, or XEmacs
293 ;;; 21.x, x>0, you can now use the "Customize" facility for
294 ;;; customization.
296 ;;;; Choices for *(), where * is from inferior-*-program....
297 ;;; Most sites will not need to use these customized program-names. They are
298 ;;; provided for cases where the program is not on the standard default path.
299 ;;; If the program doesn't get located correctly by the default use of
300 ;;; M-x S+3 (for example), then put the path name for your system into the
301 ;;; the variable inferior-S+3-program-name. If for any reason you want the
302 ;;; default use of M-x S to refer to a different program than S+3, then
303 ;;; redefine inferior-S-program-name.
305 ;;(setq-default inferior-S3-program-name "/disk05/s/S")
306 ;;(setq-default inferior-S+3-program-name "Splus34")
307 ;;(setq-default inferior-S4-program-name "/disk05/s4/S")
308 ;;(setq-default inferior-S+4-program-name "Splus")
309 ;;(setq-default inferior-S+5-program-name "Splus5")
310 ;;(setq-default inferior-S+6-program-name "Splus7") ; unix systems
311 ;;(setq-default inferior-R-program-name "R") ; unix systems
312 ;;(setq-default inferior-R-program-name "Rterm") ; msdos systems
313 ;;(setq-default inferior-R-program-name "C:\\Program Files\\R\rw1081\\bin\\Rterm.exe") ; msdos systems
314 ;;(setq-default inferior-XLS-program-name "xlispstat")
315 ;;(setq-default inferior-ARC-program-name "arc")
316 ;;(setq-default inferior-VST-program-name "vista")
317 ;;(setq-default inferior-SAS-program-name "sas")
318 ;;(setq-default inferior-OMG-program-name "/home/rossini/src/anoncvs/Omegahat/org/omegahat/bin/omegahat")
319 (setq-default inferior-OMG-program-name "omegahat")
321 ;;; ESS on the Windows NT/95/98 assumes you have installed gnuclient
322 ;;; with your NTemacs.
323 ;;; http://www.cs.washington.edu/homes/voelker/ntemacs/contrib/gnuserv.zip
324 ;;; Should you choose not to use gnuclient, you will need to uncomment
325 ;;; the notepad definitions below.
327 ;;; Send Print from S+4 GUI Commands window print icon to emacs.
328 ;;; StatSci's S+4 default print destination for the commands window is
329 ;;(setq-default inferior-S+4-print-command "notepad/p")
331 ;;; The line below is the ESS default and sends the commands window
332 ;;; to emacs, giving the user the opportunity to
333 ;;; (1) edit the output into a clean ess-transcript file before printing, or
334 ;;; (2) print a region of the file.
335 ;;(setq-default inferior-S+4-print-command "S_PRINT_COMMAND=gnuclientw.exe")
337 ;;; The editor and pager output from S+4 and Sqpe+4 are sent by
338 ;;; StatSci default to notepad, effectively using the definition:
339 ;;(setq-default inferior-S+4-editor-pager-command
340 ;; "options(editor='notepad', pager='notepad')")
342 ;;; ESS sends the output from both commands to an emacs buffer using
343 ;;; the definition:
344 ;;(setq-default inferior-S+4-editor-pager-command
345 ;; "options(editor='gnuclient.exe', pager='gnuclientw.exe')")
347 ;;; These commands are for running the PC version of Sqpe of S+4 and
348 ;;; S+6 in an emacs buffer, using the same technology as ESS uses for
349 ;;; Unix S-Plus. Interactive graphics with javagraph are available
350 ;;; in this mode beginning with S-Plus 6.1.
351 ;;; See essd-sp4.el or essd-sp6w.el
353 ;;; These are the defaults. Change them here if the defaults don't work.
354 ;;; Use the 8.3 version of the pathname because embedded blanks will cause
355 ;;; trouble.
356 ;;; The emacs command `w32-short-file-name' will help you find the 8.3 name.
357 ;;(setq-default inferior-S+4-program-name "c:/progra~1/SPLS45SE/cmd/Splus")
358 ;;(setq-default inferior-Sqpe+4-SHOME-name "c:/progra~1/SPLS45SE")
359 ;;(setq-default inferior-Sqpe+4-program-name "c:/progra~1/SPLS45SE/cmd/Sqpe.exe")
361 ;;(setq-default inferior-S+6-program-name "c:/progra~1/Insightful/splus70/cmd/Splus")
362 ;;(setq-default inferior-Sqpe+6-SHOME-name "c:/progra~1/Insightful/splus70")
363 ;;(setq-default inferior-Sqpe+6-program-name "c:/progra~1/Insightful/splus70/cmd/Sqpe.exe")
365 ;;; These ddeclient values will be buffer-local on MS-Windows 9x/NT
366 (setq-default inferior-ess-ddeclient "Initial")
367 (setq-default inferior-ess-client-name "Initial")
368 (setq-default inferior-ess-client-command "Initial")
370 ;;; S-Plus 6 for Windows startup time depends on the amount of RAM and
371 ;;; the processor speed. ESS needs to build a delay into the M-x S+6
372 ;;; sequence to allow time for S-Plus 6 to open the Commands window.
373 ;;; We then send several lines to the Commands window before returning
374 ;;; control to the user. On a 300 MHz machine with 96MB of RAM the
375 ;;; delay is 60 seconds. On a ???? MHz machine with 523MB the delay is
376 ;;; 10 seconds. The user may need to adjust this number.
377 (defvar ess-S+6-startup-delay 15 ;; <- 2005-01-03; MM
378 "*Number of seconds to wait for the Commands window to appear before
379 sending `inferior-ess-language-start' to S-Plus.")
382 ;;; see essd-els.el
384 ;;(setq-default inferior-S-elsewhere-program-name "sh")
385 ;;(setq-default inferior-S-elsewhere-program-name "ssh")
386 ;;; You might consider using ssh, if you can! (and if you really do
387 ;;; this, use ssh-agent, etc, for securing your sessions).
390 ;;;; Choice for S().
391 ;;(setq-default inferior-S-program-name inferior-S+3-program-name)
397 ;; (1.5) Require the needed dialects for your setup.
398 (if (< max-specpdl-size 700) ;;; ESS won't load at the default of 600
399 (setq max-specpdl-size 700))
401 (ess-message "[ess-site:] Before requiring dialect 'essd-** ....")
402 (ess-message "[ess-site:] require 'essd-r ...")
403 (require 'essd-r) ;; R
404 ;; (ess-message "[ess-site:] require 'essd-s4 ...")
405 ;; (require 'essd-s4) ; has become VERY RARE ..
407 ;;(ess-message "[ess-site:] require 'essd-s3 ...")
408 ;;(require 'essd-s3) ; THIS IS RARE. You probably do not have this.
410 ;; "sp" refers to S-PLUS (MathSoft/StatSci/Insightful):
411 (ess-message "[ess-site:] require 'essd-sp3 ...")
412 (require 'essd-sp3)
414 (if ess-microsoft-p
415 (progn
416 (ess-message "[ess-site:] require 'essd-sp4 ...")
417 (require 'essd-sp4)
418 (ess-message "[ess-site:] require 'essd-sp6w ...")
419 (require 'essd-sp6w))
420 ;; else: decent OS
421 (ess-message "[ess-site:] require 'essd-sp5 ...")
422 (require 'essd-sp5)
423 (ess-message "[ess-site:] require 'essd-sp6 ...")
424 (require 'essd-sp6))
426 (ess-message "[ess-site:] require 'essd-sta ...")
427 (require 'essd-sta) ;; for Stata.
428 (ess-message "[ess-site:] require 'essd-xls ...")
429 (require 'essd-xls) ;; XLispStat
430 (ess-message "[ess-site:] require 'essd-vst ...")
431 (require 'essd-vst) ;; ViSta
432 (ess-message "[ess-site:] require 'essd-arc ...")
433 (require 'essd-arc) ;; Arc
434 (ess-message "[ess-site:] require 'essd-sas ...")
435 (require 'essd-sas)
436 (ess-message "[ess-site:] require 'essd-els ...")
437 (require 'essd-els) ;; S-elsewhere, on another machine by telnet
438 (ess-message "[ess-site:] require 'essd-omg ...")
439 (require 'essd-omg) ;; for omegahat
440 (ess-message "[ess-site:] require 'essl-bug ...")
441 (require 'essl-bug) ;; for batch BUGS
443 (ess-write-to-dribble-buffer
444 (format "[ess-site.el]: ess-customize-alist=%s \n"
445 ess-customize-alist))
447 ;;; (1.7) Literate Data Analysis
448 (require 'ess-noweb)
449 (require 'ess-swv); for Sweave
451 ;; ALWAYS:
452 (require 'ess); -> loads ess-cust.el and more
454 (ess-write-to-dribble-buffer
455 (format "[ess-site.el _2_]: ess-customize-alist=%s \n"
456 ess-customize-alist))
458 ;; (1.8) Speedbar and mouse
460 (require 'ess-menu)
461 (require 'ess-mous)
463 ;; (1.9) Toolbar support
465 ;; To remove toolbar support under ESS, either comment-out
466 ;; (require 'ess-toolbar) below, or add "(setq ess-use-toolbar nil)"
467 ;; to your .emacs before (require 'ess-site).
468 (require 'ess-toolbar)
470 ;;; 2. Site Specific setup
471 ;;;; ===============================================
473 ;;; Set this to the name of the program you use to run S or S-PLUS. It
474 ;;; can be an absolute pathname, if you wish.
475 ;;(setq inferior-ess-program "Splus")
476 ;;(setq inferior-ess-program (concat (getenv "SHOME") "/Splus"))
478 ;;; You will need to change the following two variables if you use a
479 ;;; non-standard S prompt.
480 ;; (setq inferior-ess-primary-prompt "[a-zA-Z0-9() ]*> ?")
481 ;; (setq inferior-ess-secondary-prompt "+ ?")
484 ;;; 2.1 Backwards compatibility (roll your own!)
485 ;;; What you want S and R to call...
487 (autoload 'ess-transcript-mode "ess-trns"
488 "Major mode for editing S transcript files." t)
490 (autoload 'ess-rdired "ess-rdired"
491 "View *R* objects in a dired-like buffer." t)
493 ;;; On a PC, the default is S+6.
494 ;; Elsewhere (unix and linux) the default is S+6
495 (cond (ess-microsoft-p ; MS-Windows
496 (fset 'S 'S+6)
497 (fset 'Sqpe 'Sqpe+6)
498 (fset 's-mode 'S+6-mode)
499 (fset 's-transcript-mode 'S+6-transcript-mode))
501 ((eq system-type 'gnu/linux) ; Linux -- no S+3
502 (fset 'S 'S+6)
503 (fset 's-mode 'S+6-mode)
504 (fset 's-transcript-mode 'S+6-transcript-mode))
506 (t ; Other Unixen
507 (fset 'S 'S+6)
508 (fset 's-mode 'S+6-mode)
509 (fset 's-transcript-mode 'S+6-transcript-mode)))
512 ;;;;* Alias S-mode to s-mode
513 ;;; Emacs will set the mode for a file based on the file's header.
514 ;;; The mode name is indicated by putting it between -*- on the top line.
515 ;;; (Other commands can go here too, see an Emacs manual.)
516 ;;; For a file you also load, you will want a leading # (comment to S)
517 ;;; Emacs will downcase the name of the mode, e.g., S, so we must provide
518 ;;; s-mode in lower case too. That is, "#-*- S-*-" invokes s-mode and
519 ;;; not S-mode.
520 (fset 'S-transcript-mode 's-transcript-mode)
521 (fset 'S-mode 's-mode)
523 ;;; Create functions for calling older versions of R and Sqpe.
524 (let ( (ess-sqpe-versions-created)
525 (ess-rterm-versions-created)
526 (ess-r-versions-created)
527 (ess-s-versions-created)
528 (ess-versions-created)
530 (if ess-microsoft-p
531 (progn
532 (setq ess-sqpe-versions-created
533 (ess-sqpe-versions-create)) ;; use ess-SHOME-versions
534 (setq ess-rterm-versions (ess-find-rterm))
535 (setq ess-rterm-versions-created
536 (ess-rterm-versions-create))) ;; use ess-rterm-versions
537 (progn
538 (setq ess-s-versions-created
539 (ess-s-versions-create)) ;; use ess-s-versions
540 (setq ess-r-versions-created
541 (ess-r-versions-create)))) ;; use ess-r-versions
543 ;; Add the new defuns, if any, to the menu.
544 ;; Check that each variable exists, before adding.
545 ;; e.g. ess-sqpe-versions-created will not be created on Unix.
546 (setq ess-versions-created
547 (ess-flatten-list
548 (mapcar (lambda(x) (if (boundp x) (symbol-value x) nil))
549 '(ess-r-versions-created
550 ess-rterm-versions-created
551 ess-s-versions-created
552 ess-sqpe-versions-created))))
554 (when ess-versions-created
555 ;; new-menu will be a list of 3-vectors, of the form:
556 ;; ["R-1.8.1" R-1.8.1 t]
557 (let (( new-menu (mapcar '(lambda(x) (vector x (intern x) t))
558 ess-versions-created)))
559 (easy-menu-add-item ess-mode-menu '("Start Process")
560 (cons "Other" new-menu)))))
563 ;;; 3. Customization (and commented out examples) for your site
564 ;;;; ===============================================
567 ;;; (3.01) SOME PEOPLE (who will remain nameless) worry that novices
568 ;;; won't like fancy buffer names for their first (and only :-)
569 ;;; process. To number all processes, uncomment the next line.
570 ;;(setq ess-plain-first-buffername nil)
572 ;;; (3.02) Some people have requested using the program name as part
573 ;;; of the buffer. Turned on for R.
574 ;;(setq ess-use-inferior-program-name-in-buffer-name t)
577 ;;; (3.1) Font-lock
578 ;; The following two expressions automatically enable font-lock-mode
579 ;; for ess-mode and inferior-ess-mode buffers.
581 ;; FIXME: XEmacs and Emacs 21.x has font-lock for ttys, as well.
582 ;; So we need a better check! [or do this unconditionally -working everywhere ??]
583 (if window-system
584 (progn
585 (add-hook 'ess-mode-hook 'turn-on-font-lock t)
586 (add-hook 'ess-transcript-mode-hook 'turn-on-font-lock t)
587 (add-hook 'inferior-ess-mode-hook 'turn-on-font-lock t)))
589 ;; If nil, then don't font-lock the input
590 ;; if t, font-lock (default).
591 (setq inferior-ess-font-lock-input t) ; from RMH
593 ;;; (3.2) Framepop. Windows produced by ess-execute-objects etc. are
594 ;;; often unnecessarily large. The framepop package makes such
595 ;;; windows appear in a separate, shrink-wrapped frame. This will
596 ;;; also affect other "temporary" windows such as those produced by
597 ;;; C-h k, etc. To enable, uncomment both lines of code below).
599 ;;; Works only with Emacs at this time.
600 ;; (cond (window-system
601 ;; (require 'framepop)))
603 ;;; (3.3) ess-keep-dump-files.
604 ;;; Documentation:
605 ;;; *Variable controlling whether to delete dump files after a successful load.
606 ;;; If nil: always delete. If `ask', confirm to delete. If `check', confirm
607 ;;; to delete, except for files created with ess-dump-object-into-edit-buffer.
608 ;;; Anything else (for example `always'): always keep and never delete.
609 ;;; This variable only affects the behavior
610 ;;; of ess-load-file. Dump files are never deleted if an error occurs
611 ;;; during the load.
613 ;;; RH sez: I find the default `always' keep to be imperative. The previous
614 ;;; default was to throw away
615 ;;; files at the wrong time (I think it was something like, if you M-x
616 ;;; ess-load a file twice, while you are working on it, the file is
617 ;;; deleted). I believe source is real and the ESS object is temporary.
618 ;;; The previous default behavior is dangerous for people who believe this way.
619 ;;; It made sense only for people who believe the object is real
620 ;;; and the source file temporary.
621 (setq ess-keep-dump-files "always")
623 ;;; (3.4) ess-ask-for-ess-directory
624 ;;; If t, will ask for the directory to use. If nil, assumes the
625 ;;; default (usually, the users home directory...).
626 ;;now rather in ./ess-cust.el : (setq ess-ask-for-ess-directory t)
628 ;;; (3.5) ess-directory default (correlated with above)
629 ;;; The default location for running the subprocess is configurable.
630 ;;; By default, that is the default-directory (a lisp variable which
631 ;;; initially contains the directory from which the inferior ESS
632 ;;; statistical package/process is started).
633 ;;; For example, the following function (added to the pre-run-hook, by
634 ;;; the line following it) will set the default directory to be your
635 ;;; home directory:
637 ;;(defun ajr:ess-set-directory ()
638 ;; "Set ess-directory to home."
639 ;; (setq-default ess-directory (file-name-as-directory (getenv "HOME"))))
640 ;;(add-hook 'ess-pre-run-hook 'ajr:ess-set-directory)
642 ;;; If you replace the setq-default line with:
644 ;; (setq-default ess-directory (file-name-as-directory
645 ;; (concat (getenv "HOME") "/ess/")))
647 ;;; then it will always start up in the directory "ess" in your home
648 ;;; directory.
650 ;;; The default is to have ess to start up in the current buffer's
651 ;;; directory (the one in which you started the inferior ESS
652 ;;; statistical package/process). This is obtained
653 ;;; by setting ess-directory to nil, i.e.
654 ;; (setq-default ess-directory nil) ; this is the default.
657 ;;; 3.6 Example of formatting changes
659 ;;; Formatting and indentation patterns are defined in ess-cust.el, please
660 ;;; see ess-cust.el for exact definitions of these variable settings.
661 ;;; To change them, uncomment one or both of the following lines:
662 ;;; (eg, follow changes suggested by Terry Therneau)
663 ;;(setq ess-fancy-comments nil)
664 ;;(setq ess-default-style 'CLB)
666 ;;; 4.0 SAS configuration
668 ;;; Beginning with ESS 5.1.13, we have editing options in SAS-mode.
669 ;;; The default behavior is as it was in prior releases.
671 ;;; There are two sets of alternatives.
672 ;;; 1. Editing SAS-mode files.
673 ;;; 1a. Default: TAB is bound to sas-indent-line.
674 ;;; Current line is correctly indented as SAS code. Equivalent to
675 ;;;(setq ess-sas-edit-keys-toggle nil) ;; default TAB in sas-mode
676 ;;; 1b. Optional: TAB is bound to tab-to-tab-stop and inserts up to 4
677 ;;; columns at a time. C-TAB moves backwards and deletes characters
678 ;;; up to 4 columns at a time.
679 ;;; Uncomment the following line for the optional behavior.
680 ;;;(setq ess-sas-edit-keys-toggle t) ;; optional TAB and C-TAB in sas-mode
681 ;;; Use the function call (ess-sas-edit-keys-toggle)
682 ;;; to change the setting after the first SAS-mode buffer has been created.
683 ;;; 1c. You can also define C-TAB in all modes by Option 2b (below).
685 ;;; 2. Managing submitted SAS jobs with function keys.
686 ;;; 2a. Default: To define the function keys in ESS[SAS] mode only,
687 ;;; uncomment at most one of the following two lines.
688 ;;;(setq ess-sas-local-unix-keys t) ;; F2-F12 bound in ESS[SAS] mode
689 ;;;(setq ess-sas-local-pc-keys t) ;; F2-F12 bound in ESS[SAS] mode
691 ;;; 2b. Options: To define the function keys in all modes,
692 ;;; uncomment at most one of the following two lines.
693 ;;;(setq ess-sas-global-unix-keys t) ;; F2-F12 bound in all modes
694 ;;;(setq ess-sas-global-pc-keys t) ;; F2-F12 bound in all modes
696 ;;; 3. If it is more convenient to have "*Async Shell Command*"
697 ;;; in same-window-buffer-names, then uncomment the following line
698 ;;;(ess-same-window-async)
700 ;;;(defvar sas-program "sas" "*Name of program which runs sas.")
702 ;;;(defvar sas-indent-width 4 "*Amount to indent sas statements")
704 \f ; Local variables section
706 ;;; This file is automatically placed in Outline minor mode.
707 ;;; The file is structured as follows:
708 ;;; Chapters: ^L ;
709 ;;; Sections: ;;*;;
710 ;;; Subsections: ;;;*;;;
711 ;;; Components: defuns, defvars, defconsts
712 ;;; Random code beginning with a ;;;;* comment
713 ;;; Local variables:
714 ;;; mode: emacs-lisp
715 ;;; mode: outline-minor
716 ;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*"
717 ;;; End:
719 ;;; ess-site.el ends here