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

« back to all changes in this revision

Viewing changes to lisp/essl-bug.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
;;; essl-bug.el -- ESS BUGS customization
2
2
 
3
3
;; Copyright (C) 2001 Rodney Sparapani
 
4
;; Copyright (C) 2002--2004 Free Software Foundation, Inc.
 
5
;; Copyright (C) 2002--2004 A.J. Rossini, Rich M. Heiberger, Martin
 
6
;;      Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
4
7
 
5
 
;; Author: Rodney Sparapani <rsparapa@mcw.edu>
6
 
;; Maintainer: A.J. Rossini <rossini@biostat.washington.edu>
 
8
;; Original Author: Rodney Sparapani <rsparapa@mcw.edu>
7
9
;; Created: 27 February 2001
8
 
;; Modified: $Date: 2002/01/24 15:00:44 $
9
 
;; Version: $Revision: 1.20 $
10
 
;; RCS: $Id: essl-bug.el,v 1.20 2002/01/24 15:00:44 rsparapa Exp $/ini
 
10
;; Maintainers: ESS-core <ESS-core@stat.math.ethz.ch>
11
11
 
12
12
;; Keywords: BUGS, bugs, BACKBUGS, backbugs.
13
13
 
46
46
    )
47
47
)
48
48
 
49
 
(defcustom ess-bugs-batch-method 
50
 
  (if ess-microsoft-p 
 
49
(defgroup ess-bugs nil
 
50
  "ESS: BUGS."
 
51
  :group 'ess
 
52
  :prefix "ess-")
 
53
 
 
54
(defcustom ess-bugs-batch-method
 
55
  (if ess-microsoft-p
51
56
    (if (w32-shell-dos-semantics) 'ms-dos 'sh)
52
57
    (if (equal system-type 'Apple-Macintosh) 'apple-script 'sh))
53
58
  "Method used by `ess-bugs-batch'.
63
68
 
64
69
Unix users will get 'sh by default.
65
70
 
66
 
Users whose default is not 'sh, but are accessing a remote machine with 
 
71
Users whose default is not 'sh, but are accessing a remote machine with
67
72
`telnet', `rlogin', or `ssh', should have the following in ~/.emacs
68
73
   (setq-default ess-bugs-batch-method 'sh)"
69
74
    :group 'ess-bugs
70
75
)
71
76
 
72
 
(defcustom ess-bugs-batch-command "backbugs"
73
 
;;    (convert-standard-filename 
74
 
;;      (concat ess-lisp-directory "/../etc/" 
75
 
;;          (if (w32-shell-dos-semantics) "backbugs.bat" "backbugs")))
76
 
"*ESS[BUGS]:  Set to the name of the batch BUGS script that comes with ESS.  
77
 
It allows the user to modify settings in a cross-platform manner.  Make sure 
78
 
it is in your PATH."
79
 
    :group 'ess-bugs
80
 
    :type  'string
81
 
)
82
 
 
83
 
(defcustom ess-bugs-batch-post-command 
84
 
    (if (equal ess-bugs-batch-method 'sh) "&" " ") 
85
 
    "*ESS[BUGS]:  Modifiers at the end of the batch BUGS command line."
86
 
    :group 'ess-bugs
87
 
    :type  'string
88
 
)
89
 
 
90
 
(defcustom ess-bugs-batch-pre-command 
91
 
    (if (equal ess-bugs-batch-method 'sh) "nohup" 
 
77
(defcustom ess-bugs-batch-version "0.6"
 
78
  "*ESS[BUGS]: The batch BUGS version to use."
 
79
    :group 'ess-bugs
 
80
    :type  'string
 
81
)
 
82
 
 
83
;; SJE Thu 13 May 2004
 
84
;; The "backbugs" scripts can be found in ess-etc-directory, so maybe we
 
85
;; can use ess-etc-directory here too.
 
86
(defcustom ess-bugs-batch-command
 
87
    (if (equal ess-bugs-batch-version "0.6") "backbugs" "backbug5")
 
88
  "*ESS[BUGS]: The name of the command to run BUGS in batch mode.
 
89
 
 
90
Set to the name of the batch BUGS script that comes with ESS or
 
91
to the name of BUGS command. Make sure it is in your PATH or
 
92
add path to the command name."
 
93
    :group 'ess-bugs
 
94
    :type  'string
 
95
)
 
96
 
 
97
(defcustom ess-bugs-batch-post-command
 
98
    (if (equal ess-bugs-batch-method 'sh) "&" " ")
 
99
    "*ESS[BUGS]: Modifiers at the end of the batch BUGS command line."
 
100
    :group 'ess-bugs
 
101
    :type  'string
 
102
)
 
103
 
 
104
(defcustom ess-bugs-batch-pre-command
 
105
    (if (equal ess-bugs-batch-method 'sh) "test -f nohup.out && rm -f nohup.out || true; nohup"
92
106
        (if ess-microsoft-p "start"))
93
 
    "*ESS[BUGS]:  Modifiers at the beginning of the batch BUGS command line."
 
107
    "*ESS[BUGS]: Modifiers at the beginning of the batch BUGS command line."
94
108
    :group 'ess-bugs
95
109
    :type  'string
96
110
)
97
111
 
98
112
(defcustom ess-bugs-default-bins "32"
99
 
"ESS[BUGS]:  number of bins to use in the Griddy algorithm (Metropolis sampling)."
 
113
"ESS[BUGS]: Number of bins to use in the Griddy algorithm (Metropolis sampling)."
100
114
    :group 'ess-bugs
101
115
    :type  'string
102
116
)
103
117
 
104
118
(defcustom ess-bugs-default-burn-in "500"
105
 
    "ESS[BUGS]:  burn-in iterations to discard."
 
119
    "ESS[BUGS]: Burn-in iterations to discard."
106
120
    :group 'ess-bugs
107
121
    :type  'string
108
122
)
109
123
 
110
124
(defcustom ess-bugs-default-update "1000"
111
 
    "ESS[BUGS]:  iterations to store."
 
125
    "ESS[BUGS]: Iterations to store."
112
126
    :group 'ess-bugs
113
127
    :type  'string
114
128
)
115
129
 
116
130
(defcustom ess-bugs-default-checkpoint "100"
117
 
    "ESS[BUGS]:  make a snapshot every this many iterations."
 
131
    "ESS[BUGS]: Make a snapshot every this many iterations."
118
132
    :group 'ess-bugs
119
133
    :type  'string
120
134
)
121
135
 
122
136
(defvar ess-bugs-file "."
123
 
   "ESS[BUGS]:  BUGS file with PATH.")
 
137
   "ESS[BUGS]: BUGS file with PATH.")
124
138
 
125
139
(defvar ess-bugs-file-root "."
126
 
   "ESS[BUGS]:  Root of BUGS file.")
 
140
   "ESS[BUGS]: Root of BUGS file.")
127
141
 
128
142
(defvar ess-bugs-file-suffix "."
129
 
   "ESS[BUGS]:  Suffix of BUGS file.")
 
143
   "ESS[BUGS]: Suffix of BUGS file.")
130
144
 
131
145
(defvar ess-bugs-file-dir "."
132
 
   "ESS[BUGS]:  Directory of BUGS file.")
 
146
   "ESS[BUGS]: Directory of BUGS file.")
133
147
 
134
148
(defvar ess-bugs-file-data "..."
135
 
   "ESS[BUGS]:  BUGS data file.")
 
149
   "ESS[BUGS]: BUGS data file.")
136
150
 
137
151
(defcustom ess-bugs-inits-suffix ".in"
138
 
   "ESS[BUGS]:  BUGS init file suffix."
 
152
   "ESS[BUGS]: BUGS init file suffix."
139
153
    :group 'ess-bugs
140
154
    :type  'string
141
155
)
142
156
 
143
157
(defcustom ess-bugs-data-suffix ".dat"
144
 
   "ESS[BUGS]:  BUGS data file suffix."
 
158
   "ESS[BUGS]: BUGS data file suffix."
145
159
    :group 'ess-bugs
146
160
    :type  'string
147
161
)
148
162
 
149
 
(defcustom ess-bugs-suffix-regexp 
 
163
(defcustom ess-bugs-suffix-regexp
150
164
    (concat "[.]\\([bB][oOuU][gG]\\|[bB][mM][dD]\\|"
151
 
        (if ess-bugs-inits-suffix (concat 
 
165
        (if ess-bugs-inits-suffix (concat
152
166
            "\\|" (downcase ess-bugs-inits-suffix) "\\|" (upcase ess-bugs-inits-suffix)))
153
 
        (if ess-bugs-data-suffix (concat 
 
167
        (if ess-bugs-data-suffix (concat
154
168
            "\\|" (downcase ess-bugs-data-suffix) "\\|" (upcase ess-bugs-data-suffix)))
155
169
        "\\)")
156
 
    "*Regular expression for BUGS suffixes."
 
170
    "*ESS[BUGS]: Regular expression for BUGS suffixes."
157
171
    :group 'ess-bugs
158
172
    :type  'string
159
173
)
160
174
 
 
175
(defcustom ess-bugs-mode-hook nil
 
176
    "*ESS[BUGS]: List of functions to call upon entering mode."
 
177
    :group 'ess-bugs
 
178
    :type 'hook)
 
179
 
161
180
(defvar ess-bugs-monitor-vars " "
162
 
    "ESS[BUGS]:  List of BUGS variables to be written out to a file.")
 
181
    "ESS[BUGS]: List of BUGS variables to be written out to a file.")
163
182
 
164
183
(defvar ess-bugs-stats-vars " "
165
 
    "ESS[BUGS]:  List of BUGS variables to be summarized with statistics.")
166
 
 
167
 
(defvar ess-bugs-mode-hook nil 
168
 
    "ESS[BUGS]:  List of functions to call upon entering mode.")
169
 
 
 
184
    "ESS[BUGS]: List of BUGS variables to be summarized with statistics.")
170
185
 
171
186
(defvar ess-bugs-mode-map nil
172
 
   "ESS[BUGS]:  Keymap for mode.")
 
187
   "ESS[BUGS]: Keymap for mode.")
173
188
 
174
189
(if ess-bugs-mode-map nil
175
190
    (setq ess-bugs-mode-map (make-keymap))
179
194
 
180
195
 
181
196
(defvar ess-bugs-syntax-table nil
182
 
   "ESS[BUGS]:  Syntax table for mode.")
 
197
   "ESS[BUGS]: Syntax table for mode.")
183
198
 
184
199
(if ess-bugs-syntax-table nil
185
200
    (setq ess-bugs-syntax-table (make-syntax-table))
224
239
        ;;(cons (concat "\\<\\(c\\|list\\)[ \t\n]*(")
225
240
        ;;                              font-lock-function-name-face)
226
241
    )
227
 
    "ESS[BUGS]:  Font lock keywords."
 
242
    "ESS[BUGS]: Font lock keywords."
228
243
)
229
244
 
230
245
 
231
246
(defun ess-bugs-file ()
232
 
"ESS[BUGS]:  Set `ess-bugs-file', `ess-bugs-file-root', `ess-bugs-file-suffix' and `ess-bugs-file-dir'."
233
 
   (interactive)
234
 
 
 
247
"ESS[BUGS]: Set internal variables dealing with BUGS files.
 
248
Set `ess-bugs-file', `ess-bugs-file-root', `ess-bugs-file-suffix'
 
249
and `ess-bugs-file-dir'."
235
250
   (let ((ess-bugs-temp-string (buffer-name)))
236
251
        (setq ess-bugs-file (expand-file-name ess-bugs-temp-string))
237
 
        (setq ess-bugs-file-dir 
 
252
        (setq ess-bugs-file-dir
238
253
            (convert-standard-filename (file-name-directory ess-bugs-file)))
239
 
        (setq ess-bugs-file-root 
 
254
        (setq ess-bugs-file-root
240
255
            (file-name-nondirectory (file-name-sans-extension ess-bugs-file)))
241
256
 
242
 
        (if (fboundp 'file-name-extension) 
 
257
        (if (fboundp 'file-name-extension)
243
258
            (setq ess-bugs-file-suffix (file-name-extension ess-bugs-temp-string))
244
259
            ;;else
245
260
            (setq ess-bugs-file-suffix (car (last (split-string ess-bugs-temp-string "[.]")))))
246
261
 
247
 
        (setq ess-bugs-file-suffix 
 
262
        (setq ess-bugs-file-suffix
248
263
            (downcase (car (split-string (concat "." ess-bugs-file-suffix) "[<]"))))
249
264
 
250
265
        (setq ess-bugs-file (concat ess-bugs-file-dir ess-bugs-file-root ess-bugs-file-suffix))
253
268
 
254
269
 
255
270
(defun ess-switch-to-suffix (suffix)
256
 
   "ESS:  Switch to file with suffix."
 
271
   "ESS: Switch to file with suffix."
257
272
   (find-file (concat ess-bugs-file-dir ess-bugs-file-root suffix))
258
273
 
259
274
   (if (equal 0 (buffer-size)) (progn
269
284
            (insert "    for (i in 1:N) {\n    \n")
270
285
            (insert "    }\n")
271
286
            (insert "}\n")
272
 
        ))      
 
287
        ))
273
288
 
274
 
        (if (equal ".bmd" suffix) (progn
275
 
            (insert (concat "compile(\"" ess-bugs-file-dir ess-bugs-file-root ".bug\")\n"))
276
 
            (insert (concat "save(\"" ess-bugs-file-dir ess-bugs-file-root ".in0\")\n"))
 
289
        (if (equal ".bmd" suffix) (let
 
290
            ((tmp-bugs-file-dir (if (equal ess-bugs-batch-version "0.6") ess-bugs-file-dir)))
 
291
            (insert (concat "compile(\"" tmp-bugs-file-dir ess-bugs-file-root ".bug\")\n"))
 
292
            (insert (concat "save(\"" tmp-bugs-file-dir ess-bugs-file-root ".in0\")\n"))
277
293
            (insert (concat "update(" ess-bugs-default-burn-in ")\n"))
278
 
            (insert (concat "save(\"" ess-bugs-file-dir ess-bugs-file-root ".in1\")\n"))
 
294
            (insert (concat "save(\"" tmp-bugs-file-dir ess-bugs-file-root ".in1\")\n"))
279
295
            (insert "#%MONITOR\n\n#%MONITOR\n")
280
 
            (insert (concat "checkpoint(" ess-bugs-default-checkpoint ")\n"))
 
296
            (if (equal ess-bugs-batch-version "0.6")
 
297
                (insert (concat "checkpoint(" ess-bugs-default-checkpoint ")\n")))
281
298
            (insert (concat "update(" ess-bugs-default-update ")\n"))
282
 
            (insert (concat "save(\"" ess-bugs-file-dir ess-bugs-file-root ".in2\")\n"))
 
299
            (insert (concat "save(\"" tmp-bugs-file-dir ess-bugs-file-root ".in2\")\n"))
283
300
            (insert "#%STATS\n\n#%STATS\n")
284
301
            (insert "q()\n")
285
302
            ;;(insert "q(\"" ess-bugs-file-dir ess-bugs-file-root ".bog\")\n")
286
303
        ))
287
304
    ))
288
305
)
289
 
                
 
306
 
290
307
(defun ess-exit-notify-sh (string)
291
308
  "Detect completion or failure of submitted job and notify the user."
292
309
  (let* ((exit-done "\\[[0-9]+\\]\\ *\\+*\\ *\\(Exit\\|Done\\).*$")
294
311
    (if beg (message (substring string beg (match-end 0))))))
295
312
 
296
313
(defun ess-bugs-next-action ()
297
 
   "ESS[BUGS]:  Perform the appropriate next action."
 
314
   "ESS[BUGS]: Perform the appropriate next action."
298
315
   (interactive)
299
316
   (ess-bugs-file)
300
317
 
301
318
   (if (equal ".bug" ess-bugs-file-suffix) (ess-bugs-na-bug))
302
 
   ;;else 
 
319
   ;;else
303
320
   (if (equal ".bmd" ess-bugs-file-suffix) (ess-bugs-na-bmd))
304
321
)
305
322
 
306
323
(defun ess-bugs-na-bmd ()
307
 
    "ESS[BUGS]:  Perform the Next-Action for .bmd."
 
324
    "ESS[BUGS]: Perform the Next-Action for .bmd."
308
325
 
309
326
    (save-buffer)
310
327
    (shell)
311
328
 
312
329
    (if (w32-shell-dos-semantics)
313
 
        (if (string-equal ":" (substring ess-bugs-file 1 2)) 
 
330
        (if (string-equal ":" (substring ess-bugs-file 1 2))
314
331
            (progn
315
332
                (insert (substring ess-bugs-file 0 2))
316
333
                (comint-send-input)
322
339
        (comint-send-input)
323
340
 
324
341
        (insert (concat ess-bugs-batch-pre-command " " ess-bugs-batch-command " "
325
 
            ess-bugs-default-bins " " ess-bugs-file-root " " ess-bugs-file " " 
326
 
            ess-bugs-batch-post-command))
 
342
            (if (equal ess-bugs-batch-version "0.6") ess-bugs-default-bins)
 
343
             " " ess-bugs-file-root " "
 
344
            (if (equal ess-bugs-batch-version "0.6")
 
345
                 ess-bugs-file (concat ess-bugs-file-root ".bmd"))
 
346
             " " ess-bugs-batch-post-command))
327
347
 
328
348
        (comint-send-input)
329
349
)
330
350
 
331
 
   
 
351
 
332
352
(defun ess-bugs-na-bug ()
333
 
    "ESS[BUGS]:  Perform Next-Action for .bug"
 
353
    "ESS[BUGS]: Perform Next-Action for .bug"
334
354
 
335
355
        (if (equal 0 (buffer-size)) (ess-switch-to-suffix ".bug")
336
 
            (save-excursion 
 
356
            (save-excursion (let
 
357
                ((tmp-bugs-file-dir (if (equal ess-bugs-batch-version "0.6") ess-bugs-file-dir)))
337
358
                (goto-char (point-min))
338
359
 
339
 
                (if (search-forward "%MODEL" nil t) 
 
360
                (if (search-forward "%MODEL" nil t)
340
361
                    (replace-match ess-bugs-file-root t t))
341
362
 
342
363
                (if (search-forward "%DATA" nil t) (progn
343
 
                    (setq ess-bugs-file-data 
344
 
                        (concat ess-bugs-file-dir ess-bugs-file-root ess-bugs-data-suffix))
 
364
                    (setq ess-bugs-file-data
 
365
                        (concat tmp-bugs-file-dir ess-bugs-file-root ess-bugs-data-suffix))
345
366
                    (replace-match ess-bugs-file-data t t))
346
367
                ;;else
347
368
                (if (search-forward-regexp "data.+in[ \t\n]+\"\\(.*\\)\"" nil t)
350
371
                    (setq ess-bugs-file-data "...")
351
372
                ))
352
373
 
353
 
                (if (search-forward "%INITS" nil t) 
354
 
                    (replace-match 
355
 
                        (concat ess-bugs-file-dir ess-bugs-file-root ess-bugs-inits-suffix) t t))
356
 
 
 
374
                (if (search-forward "%INITS" nil t)
 
375
                    (replace-match
 
376
                        (concat tmp-bugs-file-dir ess-bugs-file-root ess-bugs-inits-suffix) t t))
 
377
 
357
378
                (let ((ess-bugs-temp-string " ")
358
379
                    (ess-bugs-buffer-ptr nil))
359
380
                    (goto-char (point-min))
360
 
                
361
 
                    (if (search-forward-regexp 
 
381
 
 
382
                    (if (search-forward-regexp
362
383
                            "N[ \t]*=[ \t]*[0-9]+[ \t]*;[ \t]*#[ \t]*%N" nil t) (progn
363
384
 
364
385
                        (save-excursion (save-match-data
368
389
                                (set-buffer (create-file-buffer ess-bugs-file-data))
369
390
                                (insert-file-contents ess-bugs-file-data t))
370
391
 
371
 
                            (setq ess-bugs-temp-string 
372
 
                                (concat "N = " 
 
392
                            (setq ess-bugs-temp-string
 
393
                                (concat "N = "
373
394
                                    (int-to-string (count-lines (point-min) (point-max))) ";#%N"))
374
395
                        ))
375
396
 
376
397
                        (replace-match ess-bugs-temp-string t t)
377
398
                    ))
378
 
 
379
399
                )
380
400
 
381
401
                (let (
387
407
 
388
408
                    (goto-char (point-min))
389
409
 
390
 
                    (if (search-forward-regexp "%MONITOR[ \t]+" nil t) 
 
410
                    (if (search-forward-regexp "%MONITOR[ \t]+" nil t)
391
411
                        (setq ess-bugs-search-min (point))
392
412
                    ;;else
393
413
                        (setq ess-bugs-search-min (search-forward "var"))
394
414
                    )
395
415
 
396
416
                    (setq ess-bugs-search-max (search-forward-regexp ";"))
397
 
                    
 
417
 
398
418
                    (goto-char ess-bugs-search-min)
399
419
                    (setq ess-bugs-monitor-vars "")
400
 
                    
 
420
 
401
421
                    (while (search-forward-regexp ess-bugs-search-vars ess-bugs-search-max t)
402
422
 
403
 
                        (setq ess-bugs-monitor-vars 
404
 
                            (concat ess-bugs-monitor-vars "monitor(" 
 
423
                        (setq ess-bugs-monitor-vars
 
424
                            (concat ess-bugs-monitor-vars "monitor("
405
425
                                (match-string 1) (match-string 3) (match-string 4) (match-string 5) ")\n"))
406
426
                    )
407
427
 
408
 
                    (setq ess-bugs-monitor-vars 
 
428
                    (setq ess-bugs-monitor-vars
409
429
                        (concat "#%MONITOR\n" ess-bugs-monitor-vars "#%MONITOR\n"))
410
430
 
411
431
                    (goto-char (point-min))
413
433
                    (if (search-forward-regexp "%STATS[ \t]+" nil t) (progn
414
434
                        (setq ess-bugs-search-min (point))
415
435
                        (setq ess-bugs-search-max (search-forward-regexp ";"))
416
 
                    
 
436
 
417
437
                        (goto-char ess-bugs-search-min)
418
438
                        (setq ess-bugs-stats-vars "")
419
 
                    
 
439
 
420
440
                        (while (search-forward-regexp ess-bugs-search-vars ess-bugs-search-max t)
421
441
 
422
 
                            (setq ess-bugs-stats-vars 
423
 
                                (concat ess-bugs-stats-vars "stats(" 
 
442
                            (setq ess-bugs-stats-vars
 
443
                                (concat ess-bugs-stats-vars "stats("
424
444
                                    (match-string 1) (match-string 3) (match-string 4) (match-string 5) ")\n"))
425
445
                        )
426
446
 
428
448
                    )
429
449
 
430
450
;; replace-in-string may not be available, work-around necessary; see below
431
 
;;                      (setq ess-bugs-stats-vars 
 
451
;;                      (setq ess-bugs-stats-vars
432
452
;;                          (replace-in-string ess-bugs-monitor-vars "#%MONITOR" "#%STATS"))
433
 
;;                      (setq ess-bugs-stats-vars 
 
453
;;                      (setq ess-bugs-stats-vars
434
454
;;                          (replace-in-string ess-bugs-stats-vars "monitor" "stats" t))
435
455
 
436
456
                    ;;else
437
457
                    (setq ess-bugs-stats-vars ess-bugs-monitor-vars)
438
458
 
439
459
                    (while (string-match "#%MONITOR" ess-bugs-stats-vars)
440
 
                        (setq ess-bugs-stats-vars 
 
460
                        (setq ess-bugs-stats-vars
441
461
                            (replace-match "#%STATS" t t ess-bugs-stats-vars)))
442
462
 
443
463
                    (while (string-match "monitor" ess-bugs-stats-vars)
444
 
                        (setq ess-bugs-stats-vars 
 
464
                        (setq ess-bugs-stats-vars
445
465
                            (replace-match "stats" t t ess-bugs-stats-vars)))
446
466
 
447
467
                    )
448
468
                )
449
 
                    
450
 
            )
 
469
 
 
470
            ))
451
471
 
452
472
            (save-buffer)
453
473
            (ess-switch-to-suffix ".bmd")
455
475
    (save-excursion
456
476
        (goto-char (point-min))
457
477
 
458
 
        (if (search-forward-regexp "#%MONITOR\\(.\\|\n\\)*#%MONITOR\n" nil t) 
 
478
        (if (search-forward-regexp "#%MONITOR\\(.\\|\n\\)*#%MONITOR\n" nil t)
459
479
            (replace-match ess-bugs-monitor-vars t))
460
480
 
461
 
        (if (search-forward-regexp "#%STATS\\(.\\|\n\\)*#%STATS\n" nil t) 
 
481
        (if (search-forward-regexp "#%STATS\\(.\\|\n\\)*#%STATS\n" nil t)
462
482
            (replace-match ess-bugs-stats-vars t))
463
483
    )
464
484
 
465
 
        )       
 
485
        )
466
486
)
467
487
 
468
488
 
469
489
(defun ess-bugs-mode ()
470
 
   "ESS[BUGS]:  Major mode for Classic BUGS."
 
490
   "ESS[BUGS]: Major mode for Classic BUGS."
471
491
   (interactive)
472
492
   (kill-all-local-variables)
473
493
   (setq major-mode 'ess-bugs-mode)
478
498
   (setq font-lock-defaults '(ess-bugs-font-lock-keywords nil t))
479
499
   (run-hooks 'ess-bugs-mode-hook)
480
500
 
481
 
   (if (not (w32-shell-dos-semantics)) 
 
501
   (if (not (w32-shell-dos-semantics))
482
502
        (add-hook 'comint-output-filter-functions 'ess-exit-notify-sh))
483
503
)
484
504
 
485
505
 
 
506
 
 
507
;;; ESS[BUGS-Shell] for running BUGS interactively
 
508
(defgroup ess-bugs-shell nil
 
509
  "ESS: BUGS-Shell."
 
510
  :group 'ess-bugs
 
511
  :prefix "ess-")
 
512
 
 
513
(defcustom ess-bugs-shell-buffer-name "BUGS"
 
514
  "*ESS[BUGS-Shell]: The name of the BUGS-Shell buffer."
 
515
  :group 'ess-bugs-shell
 
516
  :type  'string)
 
517
 
 
518
(defcustom ess-bugs-shell-command "bugs"
 
519
  "*ESS[BUGS-Shell]: The name of the command to run BUGS interactively.
 
520
 
 
521
Set to the name of the batch BUGS script that comes with ESS or
 
522
to the name of BUGS command. Make sure it is in your PATH or
 
523
add path to the command name."
 
524
  :group 'ess-bugs-shell
 
525
  :type  'string)
 
526
 
 
527
(defcustom ess-bugs-shell-default-output-file-root "bugs"
 
528
  "*ESS[BUGS-Shell]: Default value for the root of output files."
 
529
  :group 'ess-bugs-shell
 
530
  :type  'string)
 
531
 
 
532
(defcustom ess-bugs-shell-mode-hook nil
 
533
  "*ESS[BUGS-Shell]: List of functions to call upon entering mode."
 
534
  :group 'ess-bugs-shell
 
535
  :type 'hook)
 
536
 
 
537
(defun ess-bugs-shell ()
 
538
  "Create a buffer with BUGS running as a subprocess."
 
539
  (interactive)
 
540
  (require 'shell)
 
541
  (switch-to-buffer (concat "*" ess-bugs-shell-buffer-name "*"))
 
542
  (make-comint ess-bugs-shell-buffer-name ess-bugs-shell-command nil
 
543
               ess-bugs-default-bins ess-bugs-shell-default-output-file-root)
 
544
  (comint-mode)
 
545
  (setq shell-dirtrackp t
 
546
        major-mode 'bugs-shell-mode
 
547
        mode-name "ESS[BUGS-Shell]"
 
548
        comint-prompt-regexp "^Bugs> *")
 
549
   (make-local-variable 'font-lock-defaults)
 
550
   (setq font-lock-defaults '(ess-bugs-font-lock-keywords nil t))
 
551
   (run-hooks 'ess-bugs-shell-mode-hook)
 
552
  )
 
553
 
486
554
(provide 'essl-bug)
487