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

« back to all changes in this revision

Viewing changes to lisp/essdsp6w.el

  • Committer: Bazaar Package Importer
  • Author(s): Camm Maguire
  • Date: 2004-11-11 00:51:43 UTC
  • mfrom: (1.1.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20041111005143-wv1cih1h04xyrxrb
Tags: 5.2.3-3
* repair broken replace-regexp-in-string -> ess-replace-regexp-in-string
  patch
* expand autoload functionality in emacsen-startup

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
;;; essdsp6w.el --- S-PLUS 6.x  for Windows customization
2
 
;;; copied and edited from essd-sp4.el
3
 
;;; Richard M. Heiberger, April 2001
 
2
 
 
3
;;; copied and edited from essd-sp4.el - Richard M. Heiberger, April 2001
4
4
 
5
5
;; Copyright (C) 2001 Richard M. Heiberger <rmh@sbm.temple.edu>
 
6
;; Copyright (C) 2002--2004 A.J. Rossini, Rich M. Heiberger, Martin
 
7
;;      Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
6
8
 
7
 
;; Author: Richard M. Heiberger <rmh@sbm.temple.edu>
8
 
;; Maintainer: Richard M. Heiberger <rmh@sbm.temple.edu>
 
9
;; Original Author: Richard M. Heiberger <rmh@sbm.temple.edu>
9
10
;; Created: April 2001
10
 
;; Modified: $Date: 2002/06/24 13:24:12 $
11
 
;; Version: $Revision: 5.16 $
12
 
;; RCS: $Id: essdsp6w.el,v 5.16 2002/06/24 13:24:12 maechler Exp $
13
 
;;
 
11
;; Maintainers: ESS-core <ESS-core@stat.math.ethz.ch>
 
12
 
14
13
;; Keywords: start up, configuration.
15
14
 
16
15
;; This file is part of ESS.
48
47
  "Name of 'dialect' for S-PLUS 6.x.
49
48
Easily changeable in a user's `.emacs'.")
50
49
 
 
50
(defvar inferior-S+6-start-args " "
 
51
  "Default is empty.  Can be used for license manager information, for example
 
52
`(setq inferior-S+6-start-args \" S_ELMHOST=\\\\\\\\@123.456.789.012  ELMTIMEOUT=60 \")'."
 
53
;; (setq inferior-S+6-start-args " S_ELMHOST=\\\\@123.456.789.012  ELMTIMEOUT=60 ")  ;; use this line as the model for your site-start.el
 
54
)
 
55
 
 
56
(defvar inferior-Sqpe-start-args " "
 
57
  "Default is empty.  Can be used for license manager information, for example
 
58
`(setq inferior-Sqpe-start-args \" S_ELMHOST=@123.456.789.012  ELMTIMEOUT=60 \")'."
 
59
;; (setq inferior-Sqpe-start-args " S_ELMHOST=@123.456.789.012  ELMTIMEOUT=60 ")  ;; use this line as the model for your site-start.el
 
60
)
 
61
 
51
62
(defvar inferior-S+6-multipleinstances "/MULTIPLEINSTANCES"
52
63
  "Default \"/MULTIPLEINSTANCES\" opens up a new instance of S+6 in a
53
64
GUI window and connects it to the '(ddeESS [S+6])' window.  The
59
70
    (ess-language                  . "S")
60
71
    (ess-dialect                   . S+6-dialect-name)
61
72
    (ess-suffix                    . "S")
62
 
    (ess-dump-filename-template    . (concat (user-login-name)
63
 
                                             ".%s."
64
 
                                             ess-suffix))
65
73
    (ess-mode-editing-alist        . S-editing-alist)
66
74
    (ess-mode-syntax-table         . S-syntax-table)
67
75
    (ess-help-sec-regex            . ess-help-S+-sec-regex)
68
76
    (ess-help-sec-keys-alist       . S+-help-sec-keys-alist)
69
 
    (ess-loop-timeout              . 500000 )
 
77
    (ess-loop-timeout              . ess-S-loop-timeout)
70
78
    (ess-object-name-db-file       . "ess-sp6-namedb.el" )
71
79
    (ess-retr-lastvalue-command
72
80
     . ".Last.value <- get(\".ess.lvsave\",frame=0)\n")
86
94
    (inferior-ess-start-args       . (concat
87
95
                                      inferior-S+6-multipleinstances
88
96
                                      " "
 
97
                                      inferior-S+6-start-args
 
98
                                      " "
89
99
                                      inferior-S+6-print-command
90
100
                                      " S_PROJ="
91
101
                                      (directory-file-name default-directory))
97
107
    )
98
108
 "Variables to customize for S+6")
99
109
 
 
110
 
100
111
(defvar Sqpe+6-customize-alist
101
112
  '((ess-local-customize-alist     . 'Sqpe+6-customize-alist)
102
113
    (ess-language                  . "S")
103
114
    (ess-dialect                   . S+6-dialect-name)
104
115
    (ess-suffix                    . "S")
105
 
    (ess-dump-filename-template    . (concat (user-login-name)
106
 
                                             ".%s."
107
 
                                             ess-suffix))
108
116
    (ess-mode-editing-alist        . S-editing-alist)
109
117
    (ess-mode-syntax-table         . S-syntax-table)
110
118
    (ess-help-sec-regex            . ess-help-S+-sec-regex)
123
131
    (inferior-ess-secondary-prompt . "+ ?")
124
132
    (comint-use-prompt-regexp-instead-of-fields . t) ;; emacs 21 and up
125
133
    (inferior-ess-start-file       . nil) ;"~/.ess-S+6")
126
 
    (inferior-ess-start-args       . "ALWAYS_PROMPT=X") ;;workaround for bug in S-Plus 6 for Windows
 
134
    (inferior-ess-start-args       . (concat
 
135
                                      "ALWAYS_PROMPT=X"  ;;workaround for bug in S-Plus 6 for Windows
 
136
                                      " "
 
137
                                      inferior-Sqpe-start-args ;; license manager for example
 
138
                                      ))
127
139
    (ess-STERM  . "iESS")
128
140
    (ess-editor . S-editor)
129
141
    (ess-pager  . S-pager)
171
183
                         "/../../versions") t))
172
184
    (toggle-read-only 1)
173
185
    (forward-line)
174
 
    (if (not (search-backward "6.1" (point-min) t))
 
186
    (if (not (search-backward-regexp "6.[1-9]" (point-min) t))
175
187
        (if (search-backward "6.0" (point-min) t)
176
188
            (error "S-Plus 6.0 for Microsoft Windows has a bug that
177
189
prevents it from being started by emacs.  Instead, you must start it
178
190
by double-clicking an icon.  Then you can connect to it with
179
 
`S+6-existing'.  You should consider upgrading to S-Plus 6.1.")
 
191
`S+6-existing'.  You should consider upgrading to S-Plus 6.1 or higher.")
180
192
          (error "The emacs variable `inferior-S+6-program-name' does
181
 
not point to S-Plus 6.  Please add `splus61/cmd' to your `exec-path' or
 
193
not point to S-Plus 6.  Please add `splus6?/cmd'
 
194
(expand the `?' to match your setup) to your `exec-path' or
182
195
specify the complete path to `Splus.exe' in the variable
183
196
`inferior-S+6-program-name' in your `.emacs' file."))))
184
197
  (S+6-initiate proc-name)) ;; normal start
338
351
  (interactive)
339
352
  (setq ess-customize-alist S+6-customize-alist)
340
353
  (ess-mode S+6-customize-alist proc-name)
341
 
  (if ess-S-use-imenu (ess-imenu-R)))
 
354
  (if ess-imenu-use-S (ess-imenu-R)))
342
355
 
343
356
 
344
357
(defun S+6-transcript-mode ()
481
494
    (toggle-read-only t)                ; restore ESS buffer to be read-only
482
495
    ))
483
496
 
 
497
(defun ess-sqpe-versions-create ()
 
498
  "Generate the `M-x splusxy' functions for starting other versions of
 
499
Sqpe.  See `ess-sqpe-versions' for strings that determine which
 
500
functions are created.  This works by creating a temp buffer where the
 
501
template function `Sqpe+template' is edited by replacing the string
 
502
'Sqpe+template' by the version name.  The list of functions actually
 
503
created appears in the *ESS* buffer.
 
504
 
 
505
The result `ess-sqpe-versions-created' will store a list of the new
 
506
Sqpe defuns, if any, that were created.  The defuns will normally be
 
507
placed on the menubar upon ESS initialisation."
 
508
  (let ((beg)
 
509
        (versions)
 
510
        (version)
 
511
        (eval-buf (get-buffer-create "*ess-temp-sqpe-evals*"))
 
512
        (ess-sqpe-versions-created)
 
513
        )
 
514
    ;;
 
515
    (save-excursion
 
516
      (set-buffer eval-buf)
 
517
      ;; clear the buffer.
 
518
      (delete-region (point-min) (point-max))
 
519
 
 
520
      ;; Find which versions of Sqpe we want.
 
521
      (setq versions (ess-uniq-list ess-SHOME-versions))
 
522
      ;; Iterate over each string in VERSIONS, creating a new defun each time.
 
523
      (while versions
 
524
        (setq version (car versions)
 
525
              versions (cdr versions))
 
526
        (if (file-executable-p version)
 
527
            (progn
 
528
              (setq beg (point))
 
529
              (prin1 (symbol-function 'Sqpe+template) eval-buf)
 
530
              (insert "\n\n")
 
531
              (goto-char beg)
 
532
              (while (search-forward "lambda" nil t 1)
 
533
                (replace-match
 
534
                 (concat "defun " (file-name-nondirectory version))
 
535
                 t t))
 
536
              (while (search-forward "ess-SHOME" nil t)
 
537
                (replace-match version t t))
 
538
              (goto-char (point-max))
 
539
              (setq ess-sqpe-versions-created
 
540
                    (cons (file-name-nondirectory version)
 
541
                          ess-sqpe-versions-created))
 
542
              (ess-write-to-dribble-buffer
 
543
               (format
 
544
                "(Sqpe): ess-sqpe-versions-create making M-x defun %s for %s \n"
 
545
                (file-name-nondirectory version) version))
 
546
              )))
 
547
      ;; buffer has now been created with defuns, so eval them!
 
548
      (eval-buffer)
 
549
      (kill-buffer eval-buf))
 
550
    ess-sqpe-versions-created))
 
551
 
 
552
;; template function used by ess-sqpe-versions-create
 
553
(defun Sqpe+template (&optional proc-name)
 
554
  "Call 'Sqpe' from 'S-PLUS for Windows ess-SHOME',
 
555
the 'Real Thing'  from StatSci.
 
556
This function was generated by `ess-sqpe-versions-create'."
 
557
  (interactive)
 
558
  (setq ess-customize-alist Sqpe+6-customize-alist)
 
559
  (let* ((shome-old (getenv "SHOME"))
 
560
         (inferior-Sqpe+6-SHOME-name "ess-SHOME")
 
561
         (inferior-Sqpe+6-program-name (concat "ess-SHOME" "/cmd/sqpe.exe")))
 
562
    (setenv "SHOME" "ess-SHOME")
 
563
    (ess-write-to-dribble-buffer
 
564
     (format "\n(Sqpe+template): ess-dialect=%s, buf=%s\n" ess-dialect
 
565
             (current-buffer)))
 
566
    (setq ess-customize-alist    ; change inferior-ess-primary-prompt
 
567
          (append ess-customize-alist
 
568
                  '((inferior-ess-primary-prompt   . "^"))))
 
569
    (inferior-ess)
 
570
    (setq ess-customize-alist Sqpe+6-customize-alist) ; restore i-e-p-p in alist
 
571
    (ess-setq-vars-local ess-customize-alist) ; restore i-e-p-p in buffer
 
572
    (setq inferior-ess-prompt           ; define with correct i-e-p-p
 
573
          ;; Do not anchor to bol with `^'       ; (copied from ess-inf.el)
 
574
          (concat "\\("
 
575
                  inferior-ess-primary-prompt
 
576
                  "\\|"
 
577
                  inferior-ess-secondary-prompt
 
578
                  "\\)"))
 
579
    (setq comint-prompt-regexp (concat "^" inferior-ess-prompt))
 
580
                                        ; define with correct i-e-p-p
 
581
    (setq comint-input-sender 'inferior-ess-input-sender)
 
582
    (add-hook 'comint-output-filter-functions 'shell-strip-ctrl-m nil t)
 
583
    (goto-char (point-max))
 
584
    (insert "options(interactive=T)")
 
585
    (inferior-ess-send-input)
 
586
    (setq mode-name "iESS(Sqpe)")
 
587
    ;;  (ess-eval-linewise inferior-S+6-editor-pager-command)
 
588
    (if inferior-ess-language-start
 
589
        (ess-eval-linewise inferior-ess-language-start))
 
590
    (setenv "SHOME" shome-old)))
 
591
 
 
592
 
484
593
 ; Provide package
485
594
 
486
595
(provide 'essdsp6w)