Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
2701 views
1
;;; ess-site.el --- user customization of ESS
2
3
;; Copyright (C) 1993 David M. Smith
4
;; Copyright (C) 1997--2012 A.J. Rossini, Richard M. Heiberger, Martin
5
;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
6
7
;; Author: David Smith <[email protected]>
8
;; Created: 12 Nov 1993
9
;; Maintainer: ESS-core <[email protected]>
10
;; Keywords: local
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
;; This file defines all the site-specific customizations for ESS. It should be
31
;; edited on a per-site basis. Read the comments (1.1 in Section 1 to see if
32
;; ess-site.el must be edited. The final directory location of this file must be
33
;; supplied in ess-lisp-directory. The editing of remaining sections is
34
;; optional. It should then be byte-compiled, and users who wish to use ESS
35
;; should add the line:
36
;;
37
;; (load "/PATH/TO/THIS/FILE/ess-site")
38
;;
39
;; (where /PATH/TO/THIS/FILE is the path to ess-site.elc: i.e. the value of
40
;; `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
;;
45
;; (require 'ess-site)
46
;;
47
;; will work.
48
;;
49
;; with XEmacs, this is simply:
50
;;
51
;; (add-path "/path/to/ess/lisp-directory")
52
;;
53
;; with Emacs (and in general):
54
;;
55
;; (setq load-path (cons "/path/to/ess/lisp-directory" load-path))
56
57
;;; Code:
58
59
;; provide here; otherwise we'll get infinite loops of (require ..):
60
(provide 'ess-site)
61
;;(require 'ess-sp6-d)
62
63
;;;; 1. Load path, autoloads, and major modes
64
;;;; ========================================
65
;;;
66
;;; (1.1) For most users the variable ess-lisp-directory will
67
;;; automatically be set correctly. If you are working with an old
68
;;; emacs, one in which file-truename is not defined, then you might
69
;;; need to change the value of ess-lisp-directory to the directory
70
;;; which is to contain the file ess-site.elc. This is probably the
71
;;; current directory, or the value of LISPDIR if it was set in the
72
;;; Makefile.
73
74
(eval-and-compile
75
76
;; Not important in XEmacs, if unpacking from ../xemacs/site-lisp/
77
;; directory.
78
79
;; WARNING: with Emacs 20.2 (and 20.3 in one case),
80
;; ======= MUST USE ONE OF THE NON-DEFAULT SETTINGS BELOW
81
82
;; NOTE again: MOST people should NOT change anything here !!!
83
;; ==== ==== ================
84
85
;; A nice default
86
(defvar ess-lisp-directory
87
(directory-file-name
88
(file-name-directory
89
(if (and (boundp 'load-file-name) load-file-name) ;; A nice default
90
(file-truename load-file-name)
91
(locate-library "ess-site") )))
92
"Directory containing ess-site.el(c) and other ESS lisp files.")
93
94
95
;; NON DEFAULTS:
96
;;(defvar ess-lisp-directory
97
;;(directory-file-name "/usr/local/lib/xemacs/site-lisp/ess-/lisp"))
98
;; >> or replace "ess-" above by "ESS" which would be a symbolic link..
99
;; >> This way, your .emacs (or default.el or site-start.el)
100
;; >> won't have to change with each version of ESS
101
102
;; example of "local" or personal use
103
;;(defvar ess-lisp-directory
104
;;(directory-file-name "/stat2/faculty/rossini/ESS/lisp"))
105
106
;;)
107
108
;; emacs 19.28 and 19.29 don't have functions we need.
109
(if (not (fboundp 'file-name-sans-extension))
110
;; take the definition from emacs-20.6/lisp/files.el:
111
(defun file-name-sans-extension (filename)
112
"Return FILENAME sans final \"extension\".
113
The extension, in a file name, is the part that follows the last `.'."
114
(save-match-data
115
(let ((file (file-name-sans-versions
116
(file-name-nondirectory filename)))
117
directory)
118
(if (string-match "\\.[^.]*\\'" file)
119
(if (setq directory (file-name-directory filename))
120
(expand-file-name (substring file 0 (match-beginning 0))
121
directory)
122
(substring file 0 (match-beginning 0)))
123
filename)))))
124
125
(add-to-list 'load-path (file-name-as-directory ess-lisp-directory))
126
127
;; Need these as early as here [also in ./ess-comp.el] :
128
(if (not (boundp 'ess-show-load-messages))
129
(defvar ess-show-load-messages nil
130
"If t, show many more \"loading ..\" messages."))
131
(if (not (fboundp 'ess-message))
132
(defun ess-message (format-string &rest args)
133
"Shortcut for \\[message] only if `ess-show-load-messages' is non-nil."
134
(if ess-show-load-messages (message format-string args)))
135
)); eval-*-compile
136
137
;; DEBUG: (setq ess-show-load-messages t); instead of nil above
138
139
(ess-message
140
(format "[ess-site:] ess-lisp-directory = '%s'" ess-lisp-directory))
141
142
;; load code to figure out what version/strain of Emacs we are running
143
;; must come *AFTER* load-path is set !
144
145
;;; The following require sets ess-local-custom-available to
146
;;; true if custom is provided at this point.
147
(require 'ess-compat)
148
;;; If it is not provided, but we think it will be available when necessary,
149
;;; then we can use the following line (uncommented) to make sure that
150
;;; it will be used. If you have to ask, then you don't need this.
151
;;(setq ess-local-custom-available t)
152
153
;; SJE Thu 13 May 2004
154
;; Maybe ess-etc-directory should not be defcustom, since its value
155
;; depends on ess-lisp-directory, and is needed by other modes that are
156
;; loaded before the custom code.
157
(defvar ess-etc-directory nil
158
"Location of the ESS etc/ directory.
159
The ESS etc directory stores various auxillary files that are useful
160
for ESS, such as icons.")
161
162
(defvar ess-etc-directory-list
163
'("../etc/ess/" "../etc/" "../../etc/ess/" "./etc/")
164
"List of directories, relative to `ess-lisp-directory', to search for etc.")
165
166
(while (and (listp ess-etc-directory-list) (consp ess-etc-directory-list))
167
(setq ess-etc-directory
168
(expand-file-name (concat ess-lisp-directory "/"
169
(car ess-etc-directory-list))))
170
(if (file-directory-p ess-etc-directory)
171
(setq ess-etc-directory-list nil)
172
(setq ess-etc-directory nil)
173
(setq ess-etc-directory-list (cdr ess-etc-directory-list))
174
(when (null ess-etc-directory-list)
175
(beep 0) (beep 0)
176
(message (concat
177
"ERROR:ess-site.el:ess-etc-directory\n"
178
"Relative to ess-lisp-directory, one of the following must exist:\n"
179
"../etc/ess, ../etc, ../../etc/ess or ./etc"))
180
(sit-for 4))))
181
182
;;-- no longer used thanks to the (unless ...) clause below --
183
;; (defvar ess-info-directory nil
184
;; "*Location of the ESS info/ directory.
185
;; The ESS info directory stores the ESS info files.")
186
187
188
;;(1.2) If ess.info is not found, then ess-lisp-directory/../doc/info is added
189
;; resurrecting Stephen's version with a bug-fix & xemacs compatibility
190
(if (fboundp 'locate-file) (progn
191
(unless (locate-file "ess.info"
192
(if (featurep 'xemacs)
193
Info-directory-list
194
Info-default-directory-list))
195
(add-to-list (if (featurep 'xemacs)
196
'Info-directory-list 'Info-default-directory-list)
197
(expand-file-name "../doc/info/" ess-lisp-directory)))))
198
199
200
;; ALWAYS:
201
(ess-message "[ess-site:] require 'ess *ITSELF* ...")
202
(require 'ess); -> loads ess-custom.el and more
203
(ess-message "[ess-site:] .. after requiring 'ess ...")
204
205
206
;;; (1.3) Files ending in .q and .S are considered to be S source files
207
;;; Files ending in .St are considered to be S transcript files
208
;;;
209
;;; NB: in standard Emacs, files ending in .s are assembler files. If you
210
;;; want to use assembler. If a user wants to
211
;;; restore the default modes for assembly file extensions, the
212
;;; following can go into ~/.emacs or ~/.xemacs/init.el
213
;;;
214
;;; (add-hook 'ess-mode-hook 'ess-restore-asm-extns)
215
;;; (add-hook 'inferior-ess-mode-hook 'ess-restore-asm-extns)
216
217
(autoload 'Rd-mode "ess-rd" "Major mode for editing R documentation." t)
218
219
; Here is a workaround for an Emacs bug related to indirect buffers and
220
; spurious lockfiles that rears its ugly head with .Rd files
221
; http://lists.gnu.org/archive/html/bug-gnu-emacs/2013-02/msg01368.html
222
; http://debbugs.gnu.org/cgi/bugreport.cgi?bug=14328
223
(if (featurep 'xemacs) nil
224
;; (add-hook 'Rd-mode-hook (lambda ()
225
;; (set (make-local-variable create-lockfiles) nil)))
226
227
(make-local-variable 'create-lockfiles)
228
229
(add-hook 'Rd-mode-hook (lambda () (setq create-lockfiles nil)))
230
)
231
232
;; This is thanks to Ed L Cashin <[email protected]>, 03 Mar 2004 :
233
(defun ess-restore-asm-extns ()
234
"Remove the S-Plus mode association for .s and .S files added by ESS.
235
Putting the following in ~/.emacs restores emacs' default association
236
between .s or .S files and assembly mode.
237
238
(add-hook 'ess-mode-hook 'ess-restore-asm-extns)
239
(add-hook 'inferior-ess-mode-hook 'ess-restore-asm-extns)"
240
(interactive)
241
(when (assoc "\\.[qsS]\\'" auto-mode-alist)
242
(setq auto-mode-alist
243
(remassoc "\\.[qsS]\\'" auto-mode-alist))
244
;; put .q extention back
245
;; (add-to-list is in xemacs and GNU emacs)
246
;; R-mode when in a R/ subdirectory, otherwise S-mode:
247
(add-to-list 'auto-mode-alist '("/R/.*\\.q\\'" . R-mode))
248
(add-to-list 'auto-mode-alist '("\\.q\\'" . S-mode))
249
))
250
251
;; Be careful when editing the following. MISTAKES WILL RESULT IN
252
;; *.sty BEING TREATED AS ESS[S], rather than LaTeX-mode!
253
254
(if (assoc "\\.[rR]\\'" auto-mode-alist) nil
255
(setq auto-mode-alist
256
(append
257
'(("\\.sp\\'" . S-mode) ;; re: Don MacQueen <[email protected]>
258
("/R/.*\\.q\\'" . R-mode) ;; R/*.q is R code (e.g., in package)
259
("\\.[qsS]\\'" . S-mode) ;; s,S [see ess-restore-asm-extns above!]
260
("\\.ssc\\'" . S-mode) ;; Splus (>= 4.x) script files.
261
("\\.SSC\\'" . S-mode) ;; ditto for windoze
262
("\\.[rR]\\'" . R-mode)
263
("\\.[rR]nw\\'" . Rnw-mode)
264
("\\.[sS]nw\\'" . Snw-mode); currently identical to Rnw-mode
265
("\\.[rR]profile\\'" . R-mode)
266
("NAMESPACE\\'" . R-mode)
267
("CITATION\\'" . R-mode)
268
("\\.omg\\'" . omegahat-mode)
269
("\\.hat\\'" . omegahat-mode) ;; Duncan's pref'd...
270
("\\.lsp\\'" . XLS-mode)
271
("\\.do\\'" . STA-mode)
272
("\\.ado\\'" . STA-mode)
273
("\\.[Ss][Aa][Ss]\\'" . SAS-mode)
274
;; Many .log/.lst files, not just SAS
275
;;("\\.log\\'" . SAS-log-mode)
276
;;("\\.[Ll][Ss][Tt]\\'" . SAS-listing-mode)
277
("\\.[Ss]t\\'" . S-transcript-mode)
278
("\\.Sout" . S-transcript-mode)
279
;;("\\.[Rr]t\\'" . R-transcript-mode)
280
("\\.[Rr]out" . R-transcript-mode)
281
("\\.Rd\\'" . Rd-mode)
282
("\\.[Bb][Uu][Gg]\\'" . ess-bugs-mode)
283
("\\.[Bb][Oo][Gg]\\'" . ess-bugs-mode)
284
("\\.[Bb][Mm][Dd]\\'" . ess-bugs-mode)
285
("\\.[Jj][Aa][Gg]\\'" . ess-jags-mode)
286
("\\.[Jj][Oo][Gg]\\'" . ess-jags-mode)
287
("\\.[Jj][Mm][Dd]\\'" . ess-jags-mode)
288
)
289
auto-mode-alist)))
290
291
;; Rscript and littler interpreters recognized. XEmacs entries can
292
;; be regexps, which complicates matters as "r" on its own matches
293
;; other interpeters like "perl".
294
(add-to-list 'interpreter-mode-alist '("Rscript" . r-mode))
295
(add-to-list 'interpreter-mode-alist
296
(cons (if (featurep 'xemacs) "r$" "r") 'r-mode))
297
298
299
;; (1.4) Customize the dialects for your setup.
300
301
;;; AS OF ESS 5.1.14, if you are using Emacs 20.x, x>3, or XEmacs
302
;;; 21.x, x>0, you can now use the "Customize" facility for
303
;;; customization.
304
305
;;;; Choices for *(), where * is from inferior-*-program....
306
;;; Most sites will not need to use these customized program-names. They are
307
;;; provided for cases where the program is not on the standard default path.
308
;;; If the program doesn't get located correctly by the default use of
309
;;; M-x S+3 (for example), then put the path name for your system into the
310
;;; the variable inferior-S+3-program-name. If for any reason you want the
311
;;; default use of M-x S to refer to a different program than S+3, then
312
;;; redefine inferior-S-program-name.
313
314
;;(setq-default inferior-S3-program-name "/disk05/s/S")
315
;;(setq-default inferior-S+3-program-name "Splus34")
316
;;(setq-default inferior-S4-program-name "/disk05/s4/S")
317
;;(setq-default inferior-S+4-program-name "Splus")
318
;;(setq-default inferior-S+5-program-name "Splus5")
319
;;(setq-default inferior-S+-program-name "Splus7") ; unix systems ; or
320
;;(setq-default inferior-S+-program-name "Splus") ; unix systems
321
;;
322
;; If you wish to call other versions of R on a Unix system, ESS
323
;; should auto-detect other versions of R, according to matches to the
324
;; variable `ess-r-versions' as described in its docstring. Consider
325
;; changing that variable rather than changing inferior-R-program-name
326
;; if your version of R is not already auto-detected.
327
;;(setq-default inferior-R-program-name "R") ; unix systems
328
;;(setq-default inferior-R-program-name "Rterm") ; MS Windows, see below for path as well
329
;;(setq-default inferior-R-program-name "C:\\Program Files\\R\\R-2.5.0\\bin\\Rterm.exe")
330
;;(setq-default inferior-XLS-program-name "xlispstat")
331
;;(setq-default inferior-ARC-program-name "arc")
332
;;(setq-default inferior-VST-program-name "vista")
333
;;(setq-default inferior-SAS-program-name "sas")
334
;;(setq-default inferior-OMG-program-name "/home/rossini/src/anoncvs/Omegahat/org/omegahat/bin/omegahat")
335
(setq-default inferior-OMG-program-name "omegahat")
336
337
;;; The line below is the ESS default and sends the commands window
338
;;; to emacs, giving the user the opportunity to
339
;;; (1) edit the output into a clean ess-transcript file before printing, or
340
;;; (2) print a region of the file.
341
;;(setq-default inferior-S+4-print-command "S_PRINT_COMMAND=emacsclientw.exe")
342
343
;;; The editor and pager output from S+4 and Sqpe+4 are sent by
344
;;; StatSci default to notepad, effectively using the definition:
345
;;(setq-default inferior-S+4-editor-pager-command
346
;; "options(editor='notepad', pager='notepad')")
347
;;;
348
;;; ESS sends the output from both commands to an emacs buffer using
349
;;; the definition:
350
;;(setq-default inferior-S+4-editor-pager-command
351
;; "options(editor='emacsclient.exe', pager='emacsclientw.exe')")
352
353
;;; These commands are for running the PC version of Sqpe of S+4 and
354
;;; S+6 in an emacs buffer, using the same technology as ESS uses for
355
;;; Unix S-Plus. Interactive graphics with javagraph are available
356
;;; in this mode beginning with S-Plus 6.1.
357
;;; See ess-sp4-d.el or ess-sp6w-d.el
358
359
;;; -----> configuration now via custom, see ./ess-custom.el and look for
360
;;; inferior-Sqpe+... e.g. inferior-Sqpe+6-program-name
361
362
;;; These ddeclient values will be buffer-local on MS-Windows 9x/NT
363
(setq-default inferior-ess-ddeclient "Initial")
364
(setq-default inferior-ess-client-name "Initial")
365
(setq-default inferior-ess-client-command "Initial")
366
367
;;; S-Plus 6 for Windows startup time depends on the amount of RAM and
368
;;; the processor speed. ESS needs to build a delay into the M-x S+6
369
;;; sequence to allow time for S-Plus 6 to open the Commands window.
370
;;; We then send several lines to the Commands window before returning
371
;;; control to the user. On a 300 MHz machine with 96MB of RAM the
372
;;; delay is 60 seconds. On a ???? MHz machine with 523MB the delay is
373
;;; 10 seconds. The user may need to adjust this number.
374
(defvar ess-S+6-startup-delay 15 ;; <- 2005-01-03; MM
375
"*Number of seconds to wait for the Commands window to appear before
376
sending `inferior-ess-language-start' to S-Plus.")
377
378
379
;;; see essd-els.el
380
381
;;(setq-default inferior-S-elsewhere-program-name "sh")
382
;;(setq-default inferior-S-elsewhere-program-name "ssh")
383
;;; You might consider using ssh, if you can! (and if you really do
384
;;; this, use ssh-agent, etc, for securing your sessions).
385
386
387
;;;; Choice for S().
388
;;(setq-default inferior-S-program-name inferior-S+3-program-name)
389
390
391
392
393
394
;; (1.5) Require the needed dialects for your setup.
395
396
(ess-message "[ess-site:] Before requiring dialect 'ess-*-d ....")
397
(ess-message "[ess-site:] require 'ess-r-d ...")
398
(require 'ess-r-d) ;; R
399
(require 'ess-julia)
400
;; (ess-message "[ess-site:] require 'ess-s4-d ...")
401
;; (require 'ess-s4-d) ; has become VERY RARE ..
402
403
;;(ess-message "[ess-site:] require 'ess-s3-d ...")
404
;;(require 'ess-s3-d) ; THIS IS RARE. You probably do not have this.
405
406
;; "sp" refers to S-PLUS (MathSoft/StatSci/Insightful/TIBCO):
407
(ess-message "[ess-site:] require 'ess-sp3-d ...")
408
(require 'ess-sp3-d)
409
410
(if ess-microsoft-p
411
(progn
412
;; (ess-message "[ess-site:] require 'ess-sp4-d ...")
413
;; (require 'ess-sp4-d)
414
(ess-message "[ess-site:] require 'ess-sp6w-d ...")
415
(require 'ess-sp6w-d))
416
;; else: decent OS
417
;; (ess-message "[ess-site:] require 'ess-sp5-d ...")
418
;; (require 'ess-sp5-d)
419
(ess-message "[ess-site:] require 'ess-sp6-d ...")
420
(require 'ess-sp6-d))
421
422
(ess-message "[ess-site:] require 'ess-sta-d ...")
423
(require 'ess-sta-d) ;; for Stata.
424
;; (ess-message "[ess-site:] require 'ess-xls-d ...")
425
;; (require 'ess-xls-d) ;; XLispStat
426
;; (ess-message "[ess-site:] require 'ess-vst-d ...")
427
;; (require 'ess-vst-d) ;; ViSta
428
;; (ess-message "[ess-site:] require 'ess-arc-d ...")
429
;; (require 'ess-arc-d) ;; Arc
430
(ess-message "[ess-site:] require 'ess-sas-d ...")
431
(require 'ess-sas-d)
432
(ess-message "[ess-site:] require 'essd-els ...")
433
(require 'essd-els) ;; S-elsewhere, on another machine by telnet
434
;; (ess-message "[ess-site:] require 'ess-omg-d ...")
435
;; (require 'ess-omg-d) ;; for omegahat
436
(ess-message "[ess-site:] require 'ess-bugs-l ...")
437
(require 'ess-bugs-l) ;; for batch BUGS
438
439
(ess-write-to-dribble-buffer
440
(format "[ess-site.el]: ess-customize-alist=%s \n"
441
ess-customize-alist))
442
443
;;; (1.7) Literate Data Analysis
444
(require 'ess-noweb)
445
(require 'ess-swv); for Sweave
446
447
(ess-write-to-dribble-buffer
448
(format "[ess-site.el _2_]: ess-customize-alist=%s \n"
449
ess-customize-alist))
450
451
;; (1.8) Speedbar and mouse
452
453
(ess-message "[ess-site:] require 'ess-menu ...")
454
(require 'ess-menu)
455
(require 'ess-mouse)
456
457
;; (1.9) Toolbar support
458
459
;; To remove toolbar support under ESS, add "(setq ess-use-toolbar nil)"
460
;; to your ~/.emacs or ~/.xemacs/init.el before (require 'ess-site)
461
(ess-message "[ess-site:] require 'ess-toolbar ...")
462
(require 'ess-toolbar)
463
464
;;; 2. Site Specific setup
465
;;;; ===============================================
466
467
;;; Set this to the name of the program you use to run S or S-PLUS. It
468
;;; can be an absolute pathname, if you wish.
469
;;(setq inferior-ess-program "Splus")
470
;;(setq inferior-ess-program (concat (getenv "SHOME") "/Splus"))
471
472
473
;;; 2.1 Backwards compatibility (roll your own!)
474
;;; What you want S and R to call...
475
476
(autoload 'ess-transcript-mode "ess-trns"
477
"Major mode for editing S transcript files." t)
478
(autoload 'ess-transcript-clean-region "ess-trns" no-doc t)
479
480
(autoload 'ess-rdired "ess-rdired"
481
"View *R* objects in a dired-like buffer." t)
482
483
484
;;; On a PC, the default is S+.
485
;; Elsewhere (unix and linux) the default is S+
486
(cond (ess-microsoft-p
487
;; MS-Windows-------------------------------------------------
488
489
;; (fset 'S
490
;; (if (equal (file-name-nondirectory shell-file-name) "cmdproxy.exe")
491
;; 'S+-msdos
492
;; 'S+))
493
(defun S-by-icon (&rest x)
494
(interactive)
495
(message "Please start S+ from the icon.
496
Then you can connect emacs to it with `M-x S-existing'.")
497
)
498
(fset 'S 'S-by-icon)
499
(fset 'S-existing
500
(if (equal (file-name-nondirectory shell-file-name) "cmdproxy.exe")
501
'S+-msdos-existing
502
'S+-existing))
503
(fset 'Sqpe 'Sqpe+)
504
(fset 's-mode 'S+-mode)
505
(fset 's-transcript-mode 'S+-transcript-mode))
506
507
(t ;;((eq system-type 'gnu/linux)
508
;; Linux etc (including Mac OSX !?) --------------------------
509
(fset 'S 'S+)
510
(fset 's-mode 'S+-mode)
511
(fset 's-transcript-mode 'S+-transcript-mode)))
512
513
514
;;;;* Alias S-mode to s-mode
515
;;; Emacs will set the mode for a file based on the file's header.
516
;;; The mode name is indicated by putting it between -*- on the top line.
517
;;; (Other commands can go here too, see an Emacs manual.)
518
;;; For a file you also load, you will want a leading # (comment to S)
519
;;; Emacs will downcase the name of the mode, e.g., S, so we must provide
520
;;; s-mode in lower case too. That is, "#-*- S-*-" invokes s-mode and
521
;;; not S-mode.
522
(fset 'S-transcript-mode 's-transcript-mode)
523
(fset 'S-mode 's-mode)
524
525
;;; Create functions for calling different (older or newer than default)
526
;;; versions of R and S(qpe).
527
(defvar ess-versions-created nil
528
"List of strings of all S- and R-versions found on the system.")
529
530
;; is currently used (updated) by ess-find-newest-R
531
(defvar ess-r-versions-created nil
532
"List of strings of all R-versions found on the system.")
533
;; FIXME: should then update ess-versions-created as well (easy),
534
;; ----- *and* update the "Start Process" menu (below)
535
;; -> To this: wrap the following in functions that can be re-called
536
537
(defun ess-r-s-versions-creation ()
538
"(Re)Create ESS R-<..> commands FILENAME sans final \"extension\".
539
The extension, in a file name, is the part that follows the last `.'."
540
541
(interactive)
542
(ess-message "[ess-site:] before creating ess-versions-* ...")
543
;; Create ess-versions-created,
544
;; ess-r-versions-created,
545
;; and on Windows, ess-rterm-version-paths -----------------------------------------
546
(let ((R-newest-list '("R-newest"))
547
(ess-s-versions-created (if ess-microsoft-p
548
(nconc
549
(ess-sqpe-versions-create ess-SHOME-versions) ;; 32-bit
550
(ess-sqpe-versions-create ess-SHOME-versions-64 "-64-bit")) ;; 64-bit
551
(ess-s-versions-create)))) ;; use ess-s-versions
552
(if ess-microsoft-p
553
(setq ess-rterm-version-paths ;; (ess-find-rterm))
554
(ess-flatten-list
555
(ess-uniq-list
556
(if (not ess-directory-containing-R)
557
(if (getenv "ProgramW6432")
558
(let ((P-1 (getenv "ProgramFiles(x86)"))
559
(P-2 (getenv "ProgramW6432")))
560
(nconc
561
;; always 32 on 64 bit OS, nil on 32 bit OS
562
(ess-find-rterm (concat P-1 "/R/") "bin/Rterm.exe")
563
(ess-find-rterm (concat P-1 "/R/") "bin/i386/Rterm.exe")
564
;; keep this both for symmetry and because it can happen:
565
(ess-find-rterm (concat P-1 "/R/") "bin/x64/Rterm.exe")
566
567
;; always 64 on 64 bit OS, nil on 32 bit OS
568
(ess-find-rterm (concat P-2 "/R/") "bin/Rterm.exe")
569
(ess-find-rterm (concat P-2 "/R/") "bin/i386/Rterm.exe")
570
(ess-find-rterm (concat P-2 "/R/") "bin/x64/Rterm.exe")
571
))
572
(let ((PF (getenv "ProgramFiles")))
573
(nconc
574
;; always 32 on 32 bit OS, depends on 32 or 64 process on 64 bit OS
575
(ess-find-rterm (concat PF "/R/") "bin/Rterm.exe")
576
(ess-find-rterm (concat PF "/R/") "bin/i386/Rterm.exe")
577
(ess-find-rterm (concat PF "/R/") "bin/x64/Rterm.exe")
578
))
579
)
580
(let ((PF ess-directory-containing-R))
581
(nconc
582
(ess-find-rterm (concat PF "/R/") "bin/Rterm.exe")
583
(ess-find-rterm (concat PF "/R/") "bin/i386/Rterm.exe")
584
(ess-find-rterm (concat PF "/R/") "bin/x64/Rterm.exe")
585
))
586
)))))
587
(ess-message "[ess-site:] (let ... before (ess-r-versions-create) ...")
588
589
(setq ess-r-versions-created ;; for Unix *and* Windows, using either
590
(ess-r-versions-create));; ess-r-versions or ess-rterm-version-paths (above!)
591
592
;; Add the new defuns, if any, to the menu.
593
;; Check that each variable exists, before adding.
594
;; e.g. ess-sqpe-versions-created will not be created on Unix.
595
(setq ess-versions-created
596
(ess-flatten-list
597
(mapcar (lambda(x) (if (boundp x) (symbol-value x) nil))
598
'(R-newest-list
599
ess-r-versions-created
600
ess-s-versions-created)))))
601
)
602
603
(ess-message "[ess-site:] before (ess-r-s-versions-creation) ...")
604
(ess-r-s-versions-creation)
605
606
(when ess-versions-created
607
;; new-menu will be a list of 3-vectors, of the form:
608
;; ["R-1.8.1" R-1.8.1 t]
609
(let ((new-menu (mapcar (lambda(x) (vector x (intern x) t))
610
ess-versions-created)))
611
(easy-menu-add-item ess-mode-menu '("Start Process")
612
(cons "Other" new-menu))))
613
614
(ess-message "[ess-site:] after ess-versions-created ...")
615
616
;; Check to see that inferior-R-program-name points to a working version
617
;; of R; if not, try to find the newest version:
618
(ess-check-R-program-name) ;; -> (ess-find-newest-R) if needed, in ./ess-r-d.el
619
(ess-message "[ess-site:] after ess-check-R-prog... ...")
620
621
;;; 3. Customization (and examples) for your site
622
;;;; ===============================================
623
624
625
;;; (3.01) SOME PEOPLE (who will remain nameless) worry that novices
626
;;; won't like fancy buffer names for their first (and only :-)
627
;;; process. To number all processes:
628
;;(setq ess-plain-first-buffername nil)
629
630
;;; (3.02) Some people have requested using the program name as part
631
;;; of the buffer. Turned on for R.
632
;;(setq ess-use-inferior-program-name-in-buffer-name t)
633
634
635
;;; (3.1) Font-lock
636
;; The following two expressions automatically enable font-lock-mode
637
;; for ess-mode and inferior-ess-mode buffers.
638
639
;; no longer requiring (window-system) here:
640
(when ess-font-lock-mode
641
(add-hook 'ess-mode-hook 'turn-on-font-lock t)
642
(add-hook 'ess-transcript-mode-hook 'turn-on-font-lock t)
643
(add-hook 'Rd-mode-hook 'turn-on-font-lock t)
644
(add-hook 'inferior-ess-mode-hook 'turn-on-font-lock t))
645
646
647
;;; (3.2) Framepop. Windows produced by ess-execute-objects etc. are
648
;;; often unnecessarily large. The framepop package makes such
649
;;; windows appear in a separate, shrink-wrapped frame. This will
650
;;; also affect other "temporary" windows such as those produced by
651
;;; C-h k, etc. To enable:
652
;;;
653
;;; Works only with Emacs at this time.
654
;; (cond (window-system
655
;; (require 'framepop)))
656
657
;;; (3.3) ess-keep-dump-files.
658
;;; Documentation:
659
;;; *Variable controlling whether to delete dump files after a successful load.
660
;;; If nil: always delete. If `ask', confirm to delete. If `check', confirm
661
;;; to delete, except for files created with ess-dump-object-into-edit-buffer.
662
;;; Anything else (for example `always'): always keep and never delete.
663
;;; This variable only affects the behavior
664
;;; of ess-load-file. Dump files are never deleted if an error occurs
665
;;; during the load.
666
;;;
667
;;; RH sez: I find the default `always' keep to be imperative. The previous
668
;;; default was to throw away
669
;;; files at the wrong time (I think it was something like, if you M-x
670
;;; ess-load a file twice, while you are working on it, the file is
671
;;; deleted). I believe source is real and the ESS object is temporary.
672
;;; The previous default behavior is dangerous for people who believe this way.
673
;;; It made sense only for people who believe the object is real
674
;;; and the source file temporary.
675
(setq ess-keep-dump-files "always")
676
677
;;; (3.4) ess-ask-for-ess-directory
678
;;; If t, will ask for the directory to use. If nil, assumes the
679
;;; default (usually, the users home directory...).
680
;;now rather in ./ess-custom.el : (setq ess-ask-for-ess-directory t)
681
682
;;; (3.5) ess-directory default (correlated with above)
683
;;; The default location for running the subprocess is configurable.
684
;;; By default, that is the default-directory (a lisp variable which
685
;;; initially contains the directory from which the inferior ESS
686
;;; statistical package/process is started).
687
;;; For example, the following function (added to the pre-run-hook, by
688
;;; the line following it) will set the default directory to be your
689
;;; home directory:
690
;;;
691
;;(defun ajr:ess-set-directory ()
692
;; "Set ess-directory to home."
693
;; (setq-default ess-directory (file-name-as-directory (getenv "HOME"))))
694
;;(add-hook 'ess-pre-run-hook 'ajr:ess-set-directory)
695
;;;
696
;;; If you replace the setq-default line with:
697
;;;
698
;; (setq-default ess-directory (file-name-as-directory
699
;; (concat (getenv "HOME") "/ess/")))
700
;;;
701
;;; then it will always start up in the directory "ess" in your home
702
;;; directory.
703
;;;
704
;;; The default is to have ess to start up in the current buffer's
705
;;; directory (the one in which you started the inferior ESS
706
;;; statistical package/process). This is obtained
707
;;; by setting ess-directory to nil, i.e.
708
;; (setq-default ess-directory nil) ; this is the default.
709
710
(when ess-microsoft-p
711
(add-hook 'ess-post-run-hook
712
(lambda()
713
(when (string= ess-dialect "R")
714
(ess-eval-linewise "options(chmhelp=FALSE, help_type=\"text\")"
715
nil nil nil 'wait)))))
716
717
718
;;; 3.6 Example of formatting changes
719
720
;;; Formatting and indentation patterns are defined in ess-custom.el, please
721
;;; see ess-custom.el for exact definitions of these variable settings.
722
;;; To change them (eg, follow changes suggested by Terry Therneau),
723
;;; you need one or both of the following lines:
724
;;;
725
;;(setq ess-fancy-comments nil)
726
;;(setq ess-default-style 'CLB)
727
728
;;; 4.0 SAS configuration
729
730
;;; Beginning with ESS 5.1.13, we have editing options in SAS-mode.
731
;;; The default behavior is as it was in prior releases.
732
;;;
733
;;; There are two sets of alternatives.
734
;;; 1. Editing SAS-mode files.
735
;;; 1a. Default: TAB is bound to sas-indent-line.
736
;;; Current line is correctly indented as SAS code. Equivalent to
737
;;;(setq ess-sas-edit-keys-toggle nil) ;; default TAB in sas-mode
738
;;; 1b. Optional: TAB is bound to tab-to-tab-stop and inserts up to 4
739
;;; columns at a time. C-TAB moves backwards and deletes characters
740
;;; up to 4 columns at a time.
741
;;; The following line is for the optional behavior.
742
;;;(setq ess-sas-edit-keys-toggle t) ;; optional TAB and C-TAB in sas-mode
743
;;; Use the function call (ess-sas-edit-keys-toggle)
744
;;; to change the setting after the first SAS-mode buffer has been created.
745
;;; 1c. You can also define C-TAB in all modes by Option 2b (below).
746
;;;
747
;;; 2. Managing submitted SAS jobs with function keys.
748
;;; 2a. Default: To define the function keys in ESS[SAS] mode only,
749
;;; you will need, at most, one of the following two lines.
750
;;;(setq ess-sas-local-unix-keys t) ;; F2-F12 bound in ESS[SAS] mode
751
;;;(setq ess-sas-local-pc-keys t) ;; F2-F12 bound in ESS[SAS] mode
752
;;;
753
;;; 2b. Options: To define the function keys in all modes,
754
;;; you will need, at most, one of the following two lines.
755
;;;(setq ess-sas-global-unix-keys t) ;; F2-F12 bound in all modes
756
;;;(setq ess-sas-global-pc-keys t) ;; F2-F12 bound in all modes
757
;;;
758
;;; 3. If it is more convenient to have "*Async Shell Command*"
759
;;; in same-window-buffer-names, then:
760
;;;(ess-same-window-async)
761
;;;
762
;;;(defvar sas-program "sas" "*Name of program which runs sas.")
763
;;;
764
;;;(defvar sas-indent-width 4 "*Amount to indent sas statements")
765
766
(ess-message "[ido:]")
767
(if (featurep 'emacs)
768
(require 'ido nil t))
769
770
; Local variables section
771
(ess-message "[ess-site:] *very* end ...")
772
773
;;; This file is automatically placed in Outline minor mode.
774
;;; The file is structured as follows:
775
;;; Chapters: ^L ;
776
;;; Sections: ;;*;;
777
;;; Subsections: ;;;*;;;
778
;;; Components: defuns, defvars, defconsts
779
;;; Random code beginning with a ;;;;* comment
780
;;; Local variables:
781
;;; mode: emacs-lisp
782
;;; mode: outline-minor
783
;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*"
784
;;; End:
785
786
;;; ess-site.el ends here
787
788