~ubuntu-branches/ubuntu/edgy/ess/edgy

« back to all changes in this revision

Viewing changes to lisp/ess.el

  • Committer: Bazaar Package Importer
  • Author(s): Camm Maguire
  • Date: 2005-03-22 13:48:07 UTC
  • mfrom: (1.2.1 upstream) (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050322134807-9mpmbb799jugf248
Tags: 5.2.6-1
* New upstream release
* chmod -R u+w on orig source

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
;;; ess.el --- Emacs Speaks Statistics: statistical programming within Emacs
2
2
 
3
3
;; Copyright (C) 1989--1996 Bates, Kademan, Ritter and Smith
4
 
;; Copyright (C) 1996--2001 Rossini, Heiberger, Hornik, Maechler and
5
 
;;                          Sparapani.
 
4
;; Copyright (C) 1997--2005 A.J. Rossini, Rich M. Heiberger, Martin
 
5
;;      Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
6
6
 
7
 
;; Author: Doug Bates, Ed Kademan, Frank Ritter, David Smith
8
 
;; Maintainer(s): A.J. Rossini <rossini@biostat.washington.edu>
9
 
;;                Martin Maechler  <maechler@stat.math.ethz.ch>
10
 
;;                Kurt Hornik <hornik@ci.tuwien.ac.at>
11
 
;;                Richard M. Heiberger <rmh@fisher.stat.temple.edu>
12
 
;;                Rodney Sparapani <rsparapa@mcw.edu>
 
7
;; Original Authors: Doug Bates, Ed Kademan, Frank Ritter, David Smith
13
8
;; Created: October 14, 1991
14
 
;; Version: $Id: ess.el,v 5.26 2001/08/10 13:46:43 maechler Exp $
 
9
;; Maintainers: ESS-core <ESS-core@stat.math.ethz.ch>
 
10
 
15
11
;; Keywords: statistical support
16
12
;; Summary: general functions for ESS
17
13
 
18
 
;; Lisp-dir-entry  : ESS |
19
 
;;                   R. M. Heiberger, K. Hornik, M. Maechler, A.J. Rossini|
20
 
;;                   ess-bugs@stat.math.ethz.ch|
21
 
;;                   General Interface for Statistical Software Packages|
22
 
;;                   92-06-29|
23
 
;;                   5.0|
24
 
;;                   ftp://ess.stat.wisc.edu/pub/ESS/ESS-5.0.tar.gz
25
 
 
26
14
;; This file is part of ESS
27
15
 
28
16
;; This file is free software; you can redistribute it and/or modify
32
20
;;
33
21
;; This file is distributed in the hope that it will be useful,
34
22
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
35
 
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
23
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
36
24
;; GNU General Public License for more details.
37
25
;;
38
26
;; You should have received a copy of the GNU General Public License
39
 
;; along with GNU Emacs; see the file COPYING.  If not, write to
 
27
;; along with GNU Emacs; see the file COPYING.  If not, write to
40
28
;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
41
29
;;
42
30
;; In short: you may use this code any way you like, as long as you
43
31
;; don't charge money for it, remove this notice, or hold anyone liable
44
32
;; for its results.
45
33
 
46
 
;; Copyright 1989--92,1997 Doug Bates    bates@stat.wisc.edu
47
 
;;           1993, 1994    Ed Kademan    kademan@stat.wisc.edu
48
 
;;                         Frank Ritter  ritter@psychology.nottingham.ac.uk
49
 
;;           1994--1997    David Smith <maa036@lancaster.ac.uk>
50
 
;;
51
 
;;           1996--2000    Kurt Hornik <Kurt.Hornik@ci.tuwien.ac.at>
52
 
;;           1996--2001    Martin Maechler <maechler@stat.math.ethz.ch>
53
 
;;           1996--2000    A.J. Rossini <rossini@stat.sc.edu>,
54
 
;;           1998--2001                 <rossini@biostat.washington.edu>
55
 
;;           1996--2001    Richard M. Heiberger <rmh@astro.ocis.temple.edu>
56
 
;;           1999--2001    Rodney Sparapani <rsparapa@mcw.edu>
57
 
;;
58
 
 
59
34
;;; Commentary:
60
35
 
61
36
;;; PURPOSE
62
37
;;;
63
38
;;; Interface to the S, SAS, and XLisp dialects of statistical
64
39
;;; programming languages, with potential extensions to other
65
 
;;; languages.  Designed to be extendable to most other interactive
 
40
;;; languages.  Designed to be extendable to most other interactive
66
41
;;; statistical programming situations.
67
42
 
68
43
;;; BRIEF OVERVIEW
89
64
;;; command history editing and job control, inferior S mode
90
65
;;; allows you to dump and load S objects into and from external
91
66
;;; files, and to display help on functions.  It also provides
92
 
;;; name completion while you do these.  For more detailed
 
67
;;; name completion while you do these.  For more detailed
93
68
;;; information see the documentation strings for inferior-ess,
94
69
;;; inferior-ess-mode, ess-mode, and comint-mode.  There are also
95
70
;;; many variables and hooks available for customizing (see
100
75
;;; See README and S-site for details.
101
76
 
102
77
;;; GETTING RELEASES OF ESS
103
 
;;; ===> http://ess.stat.wisc.edu/
 
78
;;; ===> http://ess.r-project.org
104
79
;;;
105
80
 
106
81
;;; CREDITS.
135
110
 
136
111
(require 'ess-emcs)
137
112
 
138
 
;; The following should take care of all cases.  Currently, seems to
139
 
;; work, sigh...
140
 
;;(if ess-local-custom-available
141
 
;;    (eval-and-compile  ; was progn
142
 
;;      (ess-message "--++ LOADING CUSTOM ++--")
143
 
;;      (require 'ess-cust))
144
 
;;  (eval-and-compile  ; was progn
145
 
;;    (ess-message "--++ NOT NOT NOT loading custom ++--")
146
 
;;    (require 'ess-vars)))
147
 
 
148
 
;; The above was commented out to verify that it would work on
149
 
;; versions w/o customize.  Remove after verification.
150
113
(eval-and-compile
151
114
  (require 'ess-cust))
152
115
 
163
126
 
164
127
(autoload 'ess-load-file "ess-inf" "Source a file into S.")
165
128
 
166
 
(autoload 'inside-string/comment-p "ess-utils"
 
129
(autoload 'ess-inside-string-or-comment-p "ess-utils"
167
130
  "Non-nil, if inside string or comment." t)
 
131
(autoload 'ess-inside-string-p "ess-utils" "Non-nil if inside string." t)
 
132
 
 
133
(autoload 'ess-do-auto-fill "ess-utils" "substitute for \\[do-auto-fill]." t)
 
134
 
168
135
(autoload 'ess-rep-regexp "ess-utils" "Replace, but not in string/comment." t)
169
136
 
170
137
(autoload 'ess-time-string "ess-utils" "Return time-stamp string." t)
171
138
 
172
 
(autoload 'nuke-trailing-whitespace "ess-utils"
 
139
(autoload 'ess-nuke-trailing-whitespace "ess-utils"
173
140
  "Maybe get rid of trailing blanks." t)
174
141
 
175
142
 ; ess-transcript-mode: editing ``outputs'
224
191
            (load ess-object-name-db-file)
225
192
          (error
226
193
           ;;(message "%s does not exist.  Consider running ess-create-object-name-db."
227
 
                ;;    ess-object-name-db-file)
 
194
                ;;    ess-object-name-db-file)
228
195
;;            (ding)
229
196
              (sit-for 1))))))
230
197
 
233
200
 ; Buffer local customization stuff
234
201
 
235
202
;; Parse a line into its constituent parts (words separated by
236
 
;; whitespace).    Return a list of the words.
 
203
;; whitespace).    Return a list of the words.
237
204
;; Taken from rlogin.el, from the comint package, from XEmacs 20.3.
238
205
(defun ess-line-to-list-of-words (line)
239
206
  (let ((list nil)
240
207
        (posn 0))
241
 
        ;; (match-data (match-data)))
 
208
        ;; (match-data (match-data)))
242
209
    (while (string-match "[^ \t\n]+" line posn)
243
210
      (setq list (cons (substring line (match-beginning 0) (match-end 0))
244
 
                       list))
 
211
                       list))
245
212
      (setq posn (match-end 0)))
246
213
    (store-match-data (match-data))
247
214
    (nreverse list)))
249
216
(defun ess-write-to-dribble-buffer (text)
250
217
  "Write TEXT to dribble buffer."
251
218
  (save-excursion
 
219
    (if (not (buffer-live-p ess-dribble-buffer))
 
220
        ;; ESS dribble buffer must be re-created.
 
221
        (setq ess-dribble-buffer (get-buffer-create "*ESS*")))
252
222
    (set-buffer ess-dribble-buffer)
253
223
    (goto-char (point-max))
254
224
    (insert-string text)))
258
228
  (if buf (set-buffer buf))
259
229
  (mapcar (lambda (pair)
260
230
            (make-local-variable (car pair))
261
 
            (set (car pair) (eval (cdr pair))))
262
 
          alist)
 
231
            (if (cdr pair)
 
232
                (set (car pair) (eval (cdr pair)))))
 
233
          alist)
263
234
  (ess-write-to-dribble-buffer
264
235
   (format "(ess-setq-vars-LOCAL): language=%s, dialect=%s, buf=%s, comint..echoes=%s, comint..sender=%s\n"
265
 
           ess-language ess-dialect buf comint-process-echoes comint-input-sender)))
 
236
           ess-language ess-dialect buf comint-process-echoes comint-input-sender)))
266
237
 
267
238
(defun ess-setq-vars-default (alist &optional buf)
268
239
  "Set language variables from ALIST, in buffer BUF, if desired."
269
240
  (ess-write-to-dribble-buffer
270
241
   (format "ess-setq-vars-default 0: ess-language=%s, -dialect=%s, buf=%s, comint..echoes=%s, comint..sender=%s\n"
271
 
           ess-language ess-dialect buf comint-process-echoes comint-input-sender))
 
242
           ess-language ess-dialect buf comint-process-echoes comint-input-sender))
272
243
  (if buf (set-buffer buf))
273
244
  (mapcar (lambda (pair)
274
 
            (set-default (car pair) (eval (cdr pair))))
275
 
          alist)
 
245
            (set-default (car pair) (eval (cdr pair))))
 
246
          alist)
276
247
  (ess-write-to-dribble-buffer
277
248
   (format "ess-setq-vars-default 1: ess-language=%s, -dialect=%s, buf=%s, comint..echoes=%s, comint..sender=%s\n"
278
 
           ess-language ess-dialect buf comint-process-echoes comint-input-sender))
 
249
           ess-language ess-dialect buf comint-process-echoes comint-input-sender))
279
250
)
280
251
 
281
252
;;--- emacs 19.34 compatibility [MM]:
314
285
 
315
286
;; Toby Speight <Toby.Speight@ansa.co.uk>
316
287
;;> ;; untested
317
 
;;> (let ((l R-customize-alist))            ; or whatever
 
288
;;> (let ((l R-customize-alist))            ; or whatever
318
289
;;>   (while l
319
 
;;>     (set (car (car l)) (cdr (car l)))   ; set, not setq!
320
 
;;>     (setq l (cdr l))))
 
290
;;>     (set (car (car l)) (cdr (car l)))   ; set, not setq!
 
291
;;>     (setq l (cdr l))))
321
292
;;
322
293
;;
323
294
;;If they are to be buffer-local, you may need to
324
295
;;
325
 
;;>     ;; untested
326
 
;;>     (set (make-local-variable (car (car l))) (cdr (car l)))
 
296
;;>     ;; untested
 
297
;;>     (set (make-local-variable (car (car l))) (cdr (car l)))
327
298
;;
328
299
 
329
300
 
330
301
;; Erik Naggum <erik@naggum.no>
331
302
;;
332
303
;;(mapcar (lambda (pair) (set (car pair) (cdr pair)))
333
 
;;        R-customize-alist)
 
304
;;        R-customize-alist)
334
305
;;
335
306
;;if you want to evaluate these things along the way, which it appears that
336
307
;;you want, try:
337
308
;;
338
309
;;(mapcar (lambda (pair) (set (car pair) (eval (cdr pair))))
339
 
;;        R-customize-alist)
 
310
;;        R-customize-alist)
340
311
 
341
312
;; jsa@alexandria.organon.com (Jon S Anthony)
342
313
;;(mapcar #'(lambda (x)
344
315
;;      R-customize-alist)
345
316
 
346
317
 
347
 
;; The following code causes the *ESS* buffer to be recreated (if necessary)
348
 
;; before it is used; Jeff Mincy <jeff@delphioutpost.com>, 27 Jul 2001.
349
 
(defadvice ess-write-to-dribble-buffer
350
 
  (before get-dribble-buffer first activate)
351
 
  (setq ess-dribble-buffer (get-buffer-create "*ESS*")))
352
318
 
353
319
; Run load hook and provide package
354
320
 
360
326
 
361
327
;;; This file is automatically placed in Outline minor mode.
362
328
;;; The file is structured as follows:
363
 
;;; Chapters:     ^L ;
364
 
;;; Sections:    ;;*;;
 
329
;;; Chapters:     ^L ;
 
330
;;; Sections:    ;;*;;
365
331
;;; Subsections: ;;;*;;;
366
 
;;; Components:  defuns, defvars, defconsts
367
 
;;;              Random code beginning with a ;;;;* comment
 
332
;;; Components:  defuns, defvars, defconsts
 
333
;;;              Random code beginning with a ;;;;* comment
368
334
 
369
335
;;; Local variables:
370
336
;;; mode: emacs-lisp