Initial Commit
[packages] / xemacs-packages / ess / lisp / ess-cust.el
1 ;;; ess-cust.el --- Customize variables for ESS
2
3 ;; Copyright (C) 1997--2005 A.J. Rossini, Rich M. Heiberger, Martin
4 ;;      Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
5
6 ;; Original Author: A.J. Rossini <rossini@u.washington.edu>
7 ;; Created: 05 June 2000
8 ;; Maintainers: ESS-core <ESS-core@stat.math.ethz.ch>
9
10 ;; Keywords: editing and process modes.
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 ;; 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.
27 ;;
28 ;; In short: you may use this code any way you like, as long as you
29 ;; don't charge more than a distribution fee for it, do distribute the
30 ;; source with any binaries, remove this notice, or hold anyone liable
31 ;; for its results.
32
33 ;;; Code:
34
35 ;; Stolen from w3-cus.el (via Per Abrahamsen's advice on the widgets page).
36 ;; This code provides compatibility with non-customized Emacsen.
37 (eval-and-compile
38   (condition-case ()
39       (require 'custom)
40     (error nil))
41   (if (and (featurep 'custom) (fboundp 'custom-declare-variable))
42       nil ;; We've got what we needed
43     ;; We have the old custom-library, hack around it!
44     (defmacro defgroup (&rest args)
45       nil)
46     (defmacro defface (var values doc &rest args)
47        (` (make-face (, var))))
48     (defmacro defcustom (var value doc &rest args)
49       (` (defvar (, var) (, value) (, doc))))))
50
51 ;; Customization Groups
52
53 (defgroup ess nil
54   "ESS: Emacs Speaks Statistics."
55   :group 'local)
56
57 (defgroup ess-edit nil
58   "ESS: editing behavior, including coments/indentation."
59   :group 'ess
60   :prefix "ess-")
61
62 (defgroup ess-proc nil
63   "ESS: process control."
64   :group 'ess
65   :prefix "ess-")
66
67 (defgroup ess-command nil
68   "ESS: Commands for various things."
69   :group 'ess
70   :prefix "ess-")
71
72 (defgroup ess-help nil
73   "ESS: help functions."
74   :group 'ess
75   :prefix "ess-")
76
77 (defgroup ess-hooks nil
78   "ESS: hooks for customization."
79   :group 'ess
80   :prefix "ess-")
81
82 (defgroup ess-S nil
83   "ESS: S Languages."
84   :group 'ess
85   :prefix "ess-")
86
87 (defgroup ess-origS nil
88   "ESS: Original S Dialect from Bell Labs/AT&T."
89   :group 'ess-S
90   :prefix "ess-")
91
92 (defgroup ess-SPLUS nil
93   "ESS: S-PLUS Dialect of S."
94   :group 'ess-S
95   :prefix "ess-")
96
97 (defgroup ess-R nil
98   "ESS: R Dialect of S."
99   :group 'ess-S
100   :prefix "ess-")
101
102 (defgroup ess-sas nil
103   "ESS: SAS."
104   :group 'ess
105   :prefix "ess-")
106
107 (defgroup ess-Stata nil
108   "ESS: Stata."
109   :group 'ess
110   :prefix "ess-")
111
112 (defgroup ess-XLS nil
113   "ESS: XLispStat."
114   :group 'ess
115   :prefix "ess-")
116
117 (defgroup ess-OMG nil
118   "ESS: Omegahat."
119   :group 'ess
120   :prefix "ess-")
121
122 (defgroup ess-mouse nil ;; FIXME: this is not used yet <--> ./ess-mous.el
123   "ESS: Mouse."
124   :group 'ess
125   :prefix "ess-")
126
127 ;; Variables (not user-changeable)
128
129 (defvar ess-version "5.2.7"
130   "Version of ESS currently loaded.")
131
132 (defvar no-doc
133   "This function is part of ESS, but has not yet been loaded.
134 Full documentation will be available after autoloading the function."
135   "Documentation for autoload functions.")
136
137
138 \f ; User changeable variables
139
140 ;;; Common user changeable variable are described and documented in
141 ;;; ess-site.el.  Please check there first!
142 ;;;=====================================================
143 ;;; In general: Variables with document strings starting with a * are
144 ;;; the ones you can generally change safely, and may have to upon
145 ;;; occasion.
146
147 ;;*;; Options and Initialization
148
149 ;; Menus and pulldowns.
150
151 (defcustom ess-funcmenu-use-p (fboundp 'func-menu)
152   "If t, funcmenu is present."
153   :group 'ess
154   :type 'boolean)
155
156 (defcustom ess-speedbar-use-p (fboundp 'speedbar)
157   "If t, speedbar is present."
158   :group 'ess
159   :type  'boolean)
160
161 (defcustom ess-imenu-use-p (fboundp 'imenu)
162   "Use imenu facility if it exists.
163 This value can be overridden by mode-specific variables, such
164 as `ess-imenu-use-S'."
165   :group 'ess
166   :type  'boolean)
167
168 ;; 
169
170 (defcustom ess-ask-for-ess-directory t
171   "*If non-nil, the process directory will be requested each time S is run."
172   :group 'ess
173   :type 'boolean)
174
175 (defcustom ess-ask-about-transfile nil
176   "*If non-nil, asks about a transcript file before running ESS."
177   :group 'ess
178   :type 'boolean)
179
180 (defcustom ess-language nil
181   "*Prefix of all ESS processes, and defines the dialect in use.
182 Currently acceptable values are `S',  `XLS', `SAS'.
183 Can be changed, e.g., to `R'.  Use `setq-default' if setting it in
184 .emacs (also see ess-site.el)."
185   :group 'ess
186   :type '(choice (const :tag "Initial" :value "Initial")
187                  (const :tag "S"       :value "S")
188                  (const :tag "XLS"     :value "XLS")
189                  (const :tag "SAS"     :value "SAS")
190                  (const :tag "R"       :value "R")))
191
192 (make-variable-buffer-local 'ess-language)
193 (setq-default ess-language "Initial")
194
195 (defvar ess-dialect nil
196   "String version of the dialect being run for the inferior process.
197 This, plus `ess-language', should be able to determine the exact
198 version of the statistical package being executed in the particular
199 buffer.
200
201 Current values could include:
202 for `ess-dialect' = S3, S4, Sp3, Sp4, Sp5, Sp6, R, XLS, SAS, STA
203
204 Used to adjust for changes in versions of the program.")
205
206 (make-variable-buffer-local 'ess-dialect)
207 ;;(setq-default ess-dialect "Initial-dialect")
208 (setq-default ess-dialect nil)
209 ;;; SJE -- why use "Initial-dialect"?  If we use nil, it matches "None"
210 ;;; in the custom choice.
211
212 ;; (defcustom ess-etc-directory
213 ;;   (expand-file-name (concat ess-lisp-directory "/../etc/"))
214 ;;   "*Location of the ESS etc/ directory.
215 ;; The ESS etc directory stores various auxillary files that are useful
216 ;; for ESS, such as icons."
217 ;;   :group 'ess
218 ;;   :type 'directory)
219
220 (defcustom ess-directory-function nil
221   "*Function to return the directory that ESS is run from.
222 If nil or if the function returns nil then you get `ess-directory'."
223   :group 'ess
224   :type '(choice (const nil) function))
225
226 (defcustom ess-setup-directory-function nil
227   "*Function to setup the directory that ESS is run from.
228 This function can be called to set environment variables or to create
229 a workspace."
230   :group 'ess
231   :type '(choice (const nil) function))
232
233 (defcustom ess-directory nil
234   "*The directory ESS is run from.  It must end in a slash.
235 Provided as a default if `ess-ask-for-ess-directory' is non-nil.
236 A nil value means use the current buffer's default directory.
237 Buffer-local: in process buffers, this contains the directory ESS was
238 run from."
239   :group 'ess
240   :type '(choice (const nil) directory))
241
242 (defcustom ess-history-directory nil
243   "*Directory to pick up `ess-history-file' from.
244 If this is nil, the history file is relative to `ess-directory'."
245   :group 'ess
246   :type '(choice (const nil) directory))
247
248 (defcustom ess-history-file nil
249   "*File to pick up history from.
250 If this is a relative file name, it is relative to `ess-history-directory'."
251   :group 'ess
252   :type '(choice (const nil) file))
253
254 (defcustom ess-plain-first-buffername t
255   "*No fancy process buffname for the first process of each type (novice mode)."
256   :group 'ess
257   :type 'boolean)
258
259 (defcustom ess-S-assign " <- "
260   "*String to be used for left assignment in all S dialects.
261  Used by \\[ess-smart-underscore]."
262   :group 'ess-S
263   :type 'string)
264
265 ;;*;; Variables concerning editing behaviour
266
267 (defcustom ess-filenames-map t
268   "Declares if the filenames in an attached directory are the same
269 as objects in that directory (when t). This is not true for DOS and
270 other OS's with limited filename lengths.  Even if this is set
271 incorrectly, the right things will probably still happen, however."
272   :group 'ess-edit
273   :type 'boolean)
274
275 ;;; SJE -- this is set in ess-site.el to be "always", so I changed
276 ;;; value t to be "always", so that ess-site.el does not need editing.
277 ;;; However, this is a bit messy, and would be nicer if ess-site.el
278 ;;; value was t rather than "always".
279 (defcustom ess-keep-dump-files 'ask
280   "*Variable controlling whether to delete dump files after a successful load.
281 If nil: always delete.  If `ask', confirm to delete.  If `check', confirm
282 to delete, except for files created with ess-dump-object-into-edit-buffer.
283 Anything else, never delete.  This variable only affects the behaviour
284 of `ess-load-file'.  Dump files are never deleted if an error occurs
285 during the load. "
286   :group 'ess-edit
287   :type '(choice (const :tag "Check" :value  'check)
288                  (const :tag "Ask"   :value  'ask)
289                  (const :tag "Always keep"   :value "always")
290                  (const :tag "Always delete"   :value nil)
291                  ))
292
293
294 (defcustom ess-delete-dump-files nil
295   "*If non-nil, delete dump files after they are created.  This
296 applies to dump files created with `ess-dump-object-into-edit-buffer',
297 only.
298
299 Boolean flag which determines what to do with the dump files
300 generated by \\[ess-dump-object-into-edit-buffer], as follows:
301
302         If nil: dump files are deleted after each use, and so appear
303 only transiently. The one exception to this is when a loading error
304 occurs, in which case the file is retained until the error is
305 corrected and the file re-loaded.
306
307         If non-nil: dump files are not deleted, and backups are kept
308 as usual.  This provides a simple method for keeping an archive of S
309 functions in text-file form.
310
311 Auto-save is always enabled in dump-file buffers to enable recovery
312 from crashes.
313
314 This is useful to prevent sources file being created for objects
315 you don't actually modify.  Once the buffer is modified and saved
316 however, the file is not subsequently unless `ess-keep-dump-files' is
317 nil, and the file is successfully loaded back into S."
318   :group 'ess-edit
319   :type 'boolean)
320
321 ;;; From ess-mode:
322
323 (defcustom ess-mode-silently-save t
324   "*If non-nil, automatically save ESS source buffers before loading."
325   :group 'ess-edit
326   :type 'boolean)
327
328 ;;*;; Variables controlling editing
329
330 ;;;*;;; Edit buffer processing
331 (defcustom ess-function-template " <- function( )\n{\n\n}\n"
332   "If non-nil, function template used when editing nonexistent objects.
333
334 The edit buffer will contain the object name in quotes, followed by
335 this string. Point will be placed after the first parenthesis or
336 bracket."
337   :group 'ess-edit
338   :type 'string)
339
340 ;;; By K.Shibayama 5.14.1992
341 ;;; Setting any of the following variables in your .emacs is equivalent
342 ;;; to modifying the DEFAULT style.
343
344 ;;;*;;; Indentation parameters
345
346 (defcustom ess-auto-newline nil
347   "*Non-nil means automatically newline before and after braces
348 inserted in S code."
349   :type 'boolean
350   :group 'ess-edit)
351
352 (defcustom ess-tab-always-indent t
353   "*Non-nil means TAB in S mode should always reindent the current line,
354 regardless of where in the line point is when the TAB command is used."
355   :type 'boolean
356   :group 'ess-edit)
357
358 (defcustom ess-indent-level 2
359   "*Indentation of S statements with respect to containing block."
360   :type 'integer
361   :group 'ess-edit)
362
363 (defcustom ess-brace-imaginary-offset 0
364   "*Imagined indentation of an open brace following a statement."
365   :type 'integer
366   :group 'ess-edit)
367
368 (defcustom ess-brace-offset 0
369   "*Extra indentation for open braces.
370 Compares with other text in same context."
371   :type 'integer
372   :group 'ess-edit)
373
374 (defcustom ess-continued-statement-offset 2
375   "*Extra indent for lines not starting new statements."
376   :type 'integer
377   :group 'ess-edit)
378
379 (defcustom ess-continued-brace-offset 0
380   "*Extra indent for substatements that start with open-braces.
381 This is in addition to ess-continued-statement-offset."
382   :type 'integer
383   :group 'ess-edit)
384
385 (defcustom ess-arg-function-offset 2
386   "*Extra indent for internal substatements of function `foo' that called
387 in `arg=foo(...)' form.
388 If not number, the statements are indented at open-parenthesis following foo."
389   :type 'integer
390   :group 'ess-edit)
391
392 ;;added rmh 2Nov97 at request of Terry Therneau
393 (defcustom ess-close-brace-offset 0
394   "*Extra indentation for closing braces."
395   :type 'integer
396   :group 'ess-edit)
397
398 ;;added rmh 2Nov97 at request of Terry Therneau
399 (defcustom ess-fancy-comments t
400   "*Non-nil means distiguish between #, ##, and ### for indentation."
401   :type 'boolean
402   :group 'ess-edit)
403
404
405 ;; PeterDalgaard, 1Apr97 :
406 ;;The default ess-else-offset should be 0, not 2 IMHO (try looking at
407 ;;the ls() function, for instance).  Was 2.
408 (defcustom ess-else-offset 0
409   "*Extra indent for `else' lines."
410   :type 'integer
411   :group 'ess-edit)
412
413 (defcustom ess-expression-offset 4
414   "*Extra indent for internal substatements of `expression' that specified
415 in `obj <- expression(...)' form.
416 If not number, the statements are indented at open-parenthesis following
417 `expression'."
418   :type 'integer
419   :group 'ess-edit)
420
421 ;;;*;;; Editing styles
422
423 ;;; **FIXME**  The following NEEDS to be customized.
424 ;; SJE: I disagree; this variable should not be customized; individual vars,
425 ;; such as ess-indent-level are already customizable.
426 (defvar ess-default-style-list
427   (list 'DEFAULT
428         (cons 'ess-indent-level ess-indent-level)
429         (cons 'ess-continued-statement-offset ess-continued-statement-offset)
430         (cons 'ess-brace-offset ess-brace-offset)
431         (cons 'ess-expression-offset ess-expression-offset)
432         (cons 'ess-else-offset ess-else-offset)
433         (cons 'ess-brace-imaginary-offset ess-brace-imaginary-offset)
434         (cons 'ess-continued-brace-offset ess-continued-brace-offset)
435         (cons 'ess-arg-function-offset ess-arg-function-offset)
436         (cons 'ess-close-brace-offset ess-close-brace-offset))
437   "Default style constructed from initial values of indentation variables.")
438
439 (defvar ess-style-alist
440   (cons ess-default-style-list
441         '((GNU (ess-indent-level . 2)
442                (ess-continued-statement-offset . 2)
443                (ess-brace-offset . 0)
444                (ess-arg-function-offset . 4)
445                (ess-expression-offset . 2)
446                (ess-else-offset . 0)
447                (ess-close-brace-offset . 0))
448           (BSD (ess-indent-level . 8)
449                (ess-continued-statement-offset . 8)
450                (ess-brace-offset . -8)
451                (ess-arg-function-offset . 0)
452                (ess-expression-offset . 8)
453                (ess-else-offset . 0)
454                (ess-close-brace-offset . 0))
455           (K&R (ess-indent-level . 5)
456                (ess-continued-statement-offset . 5)
457                (ess-brace-offset . -5)
458                (ess-arg-function-offset . 0)
459                (ess-expression-offset . 5)
460                (ess-else-offset . 0)
461                (ess-close-brace-offset . 0))
462           (C++ (ess-indent-level . 4)
463                (ess-continued-statement-offset . 4)
464                (ess-brace-offset . -4)
465                (ess-arg-function-offset . 0)
466                (ess-expression-offset . 4)
467                (ess-else-offset . 0)
468                (ess-close-brace-offset . 0))
469           ;; R added ajr 17Feb04 to match "common R" use
470           (RRR (ess-indent-level . 4)
471                (ess-continued-statement-offset . 4)
472                (ess-brace-offset . 0)
473                (ess-arg-function-offset . 4)
474                (ess-expression-offset . 4)
475                (ess-else-offset . 0)
476                (ess-close-brace-offset . 0))
477           ;; CLB added rmh 2Nov97 at request of Terry Therneau
478           (CLB (ess-indent-level . 2)
479                (ess-continued-statement-offset . 4)
480                (ess-brace-offset . 0)
481                (ess-arg-function-offset . 0)
482                (ess-expression-offset . 4)
483                (ess-else-offset . 0)
484                (ess-close-brace-offset . 2))))
485   "Predefined formatting styles for ESS code.
486 Values for all groups, except DEFAULT, are fixed.
487 To change the value of variables in the DEFAULT group, change
488 the corresponding variables, e.g. `ess-indent-level'.
489 The default style in use is controlled by `ess-default-style'.")
490
491 (defcustom ess-default-style 'DEFAULT
492   "*The default value of `ess-style'.
493 See the variable `ess-style-alist' for how these groups (DEFAULT,
494 GNU, BSD, ...) map onto different settings for variables."
495   :type '(choice (const DEFAULT)
496                  (const GNU)
497                  (const BSD)
498                  (const K&R)
499                  (const C++)
500                  (const :tag "Common R" :value 'RRR)
501                  (const CLB))
502   :group 'ess-edit)
503
504 (defvar ess-style ess-default-style
505   "*The buffer specific ESS indentation style.")
506
507 ;;*;; Variables controlling behaviour of dump files
508
509 (defcustom ess-source-directory "/tmp/"
510   "*Directory in which to place dump files.
511 This can be a string (an absolute directory name ending in a slash) or
512 a lambda expression of no arguments which will return a suitable string
513 value.  The lambda expression is evaluated with the process buffer as the
514 current buffer.
515
516 Possible value:
517
518  '(lambda () (file-name-as-directory
519               (expand-file-name (concat (car ess-search-list) \"/.Src\"))))
520
521 This always dumps to a sub-directory (\".Src\") of the current ess
522 working directory (i.e. first elt of search list)."
523   :group 'ess-edit
524   :type 'directory)
525
526
527 (defcustom ess-dump-filename-template-proto (concat (user-login-name) ".%s.S")
528   "*Prototype template for filenames of dumped objects.
529 The ending `S' is replaced by the current \\[ess-suffix], to give
530 \\[ess-dump-filename-template] when an inferior ESS process starts.
531
532 By default, gives filenames like `user.foofun.S', so as not to clash with
533 other users if you are using a shared directory. Other alternatives:
534 \"%s.S\" ; Don't bother uniquifying if using your own directory(ies)
535 \"dumpdir\"; Always dump to a specific filename. This makes it impossible
536          to edit more than one object at a time, though.
537 (make-temp-name \"scr.\") ; Another way to uniquify"
538   ;; MM: The last 3-4 lines above suck (I don't understand them) -- FIXME --
539
540   :group 'ess-edit
541   :type 'string)
542
543
544 ;;*;; Hooks
545
546 (defcustom ess-mode-hook nil
547   "*Hook for customizing ESS each time it is entered."
548   :group 'ess-hooks
549   :type 'hook)
550
551 (defcustom ess-mode-load-hook nil
552   "*Hook to call when ess.el is loaded."
553   :group 'ess-hooks
554   :type 'hook)
555
556 (defcustom ess-pre-run-hook nil
557   "*Hook to call before starting up ESS.
558 Good for setting up your directory."
559   :group 'ess-hooks
560   :type 'hook)
561
562 (defcustom ess-post-run-hook nil
563   "*Hook to call just after the ESS process starts up.
564 Good for evaluating ESS code."
565   :group 'ess-hooks
566   :type 'hook)
567
568 (defcustom inferior-ess-mode-hook nil
569   "*Hook for customizing inferior ESS mode.  Called after
570 `inferior-ess-mode' is entered and variables have been initialised."
571   :group 'ess-hooks
572   :type 'hook)
573
574 ;;; make it possible to save an inferior-ess-mode buffer without losing
575 ;;; the connection to the running ESS process.
576 (put 'inferior-ess-mode 'mode-class 'special)
577 ;; FIXME AJR: Should the above be there?  I don't think so!
578 ;;       MM : the functionality should be, right? Move statement to ./ess.el ?
579 ;;       AJR: No, we should move the statement to ./ess-inf.el
580
581 (defcustom ess-help-mode-hook nil
582   "Functions to call when entering `ess-help-mode'. "
583   :group 'ess-hooks
584   :type 'hook)
585
586 (defcustom ess-send-input-hook nil
587   "Hook called just before line input is sent to the process."
588   :group 'ess-hooks
589   :type 'hook)
590
591 (defcustom ess-transcript-mode-hook nil
592   "Hook for customizing ESS transcript mode."
593   :group 'ess-hooks
594   :type 'hook)
595
596 \f ; System variables
597
598 (defcustom ess-local-process-name nil
599   "The name of the ESS process associated with the current buffer."
600   :group 'ess
601   :type '(choice (const nil) string))
602
603 (make-variable-buffer-local 'ess-local-process-name)
604
605
606 (defcustom ess-kermit-command "gkermit -T"
607     "*Kermit command invoked by `ess-kermit-get' and `ess-kermit-send'."
608     :group 'ess
609     :type  'string
610 )
611
612 (defcustom ess-kermit-prefix "#"
613     "*String files must begin with to use kermit file transfer."
614     :group 'ess
615     :type  'string
616 )
617
618 (defcustom ess-kermit-remote-directory "."
619     "*Buffer local variable that designates remote directory of file."
620     :group 'ess
621     :type  'string
622 )
623
624 (make-variable-buffer-local 'ess-kermit-remote-directory)
625
626 ;;*;; Regular expressions
627
628 ;; FIXME : This is just for the S dialects;  need to define this for others,
629 ;; -----
630 ;;  {however  "XLS-mode" should just use standard lisp "beginning of function"}
631
632 (defcustom ess-R-function-pattern
633   (concat
634    "\\(\\(" ; EITHER
635    "\\s\"" ; quote
636    "\\(\\sw\\|\\s_\\)+\\(<-\\)?" ; symbol (replacement?)
637    "\\s\"" ; quote
638    "\\)\\|\\(" ; OR
639    "\\(^\\|[ ]\\)" ; beginning of name
640    "\\(\\sw\\|\\s_\\)+" ; symbol
641    "\\)\\)" ; END EITHER OR
642    "\\s-*\\(<-\\|=\\)" ; whitespace, assign, whitespace/nl
643    "\\(\\(\\s-\\|\n\\)*\\s<.*\\s>\\)*" ; whitespace, comment
644    "\\(\\s-\\|\n\\)*function\\s-*(" ; whitespace, function keyword, parenthesis
645    )
646   "The regular expression for matching the beginning of an R function."
647   :group 'ess
648   :type 'regexp)
649
650 (defcustom ess-S-function-pattern
651   ;; the same as "R" - but allowing "_" in assign
652   (concat
653    "\\(\\(" ; EITHER
654    "\\s\"" ; quote
655    "\\(\\sw\\|\\s_\\)+\\(<-\\)?" ; symbol (replacement?)
656    "\\s\"" ; quote
657    "\\)\\|\\(" ; OR
658 ;;   "\\<\\(\\sw\\|\\s_\\)+" ; symbol
659 ;;   "[0-9a-zA-Z0-9$.]+" ; symbol
660    "\\(^\\|[ ]\\)" ; beginning of name
661    "\\(\\sw\\|\\s_\\)+" ; symbol
662    "\\)\\)" ; END EITHER OR
663    "\\s-*\\(<-\\|_\\|=\\)" ; whitespace, assign, whitespace/nl
664    "\\(\\(\\s-\\|\n\\)*\\s<.*\\s>\\)*" ; whitespace, comment
665    "\\(\\s-\\|\n\\)*function\\s-*(" ; whitespace, function keyword, parenthesis
666    )
667   "The regular expression for matching the beginning of an S function."
668   :group 'ess
669   :type 'regexp)
670
671
672 ;; Fixme: the following is just for S dialects :
673 (defcustom ess-dumped-missing-re
674   "\\(<-\nDumped\n\\'\\)\\|\\(<-\\(\\s \\|\n\\)*\\'\\)"
675   "If a dumped object's buffer matches this re, then it is replaced
676 by `ess-function-template'."
677   :group 'ess
678   :type 'regexp)
679
680 (defcustom ess-dump-error-re
681   (if (string= ess-language "S") "\nDumped\n\\'"
682     "[Ee]rror")
683   "Regexp used to detect an error when loading a file."
684   :group 'ess
685   :type 'regexp)
686
687 ;;;; This is tested for S dialects (actually only for R) -- be careful with it!
688 (defvar ess-help-arg-regexp "\\(['\"]?\\)\\([^,=)'\"]*\\)\\1"
689   "Reg(ular) Ex(pression) of help(.) arguments.  MUST: 2nd \\(.\\) = arg.")
690
691 \f ; ess-inf: variables for inferior-ess.
692
693 ;;*;; System dependent variables
694
695 ;; If you need to change the *-program-name variables, do so in
696 ;; ess-site.el.  Do NOT make the changes here!!
697 ;; Keep a copy of your revised ess-site.el to use as a starting point
698 ;; for upgrades of ESS.
699
700 (defcustom inferior-ess-own-frame nil
701   "*Non-nil means that inferior ESS buffers should start in their own frame.
702 The parameters of this frame are stored in `inferior-ess-frame-alist'."
703   :group 'ess-proc
704   :type 'boolean)
705
706 (defcustom inferior-ess-frame-alist default-frame-alist
707   "*Alist of frame parameters used to create new frames for iESS buffers.
708 This defaults to `default-frame-alist' and is used only when
709 the variable `inferior-ess-own-frame' is non-nil."
710   :group 'ess-proc
711   :type 'alist)
712
713 (defcustom inferior-ess-same-window t
714   "*Non-nil indicates new inferior ESS process appears in current window.
715 Otherwise, the new inferior ESS buffer is shown in another window in the
716 current frame.  This variable is ignored if `inferior-ess-own-frame' is
717 non-nil."
718   :group 'ess-proc
719   :type 'boolean)
720
721 (defcustom inferior-R-program-name
722   (if ess-microsoft-p "Rterm"  "R")
723   "*Program name for invoking an inferior ESS with \\[R]."
724   :group 'ess-R
725   :type 'string)
726
727 (defcustom inferior-R-args ""
728   "*String of arguments used when starting R.
729 These arguments are currently not passed to other versions of R that have
730 been created using the variable `ess-r-versions'."
731   :group 'ess-R
732   :type 'string)
733
734 (defcustom inferior-R-objects-command "objects(pos=%d, all.names=TRUE)\n"
735   "Format string for R command to get a list of objects at position %d.
736 Used in e.g., \\[ess-execute-objects] or \\[ess-display-help-on-object]."
737   :group 'ess-command
738   :type 'string)
739
740 (defcustom ess-r-versions '( "R-1" "R-2")
741   "*List of partial strings for versions of R to access within ESS.
742 Each string specifies the start of a filename.  If a filename
743 beginning with one of these strings is found on `exec-path', a M-x
744 command for that version of R is made available.  For example, if the
745 file \"R-1.8.1\" is found and this variable includes the string
746 \"R-1\", a function called `M-x R-1.8.1' will be available to run that
747 version of R.
748 If duplicate versions of the same program are found (which happens if
749 the same path is listed on `exec-path' more than once), they are
750 ignored by calling `ess-uniq-list'."
751   :group 'ess-R
752   :type '(repeat string))
753
754
755 (defcustom ess-rterm-versions nil
756 "*Construct ess-rterm-versions.  If you have versions of R in
757 locations other than in ../../rw*/bin/Rterm.exe, relative to the
758 directory in the `exec-path' variable containing your default location
759 of Rterm, you will need to redefine this variable with a
760 `custom-set-variables' statement in your site-start.el or .emacs
761 file."
762   :group 'ess-R
763   :type '(repeat string))
764
765 (defcustom ess-SHOME-versions 
766   '("c:/progra~1/Insightful/splus62"
767     "c:/progra~1/Insightful/splus61"
768     "c:/progra~1/MathSoft/splus6"
769     "c:/progra~1/spls45se"
770     "c:/progra~1/Insightful/splus62netclient"
771     "c:/progra~1/Insightful/splus62net/server"
772     "c:/progra~1/Insightful/splus61netclient"
773     "c:/progra~1/Insightful/splus61net/server"
774     "c:/progra~1/Insightful/splus6se"
775     "c:/progra~1/Insightful/splus61se"
776     "c:/progra~1/Insightful/splus62se"
777     "c:/progra~1/Insightful/splus70"
778     "c:/progra~1/Insightful/splus71")
779   "*List of possible values of the environment variable SHOME for recent
780 releases of S-Plus.  These are the default locations for several
781 current and recent releases of S-Plus.  If any of these pathnames
782 correspond to a directory on your machine, running the function
783 `ess-sqpe-versions-create' will create a function, for example, `M-x
784 splus62', that will start the corresponding version Sqpe inside an
785 emacs buffer in iESS[S] mode.  If you have versions of S-Plus in
786 locations other than these default values, redefine this variable with
787 a `custom-set-variables' statement in your site-start.el or .emacs
788 file.  The list of functions actually created appears in the *ESS*
789 buffer and should appear in the \"ESS / Start Process / Other\"
790 menu."
791   :group 'ess-S
792   :type '(repeat string))
793
794 (defcustom inferior-S3-program-name "/disk05/s/S"
795   "*Program name for invoking an inferior ESS with S3()."
796   :group 'ess-S
797   :type 'string)
798
799 (defcustom inferior-S+3-program-name "Splus"
800   "*Program name for invoking an inferior ESS with S+3()."
801   :group 'ess-S
802   :type 'string)
803
804 (defcustom inferior-S+4-program-name "c:/progra~1/spls45se/cmd/Splus.exe"
805   "*Program name for invoking an external GUI S+4.
806 The default value is correct for a default installation of
807 S-Plus 4.5 Student Edition and with bash as the shell.
808 For any other version or location, change this value in ess-site.el or
809 site-start.el.  Use the 8.3 version of the pathname.
810 Use double backslashes if you use the msdos shell."
811   :group 'ess-S
812   :type 'string)
813
814 (defcustom inferior-S+4-print-command "S_PRINT_COMMAND=gnuclientw.exe"
815   "*Destination of print icon in S+4 Commands window."
816   :group 'ess-S
817   :type 'string)
818
819 (defcustom inferior-S+4-editor-pager-command
820   "options(editor='gnuclient.exe', pager='gnuclientw.exe')"
821   "*Programs called by the editor() and pager() functions
822 in S+4 Commands window and in Sqpe+4 buffer."
823   :group 'ess-S
824   :type 'string)
825
826 (defcustom inferior-Sqpe+4-program-name "c:/progra~1/spls45se/cmd/Sqpe.exe"
827   "*Program name for invoking an inferior ESS with Sqpe+4()."
828   :group 'ess-S
829   :type 'string)
830
831 ;;; SJE - avoid mismatch by changing default nil to ""
832 (defcustom inferior-Sqpe+4-SHOME-name
833   (if ess-microsoft-p "c:/progra~1/spls45se" "")
834   "*SHOME name for invoking an inferior ESS with Sqpe+4().
835 The default value is correct for a default installation of
836 S-Plus 4.5 Student Edition.  For any other version or location,
837 change this value in ess-site.el or site-start.el.  Use the 8.3
838 version of the pathname."
839   :group 'ess-S
840   :type 'string)
841 ;;(if ess-microsoft-p
842 ;;    (let* ((SHOME (getenv "SHOME"))
843 ;;         (PATH (getenv "PATH"))
844 ;;         (split-PATH (split-string PATH ";")) ;; Unix uses ":"
845 ;;         (num 0)
846 ;;         pathname)
847 ;;      (if (not SHOME)
848 ;;        (while (< num (length split-PATH))
849 ;;          (setq pathname (concat (nth num split-PATH) "/Sqpe.exe"))
850 ;;          (if (not (file-exists-p pathname))
851 ;;              (setq num (1+ num))
852 ;;            (progn
853 ;;              (setq num (length split-PATH))
854 ;;              (setq SHOME (expand-file-name (concat pathname "/../..")))))))
855 ;;      (setq-default inferior-Sqpe+4-SHOME-name SHOME)))
856
857
858 (defcustom inferior-S-elsewhere-program-name "sh"
859   "*Program name for invoking an inferior ESS with S on a different computer."
860   :group 'ess-proc
861   :type 'string)
862
863 (defcustom inferior-ESS-elsewhere-program-name "sh"
864   "*Program name for invoking an inferior ESS with program on a
865 different computer."
866   :group 'ess-proc
867   :type 'string)
868
869 (defcustom inferior-S4-program-name "S4"
870   "*Program name for invoking an inferior ESS with S4()."
871   :group 'ess-S
872   :type 'string)
873
874 (defcustom inferior-S+5-program-name "Splus5"
875   "*Program name for invoking an inferior ESS with S+5()."
876   :group 'ess-S
877   :type 'string)
878
879 (if ess-microsoft-p
880     (defcustom inferior-S+6-program-name
881       "c:/progra~1/insigh~1/splus6/cmd/Splus.exe"
882       "*Program name for invoking an external GUI S+6 for Windows.
883 The default value is correct for a default installation of
884 S-Plus 6.0.3 Release 2 and with bash as the shell.
885 For any other version or location, change this value in ess-site.el or
886 site-start.el.  Use the 8.3 version of the pathname.
887 Use double backslashes if you use the msdos shell."
888       :group 'ess-S
889       :type 'string)
890   (defcustom inferior-S+6-program-name "Splus6"
891     "*Program name for invoking an inferior ESS with S+6() for Unix."
892     :group 'ess-S
893     :type 'string))
894
895 (defcustom inferior-Splus-args ""
896   "*String of arguments used when starting S.
897 These arguments are currently passed only to S+6."
898   :group 'ess-S
899   :type 'string)
900
901 (defcustom inferior-Splus-objects-command "objects(where=%d)\n"
902   "Format string for R command to get a list of objects at position %d.
903 Used in e.g., \\[ess-execute-objects] or \\[ess-display-help-on-object]."
904   :group 'ess-command
905   :type 'string)
906
907 (defcustom inferior-S+6-print-command "S_PRINT_COMMAND=gnuclientw.exe"
908   "*Destination of print icon in S+6 for Windows Commands window."
909   :group 'ess-S
910   :type 'string)
911
912 (defcustom inferior-S+6-editor-pager-command
913   "options(editor='gnuclient.exe', pager='gnuclientw.exe')"
914   "*Programs called by the editor() and pager() functions
915 in S+6 for Windows Commands window and in Sqpe+6 for Windows buffer."
916   :group 'ess-S
917   :type 'string)
918
919 (defcustom inferior-Sqpe+6-program-name
920   "c:/progra~1/insigh~1/splus6/cmd/Sqpe.exe"
921   "*Program name for invoking an inferior ESS with Sqpe+6() for Windows."
922   :group 'ess-S
923   :type 'string)
924
925 ;;; SJE - avoid mismatch by changing default nil to ""
926 (defcustom inferior-Sqpe+6-SHOME-name
927   (if ess-microsoft-p "c:/progra~1/insigh~1/splus6" "")
928   "*SHOME name for invoking an inferior ESS with Sqpe+6() for Windows.
929 The default value is correct for a default installation of
930 S-Plus 6.0.3 Release 2.  For any other version or location,
931 change this value in ess-site.el or site-start.el.  Use the 8.3
932 version of the pathname."
933   :group 'ess-S
934   :type 'string)
935 ;;(if ess-microsoft-p
936 ;;    (let* ((SHOME (getenv "SHOME"))
937 ;;         (PATH (getenv "PATH"))
938 ;;         (split-PATH (split-string PATH ";")) ;; Unix uses ":"
939 ;;         (num 0)
940 ;;         pathname)
941 ;;      (if (not SHOME)
942 ;;        (while (< num (length split-PATH))
943 ;;          (setq pathname (concat (nth num split-PATH) "/Sqpe.exe"))
944 ;;          (if (not (file-exists-p pathname))
945 ;;              (setq num (1+ num))
946 ;;            (progn
947 ;;              (setq num (length split-PATH))
948 ;;              (setq SHOME (expand-file-name (concat pathname "/../..")))))))
949 ;;      (setq-default inferior-Sqpe+6-SHOME-name SHOME)))
950
951 (defcustom ess-S-quit-kill-buffers-p nil
952   "Controls whether S buffers should also be killed once a process is killed.
953 This is used only when an iESS process is killed using C-c C-q.
954 Possible values:
955 nil - do not kill any S buffers associated with the process.
956 t - kill S buffers associated with the process.
957 ask - ask the user whether the S buffers should be killed."
958   :group 'ess-S
959   :type '(choice (const nil) (const t) (const ask)))
960
961 (defcustom inferior-XLS-program-name "xlispstat"
962   "*Program name for invoking an inferior ESS with \\[XLS]."
963   :group 'ess-XLS
964   :type 'string)
965
966 (defcustom inferior-VST-program-name "vista"
967   "*Program name for invoking an inferior ESS with \\[ViSta]."
968   :group 'ess-XLS
969   :type 'string)
970
971 (defcustom inferior-ARC-program-name "arc"
972   "*Program name for invoking an inferior ESS with \\[ARC]."
973   :group 'ess-XLS
974   :type 'string)
975
976 (defcustom inferior-SAS-program-name "sas"
977   "*Program name for invoking an inferior ESS with SAS()."
978   :group 'ess-sas
979   :type 'string)
980
981 (defcustom inferior-STA-program-name "env"
982   "*Program name for invoking an inferior ESS with stata().
983 This is NOT Stata, because we need to call stata with TERM=emacs in
984 order for it to work right.  And Emacs is too smart for it."
985   :group 'ess-Stata
986   :type 'string)
987
988 (defcustom inferior-OMG-program-name "omegahat"
989   "*Program name for invoking an inferior ESS with omegahat()."
990   :group 'ess-OMG
991   :type 'string)
992
993
994 ;;;;; names for setting the pager and editor options of the
995 ;;;;; inferior-ess-process
996 ;;;
997 ;;; S-editor and S-pager,
998 ;;; R-editor and R-pager,
999 ;;; ess-editor and ess-pager,
1000 ;;; and inferior-ess-language-start
1001 ;;; apply in principle to the 15 files essd[s-]*.el
1002 ;;; Several of the files (essd-sp4.el and essd-sp6w.el) have more
1003 ;;; than one *-customize-alist.
1004 ;;; These variables are currently used only with the S language files for
1005 ;;; S S-Plus R.
1006
1007 (defcustom R-editor
1008   (if ess-microsoft-p "gnuclient.exe"
1009     (if (equal system-type 'Apple-Macintosh) nil
1010       (if (featurep 'xemacs) "gnuclient -q" "emacsclient"))) ;; unix
1011   "*Editor called by R process with 'edit()' command."
1012   :group 'ess
1013   :type 'string)
1014
1015 (defcustom R-pager 'nil ; Usually nil is correct as ESS and page() cooperate.
1016   "*Pager called by R process with 'page()' command."
1017   :group 'ess
1018   :type '(choice (const nil) string))
1019
1020 (defcustom S-editor
1021   (if ess-microsoft-p "gnuclient.exe"
1022     (if (equal system-type 'Apple-Macintosh) nil
1023       (if (featurep 'xemacs) "gnuclient -q" "emacsclient"))) ;; unix
1024   "*Editor called by S process with 'edit()' command."
1025   :group 'ess
1026   :type 'string)
1027
1028 (defcustom S-pager
1029   (if ess-microsoft-p "gnuclientw.exe"
1030     (if (equal system-type 'Apple-Macintosh) nil
1031       (if (featurep 'xemacs) "gnuclient -q" "emacsclient")))
1032   "*Pager called by S process with 'page()' command."
1033   ;; Change made to provide a better help(function) experience with
1034   ;; S+6 and xemacs
1035   ;; gnuclient -q will open a buffer with an HTML help file
1036   ;; you can view it with M-x browse-url-of-buffer
1037   :group 'ess
1038   :type 'string)
1039
1040 (defvar ess-editor nil
1041   "*Editor by which the process sends information to an emacs buffer
1042 for editing and then to be returned to the process.")
1043
1044 (defvar ess-pager nil
1045   "*Pager by which the process sends information to an emacs buffer.")
1046
1047 (defvar inferior-ess-language-start nil
1048   "*Initialization commands sent to the ESS process.")
1049
1050 (make-variable-buffer-local 'ess-editor)
1051 (make-variable-buffer-local 'ess-pager)
1052 (make-variable-buffer-local 'inferior-ess-language-start)
1053
1054
1055
1056 ;;;;; names for communication using MS-Windows 9x/NT ddeclient mechanism
1057
1058 (defcustom inferior-ess-ddeclient nil
1059   "*ddeclient is the intermediary between emacs and the stat program."
1060   :group 'ess-proc
1061   :type 'string)
1062
1063 (make-variable-buffer-local 'inferior-ess-ddeclient)
1064
1065 (defcustom inferior-ess-client-name nil
1066   "*Name of ESS program ddeclient talks to."
1067   :group 'ess-proc
1068   :type 'string)
1069
1070 (make-variable-buffer-local 'inferior-ess-client-name)
1071
1072 (defcustom inferior-ess-client-command nil
1073   "*ddeclient command sent to the ESS program."
1074   :group 'ess-proc
1075   :type '(choice (const nil) string))
1076
1077 (make-variable-buffer-local 'inferior-ess-client-command)
1078
1079 ;;;;; user settable defaults
1080 (defvar inferior-S-program-name  inferior-S+3-program-name
1081   "*Program name for invoking an inferior ESS with S().")
1082 ;;- (setq inferior-S-program
1083 ;;-       (cond ((string= S-proc-prefix "S") "Splus")
1084 ;;-         ((string= S-proc-prefix "R") "R")
1085 ;;-         (t "S")
1086 ;;-         ))
1087 ;;(make-local-variable 'inferior-S-program)
1088
1089 (defvar inferior-ess-program nil ;inferior-S-program-name
1090   "*Default program name for invoking inferior-ess().
1091 The other variables ...-program-name should be changed, for the
1092 corresponding program.")
1093
1094 (make-variable-buffer-local 'inferior-ess-program)
1095 (setq-default inferior-ess-program inferior-S-program-name)
1096
1097
1098 (defvar inferior-ess-start-args ""
1099   "String of arguments passed to the ESS process.
1100 If you wish to pass arguments to a process, see e.g. `inferior-R-args'.")
1101
1102 (defcustom inferior-ess-start-file nil
1103   "*File dumped into process, if non-nil."
1104   :group 'ess-proc
1105   :type '(choice (const nil) file))
1106
1107 (defcustom inferior-ess-pager "cat"
1108   "*Pager to use for reporting help files and similar things."
1109   :group 'ess-proc
1110   :type 'string)
1111
1112 (defcustom inferior-ess-primary-prompt "[a-zA-Z0-9() ]*> ?"
1113   "Regular expression used by `ess-mode' to detect the primary prompt.
1114 Do not anchor to bol with `^'.")
1115
1116 (make-variable-buffer-local 'inferior-ess-primary-prompt)
1117 (setq-default inferior-ess-primary-prompt "[a-zA-Z0-9() ]*> ?")
1118
1119 (defcustom inferior-ess-secondary-prompt "+ ?"
1120   "Regular expression used by ess-mode to detect the secondary prompt.
1121 (This is issued by S to continue an incomplete expression). Do not
1122 anchor to bol with `^'.")
1123
1124 (make-variable-buffer-local 'inferior-ess-secondary-prompt)
1125 (setq-default inferior-ess-secondary-prompt "+ ?")
1126
1127 ;;*;; Variables controlling interaction with the ESS process
1128
1129 (defcustom ess-execute-in-process-buffer nil
1130   "*If non-nil, the ess-execute- commands output to the process buffer.
1131 Otherwise, they get their own temporary buffer."
1132   :group 'ess-proc
1133   :type 'boolean)
1134
1135 (defcustom ess-eval-empty nil
1136   "*If non-nil, `ess-eval-line-and-step' and `ess-eval-linewise'
1137 will send empty lines to the ESS process."
1138   :group 'ess-proc
1139   :type 'boolean)
1140
1141 (defcustom ess-eval-visibly-p t
1142   "*If non-nil, the ess-eval- commands display the text to be evaluated
1143 in the process buffer."
1144   :group 'ess-proc
1145   :type 'boolean)
1146
1147 (defcustom ess-synchronize-evals nil
1148   "*If t, then all evaluations will synchronize with the ESS process. This
1149 means ess-mode will wait for S to dent a prompt before sending the next
1150 line of code. This allows users of Emacs version 18.57 or less to
1151 evaluate large regions of code without causing an error.  Users of newer
1152 Emacsen usually do not want this feature, since it locks up use
1153 of Emacs until the code has been successfully evaluated."
1154   :group 'ess-proc
1155   :type 'boolean)
1156
1157 (defcustom ess-eval-visibly-at-end t
1158   "*If non-nil, the ess-eval- commands display the results of evaluation
1159   at the bottom of the process buffer."
1160   :group 'ess-proc
1161   :type 'boolean)
1162
1163 \f ; System variables
1164
1165 ;;*;; Variables relating to multiple processes
1166
1167 (defcustom ess-current-process-name nil
1168   "Name of the current S process."
1169   :group 'ess-proc
1170   :type '(choice (const nil) string))
1171
1172 ;; defconst ess-local-process-name now done in S.el
1173
1174 (defcustom ess-process-name-list nil
1175   "Alist of active ESS processes.")
1176
1177 ;;*;; Inferior ESS commands
1178
1179 (defcustom inferior-ess-load-command "source(\"%s\")\n"
1180   "Format-string for building the ess command to load a file.
1181
1182 This format string should use %s to substitute a file name and should
1183 result in an ESS expression that will command the inferior ESS to load
1184 that file."
1185   :group 'ess-command
1186   :type 'string)
1187
1188 (defcustom inferior-ess-dump-command "dump(\"%s\",file=\"%s\")\n"
1189   "Format-string for building the ess command to dump an object into a file.
1190
1191 Use first %s to substitute an object name
1192 Use second %s to substitute the dump file name."
1193   :group 'ess-command
1194   :type 'string)
1195
1196 (defcustom inferior-ess-help-command "help(\"%s\")\n"
1197   "Format-string for building the ESS command to ask for help on an object.
1198
1199 This format string should use %s to substitute an object name."
1200   :group 'ess-command
1201   :type 'string)
1202
1203 (make-variable-buffer-local 'inferior-ess-help-command)
1204 (setq-default inferior-ess-help-command "help(\"%s\")\n")
1205
1206 (defcustom inferior-ess-exit-command "q()\n"
1207   "Format-string for building the ess command to exit.
1208
1209 This format string should use %s to substitute an object name."
1210   :group 'ess-command
1211   :type 'string)
1212
1213 (make-variable-buffer-local 'inferior-ess-exit-command)
1214 (setq-default inferior-ess-exit-command "q()\n")
1215
1216 (defvar inferior-ess-search-list-command nil
1217   "`ess-language' command that prints out the search list;
1218 i.e. the list of directories and (recursive) objects that `ess-language' uses
1219 when it searches for objects.
1220
1221 Really set in <ess-lang>-customize-alist in ess[dl]-*.el")
1222 ;; and hence made buffer-local via that scheme...
1223
1224 (defcustom inferior-ess-names-command "names(%s)\n"
1225   "Format string for ESS command to extract names from an object.
1226
1227 %s is replaced by the object name -- usually a list or data frame."
1228   :group 'ess-command
1229   :type 'string)
1230
1231 (defcustom inferior-ess-get-prompt-command "options()$prompt\n"
1232   "Command to find the value of the current S prompt."
1233   :group 'ess-command
1234   :type 'string)
1235
1236 (defvar ess-cmd-delay nil
1237   "*Set to a positive number if ESS will include delays proportional to
1238 `ess-cmd-delay'  in some places. These delays are introduced to
1239 prevent timeouts in certain processes, such as completion.")
1240 (make-variable-buffer-local 'ess-cmd-delay)
1241
1242 (defcustom ess-R-cmd-delay nil
1243   "used to initialize `ess-cmd-delay'."
1244   :group 'ess-command
1245   :type '(choice (const nil) number))
1246
1247 (defcustom ess-S+-cmd-delay 1.0
1248   "used to initialize `ess-cmd-delay'."
1249   :group 'ess-command
1250   :type '(choice (const nil) number))
1251
1252 ;;*;; Regular expressions
1253
1254 (defvar inferior-ess-prompt nil
1255   "The regular expression inferior ess mode uses for recognizing prompts.
1256  Constructed at run time from `inferior-ess-primary-prompt' and
1257 `inferior-ess-secondary-prompt' within `inferior-ess-mode'.")
1258
1259 (make-variable-buffer-local 'inferior-ess-prompt)
1260
1261 (defvar ess-change-sp-regexp ""
1262   "The regexp for matching the S/R/.. commands that change the search path.")
1263 (make-variable-buffer-local 'ess-change-sp-regexp)
1264
1265 (defcustom ess-S+-change-sp-regexp
1266   "\\(attach(\\([^)]\\|$\\)\\|detach(\\|collection(\\|library(\\|module(\\|source(\\)"
1267   "The regexp for matching the S-plus commands that change the search path."
1268   :group 'ess-proc
1269   :type 'regexp)
1270
1271 (defcustom ess-S-change-sp-regexp
1272   "\\(attach(\\([^)]\\|$\\)\\|detach(\\|library(\\|source(\\)"
1273   "The regexp for matching the S commands that change the search path."
1274   :group 'ess-proc
1275   :type 'regexp)
1276
1277 (defcustom ess-R-change-sp-regexp
1278   "\\(attach(\\([^)]\\|$\\)\\|detach(\\|library(\\|require(\\|source(\\)"
1279   "The regexp for matching the R commands that change the search path."
1280   :group 'ess-proc
1281   :type 'regexp)
1282
1283
1284 ;;*;; Process-dependent variables
1285
1286 (defvar ess-search-list nil
1287   "Cache of list of directories and objects to search for ESS objects.")
1288
1289 (make-variable-buffer-local 'ess-search-list)
1290
1291 (defvar ess-sl-modtime-alist nil
1292   "Alist of modification times for all ess directories accessed this
1293 session.")
1294
1295 (make-variable-buffer-local 'ess-sl-modtime-alist)
1296
1297 (defvar ess-sp-change nil
1298   "This symbol flags a change in the ess search path.")
1299
1300 (make-variable-buffer-local 'ess-sp-change)
1301
1302 (defvar ess-prev-load-dir/file nil
1303   "This symbol saves the (directory . file) pair used in the last
1304 `ess-load-file' command.  Used for determining the default in the next one.")
1305
1306 (make-variable-buffer-local 'ess-prev-load-dir/file)
1307
1308 (defvar ess-object-list nil
1309   ;; This is a list of the currently known object names.  It is
1310   ;; current only for one command entry; it exists under the
1311   ;; assumption that the list of objects doesn't change while entering
1312   ;; a command.
1313   "Cache of object names")
1314
1315 (make-variable-buffer-local 'ess-object-list)
1316
1317 ;;*;; Miscellaneous system variables
1318
1319 (defvar ess-temp-point nil
1320  "Variable used to retain a buffer position past let or let*.")
1321
1322 (defvar ess-mode-map nil
1323   "Keymap for `ess-mode'.")
1324
1325 (defvar ess-eval-map nil
1326   "Keymap for ess-eval functions.")
1327
1328 (defvar inferior-ess-mode-map nil
1329   "Keymap for `inferior-ess' mode.")
1330
1331 (defvar ess-mode-minibuffer-map nil)
1332
1333 ;; SJE: Wed 29 Dec 2004 - following 3 ess-object* variables can be removed
1334 ;; soon if no-one needs the completion code.
1335 (defvar ess-object-name-db-file "ess-namedb"
1336   "File containing definitions for `ess-object-name-db'.")
1337
1338 (defvar ess-object-name-db-file-loaded '()
1339   "List of programs whose name-db file has been loaded.")
1340
1341 (defvar ess-object-name-db nil
1342   "Alist of lists of object names, with directory names as keys.
1343 The file ess-namedb.el is loaded (if it exists) to define this variable.
1344 See also function `ess-create-object-name-db'.")
1345
1346 (make-variable-buffer-local 'ess-object-name-db)
1347 (setq-default ess-object-name-db nil)
1348
1349 (defcustom ess-S-loop-timeout 2000000
1350   "Integer specifying how many loops ess-mode will wait for the prompt
1351 before signaling an error. Will be set to `ess-loop-timeout' in the S dialects'
1352 alists.  Increase this, if you have a fast(er) machine."
1353   :group 'ess-proc
1354   :type 'integer)
1355
1356 (defcustom ess-XLS-loop-timeout 50000
1357   "Integer specifying how many loops ess-mode will wait for the prompt
1358 before signaling an error. Will be set to `ess-loop-timeout' in the XLispStat
1359 dialects' alists.  Increase this, if you have a fast(er) machine."
1360   :group 'ess-proc
1361   :type 'integer)
1362
1363 ;; NOTA BENE: Other languages/dialect currently set `ess-loop-timeout'
1364 ;;            **directly** in their essd-*.el alist !!
1365
1366 ;;;*;;; Font-lock support
1367
1368 ;;; for programming, transcript, and inferior process modes.
1369
1370 (defcustom inferior-ess-font-lock-input t
1371   "*If non-nil, input is syntactically font-locked.
1372 If nil, input is in the `font-lock-variable-name-face'."
1373   :group 'ess
1374   :type 'boolean)
1375
1376 (defvar ess-R-constants
1377   '("TRUE" "FALSE" "NA" "NULL" "Inf" "NaN"))
1378
1379 (defvar ess-S-constants
1380   (append ess-R-constants '("T" "F")))
1381
1382 ;; first the common ones
1383 (defvar ess-S-modifyiers
1384   '("library" "attach" "detach" "source" "module"))
1385 (defvar ess-R-modifyiers
1386   '("library" "attach" "detach" "source" "require"))
1387
1388 (defvar ess-R-keywords
1389   '("while" "for" "in" "repeat" "if" "else" "switch" "break" "next"
1390     "function" "return" "message" "warning" "stop"))
1391 (defvar ess-S-keywords
1392   (append ess-R-keywords '("terminate")))
1393
1394 (defvar ess-R-message-prefixes
1395   '("Error:" "Error in"
1396     "Warning:" "Warning in"
1397     "Warning messages?"))
1398 (defvar ess-S-message-prefixes
1399   (append ess-R-message-prefixes
1400           '("Syntax error:" "Dumped")))
1401
1402 ;;
1403 (defvar ess-R-assign-ops
1404   '("<<-" "<-" "->") ; don't want "=" here which is not only for assign
1405 )
1406 (defvar ess-S-assign-ops
1407   '("<<-" "<-" "_" "->") ; don't want "=" here which is not only for assign
1408 )
1409
1410 (defvar ess-R-function-name-regexp
1411   (concat "\\s\"?\\(\\(\\sw\\|\\s_\\)+"
1412           "\\(<-\\)?\\)\\s\"?\\s-*\\(<-\\)"
1413           "\\(\\s-\\|\n\\)*function")
1414 )
1415 (defvar ess-S-function-name-regexp
1416   ess-R-function-name-regexp ; since "_" is deprecated for S-plus as well
1417 )
1418
1419
1420 (defvar ess-R-mode-font-lock-keywords
1421   (list
1422    (cons (regexp-opt ess-R-assign-ops)
1423          'font-lock-reference-face)     ; assign
1424    (cons (concat "\\<" (regexp-opt ess-R-constants 'enc-paren) "\\>")
1425          'font-lock-type-face)          ; constants
1426    (cons (concat "\\<" (regexp-opt ess-R-modifyiers 'enc-paren) "\\>")
1427          'font-lock-reference-face)     ; modify search list or source
1428                                         ; new definitions
1429    (cons (concat "\\<" (regexp-opt ess-R-keywords 'enc-paren) "\\>")
1430          'font-lock-keyword-face)       ; keywords
1431    (cons ess-R-function-name-regexp
1432          '(1 font-lock-function-name-face t))
1433                                         ; function name
1434     )
1435   "Font-lock patterns used in `R-mode' buffers.")
1436
1437 (defvar ess-S-mode-font-lock-keywords
1438   (list
1439    (cons (regexp-opt ess-S-assign-ops)
1440          'font-lock-reference-face)     ; assign
1441    (cons (concat "\\<" (regexp-opt ess-S-constants 'enc-paren) "\\>")
1442          'font-lock-type-face)          ; constants
1443    (cons (concat "\\<" (regexp-opt ess-S-modifyiers 'enc-paren) "\\>")
1444          'font-lock-reference-face)     ; modify search list or source
1445                                         ; new definitions
1446    (cons (concat "\\<" (regexp-opt ess-S-keywords 'enc-paren) "\\>")
1447          'font-lock-keyword-face)       ; keywords
1448    (cons ess-S-function-name-regexp
1449          '(1 font-lock-function-name-face t))
1450                                         ; function name
1451    )
1452   "Font-lock patterns used in `S-mode' buffers.")
1453
1454
1455
1456
1457 (defvar inferior-ess-R-font-lock-keywords
1458   (append
1459    '(("^[a-zA-Z0-9 ]*[>+]" . font-lock-keyword-face)) ; "prompt" must be first
1460
1461    (if (not inferior-ess-font-lock-input) ;; don't font-lock input :
1462        (list (cons "^[a-zA-Z0-9 ]*[>+]\\(.*$\\)"
1463                    '(1 font-lock-variable-name-face keep t))) )
1464
1465    ess-R-mode-font-lock-keywords
1466
1467    (list
1468     (cons "^\\*\\*\\*.*\\*\\*\\*\\s *$" 'font-lock-comment-face); ess-mode msg
1469     (cons "\\[,?[1-9][0-9]*,?\\]" 'font-lock-reference-face);Vector/matrix labels
1470     (cons (concat "^" (regexp-opt ess-R-message-prefixes 'enc-paren))
1471           'font-lock-reference-face) ; inferior-ess problems or errors
1472     (cons "#"   'font-lock-comment-face) ; comment
1473     (cons "^[^#]*#\\(.*$\\)" '(1 font-lock-comment-face keep t)) ; comments
1474                  ))
1475   "Font-lock patterns used in inferior-R-mode buffers.")
1476
1477 (defvar inferior-ess-S-font-lock-keywords
1478   (append
1479    '(("^[a-zA-Z0-9 ]*[>+]" . font-lock-keyword-face)) ; "prompt" must be first
1480
1481    (if (not inferior-ess-font-lock-input) ;; don't font-lock input :
1482        (list (cons "^[a-zA-Z0-9 ]*[>+]\\(.*$\\)"
1483                    '(1 font-lock-variable-name-face keep t))) )
1484
1485    ess-S-mode-font-lock-keywords
1486
1487    (list
1488     (cons "^\\*\\*\\*.*\\*\\*\\*\\s *$" 'font-lock-comment-face) ; ess-mode msg
1489     (cons "\\[,?[1-9][0-9]*,?\\]" 'font-lock-reference-face);Vector/matrix labels
1490     (cons (concat "^" (regexp-opt ess-S-message-prefixes 'enc-paren))
1491           'font-lock-reference-face) ; inferior-ess problems or errors
1492     (cons "#" 'font-lock-comment-face)  ; comment
1493     (cons "^[^#]*#\\(.*$\\)" '(1 font-lock-comment-face keep t)) ; comments
1494     ))
1495   "Font-lock patterns used in inferior-S-mode buffers.")
1496
1497 ;; use the inferior-* ones directly in ess-trns.el
1498 ;; (defvar ess-trans-font-lock-keywords
1499 ;;   inferior-ess-font-lock-keywords
1500 ;;   "Font-lock patterns used in `ess-transcript-mode' buffers.")
1501
1502
1503 ;;;*;;; ess-help variables
1504
1505 \f ; ess-help-mode
1506 ;; This will never need to be loaded independently of any of the other
1507 ;; modules, but they can all call it so we may as well put it here.
1508
1509 ;;*;; Variables relating to ess-help-mode
1510
1511 (defcustom ess-help-own-frame nil
1512   "*Controls whether ESS help buffers should start in a different frame.
1513
1514 Possible values are:
1515    nil: Display help in current frame.
1516   'one: All help buffers are shown in one dedicated frame.
1517      t: Each help buffer gets its own frame.
1518
1519 The parameters of this frame are stored in `ess-help-frame-alist'.
1520 See also `inferior-ess-own-frame'."
1521   :group 'ess-help
1522   :type '(choice (const nil) (const one) (const t)))
1523
1524 (defcustom ess-help-frame-alist special-display-frame-alist
1525   "*Alist of frame parameters used to create help frames.
1526 This defaults to `special-display-frame-alist' and is used only when
1527 the variable `ess-help-own-frame' is non-nil."
1528   :group 'ess-help
1529   :type 'alist)
1530
1531
1532 \f ; User changeable variables
1533 ;;;=====================================================
1534 ;;; Users note: Variables with document strings starting
1535 ;;; with a * are the ones you can generally change safely, and
1536 ;;; may have to upon occasion.
1537
1538 (defcustom ess-help-kill-bogus-buffers nil
1539   "*If non-nil, kill ESS help buffers immediately if they are \"bogus\"."
1540   :group 'ess-help
1541   :type 'boolean)
1542
1543 (defvar ess-help-form 'separate-buffer
1544   "*Place to show help.   NOT IMPLEMENTED YET.
1545 Choices are `separate-buffer', `s-process', `www'.  The latter uses
1546 `browse-url' to find the location.")
1547
1548 ;; WWW Help NOT included yet.  Be patient.
1549 (defvar ess-help-w3-url-prefix "http://pyrite.cfas.washington.edu/ESS/R/"
1550   "*Head URL for finding function help.")
1551
1552 (defvar ess-help-w3-url-funs "funs/"
1553   "Place to find functions.")
1554
1555
1556 \f ; System variables
1557 ;;;=====================================================
1558 ;;; Users note: You will rarely have to change these
1559 ;;; variables.
1560
1561 ;;*;; Variables relating to ess-help-mode
1562
1563 ;;-- ess-help-S-.. and  ess-help-R-.. : in  essl-s.el (are used in ess-inf).
1564
1565 (defvar ess-help-sec-keys-alist nil
1566   "Alist of (key . string) pairs for use in section searching.")
1567
1568 (defvar ess-help-sec-regex nil
1569   "Reg(ular) Ex(pression) of section headers in help file")
1570
1571 (make-variable-buffer-local 'ess-help-sec-keys-alist)
1572 (make-variable-buffer-local 'ess-help-sec-regex)
1573
1574
1575 \f ; ess-mode: editing S source
1576
1577 ;;; This syntax table is required by ess-mode.el, ess-inf.el and
1578 ;;; ess-trans.el, so we provide it here.
1579 (defvar ess-mode-syntax-table nil "Syntax table for `ess-mode'.")
1580 (make-variable-buffer-local 'ess-mode-syntax-table)
1581
1582
1583 \f ; Buffer local customization stuff
1584
1585 (defvar ess-source-modes '(ess-mode)
1586   "A list of modes used to determine if a buffer contains ess source code.")
1587 ;;; If a file is loaded into a buffer that is in one of these major modes, it
1588 ;;; is considered an ess source file.  The function ess-load-file uses this to
1589 ;;; determine defaults.
1590
1591 (defcustom ess-error-buffer-name "*ESS-errors*"
1592   "Name of buffer to keep process error messages in.
1593 Created for each process."
1594   :group 'ess-proc
1595   :type 'string)
1596
1597 (defcustom ess-verbose nil
1598   "if non-nil, write more information to `ess-dribble-buffer' than usual."
1599   :group 'ess-proc
1600   :type 'boolean)
1601
1602 (defvar ess-dribble-buffer (generate-new-buffer "*ESS*")
1603   "Buffer for temporary use for setting default variable values.
1604 Used for recording status of the program, mainly for debugging.")
1605
1606 (defvar ess-customize-alist nil
1607   "Variable settings to use for proper behavior.
1608 Not buffer local!")
1609
1610 (defvar ess-local-customize-alist nil
1611   "Buffer local settings for proper behavior.
1612 Used to store the values for passing on to newly created buffers.")
1613
1614 (make-variable-buffer-local 'ess-local-customize-alist)
1615
1616 (defvar ess-mode-editing-alist nil
1617   "Variable settings for ess-mode.")
1618
1619 (defvar ess-transcript-minor-mode nil
1620   "Non-nil if using `ess-transcript-mode' as a minor mode of some other mode.")
1621
1622 (make-variable-buffer-local 'ess-transcript-minor-mode)
1623
1624 (defvar ess-listing-minor-mode nil
1625   "Non-nil if using ess-listing-minor-mode.")
1626
1627 (make-variable-buffer-local 'ess-listing-minor-mode)
1628
1629 (provide 'ess-cust)
1630
1631 \f ; Local variables section
1632
1633 ;;; This file is automatically placed in Outline minor mode.
1634 ;;; The file is structured as follows:
1635 ;;; Chapters:     ^L ;
1636 ;;; Sections:    ;;*;;
1637 ;;; Subsections: ;;;*;;;
1638 ;;; Components:  defuns, defvars, defconsts
1639 ;;;              Random code beginning with a ;;;;* comment
1640
1641 ;;; Local variables:
1642 ;;; mode: emacs-lisp
1643 ;;; mode: outline-minor
1644 ;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*"
1645 ;;; End:
1646
1647 ;;; ess-cust.el ends here