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

« back to all changes in this revision

Viewing changes to lisp/essl-sas.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-sas.el --- SAS customization
2
2
 
3
 
;; Copyright (C) 1997--2001 Richard M. Heiberger, A. J. Rossini, 
4
 
;;  M. Maechler, Rodney Sparapani
 
3
;; Copyright (C) 1997--2004 A.J. Rossini, Rich M. Heiberger, Martin
 
4
;;      Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
5
5
 
6
 
;; Authors: Richard M. Heiberger <rmh@astro.ocis.temple.edu>,
 
6
;; Original Authors: Richard M. Heiberger <rmh@astro.ocis.temple.edu>,
7
7
;;          A.J. Rossini <rossini@u.washington.edu>,
8
8
;;          Rodney Sparapani <rsparap@mcw.edu>
9
 
;; Maintainer: Richard M. Heiberger <rmh@astro.ocis.temple.edu>,
10
 
;;             Rodney Sparapani <rsparap@mcw.edu>
11
9
;; Created: 20 Aug 1997
12
 
;; Modified: $Date: 2002/01/31 21:57:51 $
13
 
;; Version: $Revision: 5.39 $
14
 
;; RCS: $Id: essl-sas.el,v 5.39 2002/01/31 21:57:51 rsparapa Exp $
15
 
;;
 
10
;; Maintainers: ESS-core <ESS-core@stat.math.ethz.ch>
 
11
 
16
12
;; Keywords: start up, configuration.
17
13
 
18
14
;; This file is part of ESS (Emacs Speaks Statistics).
89
85
  "Toggle Ess-Listing minor mode.
90
86
With arg, turn Ess-Listing minor mode on if arg is positive, off
91
87
otherwise.  Ess-Listing mode is used solely to place an indicator on
92
 
the mode line." 
 
88
the mode line."
93
89
  (interactive "P")
94
90
  (setq ess-listing-minor-mode
95
91
        (if (null arg) (not ess-listing-minor-mode)
109
105
  "Fundamental mode with `ess-listing-minor-mode' and read-only."
110
106
  (interactive)
111
107
  (fundamental-mode)
112
 
  (ess-listing-minor-mode t)
 
108
  (ess-listing-minor-mode 1)
113
109
  (use-local-map sas-mode-local-map)
114
110
  (toggle-read-only t)) ;; to protect the buffer.
115
111
 
116
 
(setq auto-mode-alist (append '(("\\.lst\\'" . sas-listing-mode)) auto-mode-alist))
117
 
(setq auto-mode-alist (append '(("\\.LST\\'" . sas-listing-mode)) auto-mode-alist))
118
 
 
119
112
(fset 'sas-log-mode        'SAS-log-mode)
120
113
(fset 'SAS-transcript-mode 'SAS-log-mode)
121
114
(fset 'sas-transcript-mode 'SAS-log-mode)
138
131
  :type  'boolean)
139
132
 
140
133
;; user can specify the sas program name
141
 
(defcustom sas-program 
 
134
(defcustom sas-program
142
135
  (if (equal system-type 'Apple-Macintosh) "invoke SAS using program file" "sas")
143
136
  "*Command to invoke SAS, default for buffer-local `ess-sas-submit-command'."
144
137
  :group 'ess-sas
155
148
;  :group 'ess-sas
156
149
;  :type  'string)
157
150
 
158
 
(defcustom sas-notify t 
 
151
(defcustom sas-notify t
159
152
  "*Beep and display message when job is done."
160
153
  :group 'ess-sas
161
154
  :type  'boolean)
165
158
  :group 'ess-sas
166
159
  :type  'boolean)
167
160
 
168
 
(defcustom sas-get-options nil 
 
161
(defcustom sas-get-options nil
169
162
  "Options to be passed to SAS in sas-get-dataset."
170
163
  :group 'ess-sas
171
 
  :type  'string)
 
164
  :type '(choice (const nil) string))
172
165
 
173
166
(defcustom sas-get-options-history nil
174
167
  "History list of Options passed to SAS in sas-get-dataset."
185
178
  :group 'ess-sas
186
179
  :type  'boolean)
187
180
 
188
 
(defcustom sas-tmp-libname "_tmp_" 
 
181
(defcustom sas-tmp-libname "_tmp_"
189
182
  "*Libname to use for sas-get-dataset."
190
183
  :group 'ess-sas
191
184
  :type  'string)
193
186
(defcustom sas-file-name nil
194
187
  "*The name of the current sas file."
195
188
  :group 'ess-sas
196
 
  :type  'file)
 
189
  :type '(choice (const nil) file))
197
190
 
198
191
;; The next two are ``the inside of [...] in a regexp'' to be used in
199
192
;; (skip-chars-(for|back)ward SAS-..-chars)
210
203
(defcustom ess-sas-run-make-regexp nil
211
204
  "If you do not want to run make-regexp, then set to nil."
212
205
  :group 'ess-sas
213
 
  :type  'string)
 
206
  :type '(choice (const nil) string))
214
207
 
215
208
(require 'essa-sas)
216
209
 
252
245
      (require 'font-lock)
253
246
 
254
247
      (defvar SAS-mode-font-lock-keywords
255
 
        (if ess-sas-run-make-regexp 
 
248
        (if ess-sas-run-make-regexp
256
249
        (list
257
250
         ;; SAS comments
258
251
         (cons "^[ \t]*%?\\*.*;"                font-lock-comment-face)
378
371
         (cons "^ERROR: .*$"                        font-lock-keyword-face)
379
372
 
380
373
         ;; .log WARNING: messages
381
 
         (cons "^WARNING: .*$"                      font-lock-function-name-face)       
 
374
         (cons "^WARNING: .*$"                      font-lock-function-name-face)
382
375
 
383
376
         ;; SAS comments
384
377
;; /* */ handled by grammar above
385
378
;;       (list "/\\*.*\\*/"                      0  font-lock-comment-face t)
386
 
         (cons "\\(^[0-9]*\\|;\\)[ \t]*%?\\*.*\\(;\\|$\\)" font-lock-comment-face)
 
379
         (cons "\\(^[0-9]*\\|;\\)[ \t]*\\(%?\\*\\|comment\\).*\\(;\\|$\\)" font-lock-comment-face)
387
380
 
388
381
         ;; SAS execution blocks, DATA/RUN, PROC/RUN, SAS Macro Statements
389
382
         (cons "\\<%do[ \t]*\\(%until\\|%while\\)?\\>"
395
388
                                                    font-lock-reference-face)
396
389
 
397
390
         (cons (concat "\\(^[0-9]*\\|;\\|):\\|%then\\|%else\\)[ \t]*"
398
 
                "\\(data\\|endsas\\|quit\\|run\\)[ \t\n;]")
 
391
                "\\(data\\|endsas\\|finish\\|quit\\|run\\|start\\)[ \t\n;]")
399
392
                                                    font-lock-reference-face)
400
393
         (cons (concat "\\(^[0-9]*\\|;\\|):\\|%then\\|%else\\)[ \t]*"
401
394
                "proc[ \t]+[a-z][a-z_0-9]+")        font-lock-reference-face)
419
412
                "\\|var\\|where\\)"
420
413
                "[ \t]*=")
421
414
                                                    font-lock-keyword-face)
422
 
         (cons "\\<\\(in\\(dex[ \t]*=\\)?\\|until\\|wh\\(en\\|ile\\)\\)[ \t]*("
 
415
         (cons "\\<\\(in\\(:\\|dex[ \t]*=\\)?\\|until\\|wh\\(en\\|ile\\)\\)[ \t]*("
423
416
                                                    font-lock-keyword-face)
424
417
 
425
418
         ;; SAS statements
426
 
 
427
419
         (cons (concat
428
420
                "\\(^[0-9]*\\|):\\|[;,]\\|then\\|else\\)[ \t]*"
429
 
                "\\(a\\(bort\\|rray\\|ttrib\\)\\|by\\|c\\(hange\\|lass\\)"
430
 
                "\\|d\\(elete\\|isplay\\|m\\|rop\\)\\|e\\(rror\\|xc\\(hange\\|lude\\)\\)"
 
421
                "\\(a\\(bort\\|rray\\|ttrib\\)\\|by"
 
422
                "\\|c\\(hange\\|lass\\|ontrast\\)"
 
423
                "\\|d\\(elete\\|isplay\\|m\\|o\\([ \t]+\\(data\\|over\\)\\)?\\|rop\\)"
 
424
                "\\|e\\(rror\\|stimate\\|xc\\(hange\\|lude\\)\\)"
431
425
                "\\|f\\(ile\\(name\\)?\\|o\\(otnote\\(10?\\|[2-9]\\)?\\|rmat\\)\\|req\\)"
432
426
                "\\|go\\([ \t]*to\\|ptions\\)"
433
427
                "\\|i\\(d\\|f\\|n\\(dex\\|f\\(ile\\|ormat\\)\\|put\\|value\\)\\)"
434
 
                "\\|keep\\|l\\(abel\\|ength\\|i\\(bname\\|nk\\)\\|smeans\\)"
 
428
                "\\|keep\\|l\\(abel\\|ength\\|i\\(bname\\|nk\\|st\\)\\|smeans\\)"
435
429
                "\\|m\\(anova\\|e\\(ans\\|rge\\)\\|issing\\|od\\(el\\|ify\\)\\)\\|note"
436
 
                "\\|o\\(ptions\\|therwise\\|utput\\)\\|p\\(lot\\|ut\\)"
 
430
                "\\|o\\(ptions\\|therwise\\|utput\\)\\|p\\(arms\\|lot\\|ut\\)"
437
431
                "\\|r\\(andom\\|e\\(name\\|peated\\|tain\\)\\)"
438
432
                "\\|s\\(ave\\|e\\(lect\\|t\\)\\|kip\\|trata\\|umby\\)"
439
433
                "\\|t\\(ables?\\|i\\(me\\|tle\\(10?\\|[2-9]\\)?\\)\\)\\|update"
440
 
                "\\|va\\(lue\\|r\\)\\|w\\(eight\\|here\\|i\\(ndow\\|th\\)\\)\\)"
 
434
                "\\|va\\(lue\\|r\\)\\|w\\(eight\\|here\\|i\\(ndow\\|th\\)\\)"
 
435
 
 
436
        ;; IML statements that are not also SAS statements
 
437
                "\\|append\\|c\\(lose\\(file\\)?\\|reate\\)\\|edit\\|f\\(ind\\|orce\\|ree\\)"
 
438
                "\\|insert\\|load\\|mattrib\\|p\\(a[ru]se\\|rint\\|urge\\)"
 
439
                "\\|re\\(move\\|peat\\|place\\|set\\|sume\\)"
 
440
                "\\|s\\(et\\(in\\|out\\)\\|how\\|ort\\|tore\\|ummary\\)\\|use\\)?"
 
441
 
441
442
                "\\>")                              font-lock-keyword-face)
442
 
;;       (cons "\\<\\(\\(\\(then\\|else\\)[ \t]*\\)?do\\([ \t]*over\\)?\\|else\\)\\>"
443
 
         (cons "\\<\\(\\(then\\|else\\)[ \t]*\\)?\\(do\\([ \t]*over\\)?\\|else\\)\\>"
444
 
                                                    font-lock-keyword-face)
 
443
 
 
444
 
 
445
 
 
446
;;       (cons "\\<\\(\\(then\\|else\\)[ \t]*\\)?\\(do\\([ \t]*over\\)?\\|else\\)\\>"
 
447
;;                                                  font-lock-keyword-face)
445
448
 
446
449
         ;; SAS statements that must be followed by a semi-colon
447
450
         (cons (concat
448
451
                "\\(^[0-9]*\\|):\\|[;,]\\|then\\|else\\)[ \t]*"
449
 
                "\\(cards4?\\|end\\|l\\(ist\\|ostcard\\)\\|page\\|return\\|stop\\)?"
 
452
                "\\(cards4?\\|datalines\\|end\\|l\\(ostcard\\)\\|page\\|return\\|stop\\)?"
450
453
                "[ \t]*;")                          font-lock-keyword-face)
451
454
 
452
455
         ;; SAS/GRAPH statements not handled above
455
458
                "\\(axis\\|legend\\|pattern\\|symbol\\)"
456
459
                "\\([1-9][0-9]?\\)?\\>")            font-lock-keyword-face)
457
460
 
458
 
         ;; SAS functions and SAS macro functions
459
 
         (cons "%[a-z_][a-z_0-9]*[ \t]*[(;]"
 
461
         ;; SAS Datastep functions and SAS macro functions
 
462
         ;(cons "%[a-z_][a-z_0-9]*[ \t]*[(;]"
 
463
         ;; SAS macro functions occasionally defined with no arguments
 
464
         (cons "%[a-z_][a-z_0-9]*[ \t();,]"
460
465
                                                    font-lock-function-name-face)
461
466
         (cons "\\<call[ \t]+[a-z_][a-z_0-9]*[ \t]*("
462
467
                                                    font-lock-function-name-face)
476
481
                "\\|prob\\([ft]\\|b\\(eta\\|nml\\)\\|chi\\|gam\\|hypr\\|it\\|n\\(egb\\|orm\\)\\)"
477
482
                "\\|ordinal\\|p\\(oisson\\|ut\\)\\|qtr\\|r\\(e\\(peat\\|verse\\)\\|ight\\|ound\\)"
478
483
                "\\|ran\\(bin\\|cau\\|exp\\|g\\(am\\|e\\)\\|k\\|nor\\|poi\\|t\\(bl\\|ri\\)\\|uni\\)"
479
 
                "\\|s\\(aving\\|can\\|econd\\|i\\(gn\\|nh?\\)\\|qrt\\|t\\(d\\(\\|err\\)\\|fips\\|namel?\\)\\|u\\(bstr\\|m\\)\\|ymget\\)"
 
484
                "\\|s\\(aving\\|can\\|econd\\|i\\(gn\\|nh?\\)\\|qrt\\|t\\(d\\(\\|err\\)\\|fips\\|namel?\\)\\|u\\(bstr\\|m\\)\\|ymget\\)"
480
485
                "\\|t\\(anh?\\|i\\(me\\(\\|part\\)\\|nv\\)\\|oday\\|r\\(anslate\\|i\\(gamma\\|m\\)\\|unc\\)\\)"
481
486
                "\\|u\\(niform\\|pcase\\|ss\\)\\|v\\(ar\\|erify\\)"
482
487
                "\\|weekday\\|y\\(ear\\|yq\\)\\|zip\\(fips\\|namel?\\|state\\)"
487
492
                "\\|c\\(nonct\\|ompbl\\)\\|d\\(airy\\|equote\\)\\|fnonct\\|tnonct"
488
493
                "\\|i\\(bessel\\|n\\(dexw\\|put[cn]\\)\\)\\|jbessel\\|put[cn]"
489
494
                "\\|lowcase\\|quote\\|resolve\\|s\\(oundex\\|ysprod\\)\\|tr\\(anwrd\\|imn\\)"
490
 
                
 
495
 
 
496
;;;    ;; IML functions that are not also Datastep functions
 
497
                "\\|a\\(ll\\|ny\\|pply\\|rmasim\\)\\|b\\(lock\\|ranks\\|tran\\)"
 
498
                "\\|c\\(har\\|hoose\\|on\\(cat\\|tents\\|vexit\\|vmod\\)\\|ovlag\\|shape\\|usum\\|vexhull\\)"
 
499
                "\\|d\\(atasets\\|esignf?\\|et\\|iag\\|o\\|uration\\)"
 
500
                "\\|e\\(chelon\\|igv\\(al\\|ec\\)\\)\\|f\\(ft\\|orward\\)\\|ginv"
 
501
                "\\|h\\(alf\\|ankel\\|dir\\|ermite\\|omogen\\)"
 
502
                "\\|i\\(\\|fft\\|nsert\\|nv\\(updt\\)?\\)\\|j\\(\\|root\\)\\|loc\\|mad"
 
503
                "\\|n\\(ame\\|col\\|leng\\|row\\|um\\)\\|o\\(pscal\\|rpol\\)"
 
504
                "\\|p\\(olyroot\\|roduct\\|v\\)\\|r\\(anktie\\|ates\\|atio\\|emove\\|eturn\\|oot\\|owcatc?\\)"
 
505
                "\\|s\\(etdif\\|hape\\|olve\\|plinev\\|pot\\|qrsym\\|ssq\\|torage\\|weep\\|ymsqr\\)"
 
506
                "\\|t\\(\\|eigv\\(al\\|ec\\)\\|oeplitz\\|race\\|risolv\\|ype\\)"
 
507
                "\\|uni\\(on\\|que\\)\\|v\\(alue\\|ecdiag\\)\\|x\\(mult\\|sect\\)\\|yield"
 
508
 
491
509
;;;    ;; SCL functions that are known to work with SAS macro function %sysfunc
492
510
 
493
511
                "\\|attr[cn]\\|c\\(exist\\|lose\\)\\|d\\(close\\|num\\|open\\|read\\)"
494
512
                "\\|exist\\|f\\(close\\|etchobs\\|i\\(leexist\\|nfo\\)\\|open\\|put\\|write\\)"
495
513
                "\\|get\\(option\\|var[cn]\\)\\|lib\\(name\\|ref\\)\\|op\\(en\\|t\\(getn\\|setn\\)\\)"
496
 
                "\\|pathname\\|sysmsg\\|var\\(fmt\\|label\\|num\\|type\\)\\)"
 
514
                "\\|pathname\\|sysmsg\\|var\\(fmt\\|l\\(abel\\|en\\)\\|n\\(ame\\|um\\)\\|type\\)\\)"
497
515
                "[ \t]*(")                          font-lock-function-name-face)
498
516
         ))
499
517
        "Font Lock regexs for SAS.")
500
 
)); only if window-system
 
518
)
 
519
  (defvar SAS-mode-font-lock-keywords "") ;; empty if not window-system
 
520
); only if window-system
501
521
 
502
522
(defvar SAS-editing-alist
503
523
  '((sentence-end                 . ";[\t\n */]*")
714
734
      (beginning-of-line)
715
735
      (while ok
716
736
        (if (re-search-forward
717
 
             "\\(^[ \t]*run[ ;]\\)\\|\\(^[ \t]*proc \\|^[ \t]*data[ ;]\\)" 
 
737
             "\\(^[ \t]*run[ ;]\\)\\|\\(^[ \t]*proc \\|^[ \t]*data[ ;]\\)"
718
738
             nil 1)
719
739
            (if (match-beginning 2)
720
740
                (if (re-search-forward
852
872
  (let ((name (buffer-file-name)))
853
873
    (cond ((not name))
854
874
          ((string-match (substring name -4 nil)
855
 
                         "\\.sas\\|\\.lst\\|\\.log") 
 
875
                         "\\.sas\\|\\.lst\\|\\.log")
856
876
 
857
877
           (setq sas-file-name (substring name 0 (- (length name) 4)))
858
878
           (setq sas-buffer-name (buffer-name))