~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: 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
;;; 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/04/12 21:46:24 $
13
 
;; Version: $Revision: 5.42 $
14
 
;; RCS: $Id: essl-sas.el,v 5.42 2002/04/12 21:46:24 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)
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))
 
112
(if (not (featurep 'xemacs))
 
113
    (setq auto-mode-alist
 
114
        (append '(("\\.[lL][sS][tT]\\'" . sas-listing-mode)) auto-mode-alist)))
 
115
;;;###autoload(add-to-list 'auto-mode-alist '("\\.[lL][sS][tT]\\'" . sas-listing-mode))
118
116
 
119
117
(fset 'sas-log-mode        'SAS-log-mode)
120
118
(fset 'SAS-transcript-mode 'SAS-log-mode)
138
136
  :type  'boolean)
139
137
 
140
138
;; user can specify the sas program name
141
 
(defcustom sas-program 
 
139
(defcustom sas-program
142
140
  (if (equal system-type 'Apple-Macintosh) "invoke SAS using program file" "sas")
143
141
  "*Command to invoke SAS, default for buffer-local `ess-sas-submit-command'."
144
142
  :group 'ess-sas
155
153
;  :group 'ess-sas
156
154
;  :type  'string)
157
155
 
158
 
(defcustom sas-notify t 
 
156
(defcustom sas-notify t
159
157
  "*Beep and display message when job is done."
160
158
  :group 'ess-sas
161
159
  :type  'boolean)
165
163
  :group 'ess-sas
166
164
  :type  'boolean)
167
165
 
168
 
(defcustom sas-get-options nil 
 
166
(defcustom sas-get-options nil
169
167
  "Options to be passed to SAS in sas-get-dataset."
170
168
  :group 'ess-sas
171
 
  :type  'string)
 
169
  :type '(choice (const nil) string))
172
170
 
173
171
(defcustom sas-get-options-history nil
174
172
  "History list of Options passed to SAS in sas-get-dataset."
185
183
  :group 'ess-sas
186
184
  :type  'boolean)
187
185
 
188
 
(defcustom sas-tmp-libname "_tmp_" 
 
186
(defcustom sas-tmp-libname "_tmp_"
189
187
  "*Libname to use for sas-get-dataset."
190
188
  :group 'ess-sas
191
189
  :type  'string)
193
191
(defcustom sas-file-name nil
194
192
  "*The name of the current sas file."
195
193
  :group 'ess-sas
196
 
  :type  'file)
 
194
  :type '(choice (const nil) file))
197
195
 
198
196
;; The next two are ``the inside of [...] in a regexp'' to be used in
199
197
;; (skip-chars-(for|back)ward SAS-..-chars)
210
208
(defcustom ess-sas-run-make-regexp nil
211
209
  "If you do not want to run make-regexp, then set to nil."
212
210
  :group 'ess-sas
213
 
  :type  'string)
 
211
  :type '(choice (const nil) string))
214
212
 
215
213
(require 'essa-sas)
216
214
 
252
250
      (require 'font-lock)
253
251
 
254
252
      (defvar SAS-mode-font-lock-keywords
255
 
        (if ess-sas-run-make-regexp 
 
253
        (if ess-sas-run-make-regexp
256
254
        (list
257
255
         ;; SAS comments
258
256
         (cons "^[ \t]*%?\\*.*;"                font-lock-comment-face)
378
376
         (cons "^ERROR: .*$"                        font-lock-keyword-face)
379
377
 
380
378
         ;; .log WARNING: messages
381
 
         (cons "^WARNING: .*$"                      font-lock-function-name-face)       
 
379
         (cons "^WARNING: .*$"                      font-lock-function-name-face)
382
380
 
383
381
         ;; SAS comments
384
382
;; /* */ handled by grammar above
395
393
                                                    font-lock-reference-face)
396
394
 
397
395
         (cons (concat "\\(^[0-9]*\\|;\\|):\\|%then\\|%else\\)[ \t]*"
398
 
                "\\(data\\|endsas\\|quit\\|run\\)[ \t\n;]")
 
396
                "\\(data\\|endsas\\|finish\\|quit\\|run\\|start\\)[ \t\n;]")
399
397
                                                    font-lock-reference-face)
400
398
         (cons (concat "\\(^[0-9]*\\|;\\|):\\|%then\\|%else\\)[ \t]*"
401
399
                "proc[ \t]+[a-z][a-z_0-9]+")        font-lock-reference-face)
423
421
                                                    font-lock-keyword-face)
424
422
 
425
423
         ;; SAS statements
426
 
 
427
424
         (cons (concat
428
425
                "\\(^[0-9]*\\|):\\|[;,]\\|then\\|else\\)[ \t]*"
429
426
                "\\(a\\(bort\\|rray\\|ttrib\\)\\|by"
430
427
                "\\|c\\(hange\\|lass\\|ontrast\\)"
431
 
                "\\|d\\(elete\\|isplay\\|m\\|rop\\)"
 
428
                "\\|d\\(elete\\|isplay\\|m\\|o\\([ \t]+\\(data\\|over\\)\\)?\\|rop\\)"
432
429
                "\\|e\\(rror\\|stimate\\|xc\\(hange\\|lude\\)\\)"
433
430
                "\\|f\\(ile\\(name\\)?\\|o\\(otnote\\(10?\\|[2-9]\\)?\\|rmat\\)\\|req\\)"
434
431
                "\\|go\\([ \t]*to\\|ptions\\)"
435
432
                "\\|i\\(d\\|f\\|n\\(dex\\|f\\(ile\\|ormat\\)\\|put\\|value\\)\\)"
436
 
                "\\|keep\\|l\\(abel\\|ength\\|i\\(bname\\|nk\\)\\|smeans\\)"
 
433
                "\\|keep\\|l\\(abel\\|ength\\|i\\(bname\\|nk\\|st\\)\\|smeans\\)"
437
434
                "\\|m\\(anova\\|e\\(ans\\|rge\\)\\|issing\\|od\\(el\\|ify\\)\\)\\|note"
438
435
                "\\|o\\(ptions\\|therwise\\|utput\\)\\|p\\(lot\\|ut\\)"
439
436
                "\\|r\\(andom\\|e\\(name\\|peated\\|tain\\)\\)"
440
437
                "\\|s\\(ave\\|e\\(lect\\|t\\)\\|kip\\|trata\\|umby\\)"
441
438
                "\\|t\\(ables?\\|i\\(me\\|tle\\(10?\\|[2-9]\\)?\\)\\)\\|update"
442
 
                "\\|va\\(lue\\|r\\)\\|w\\(eight\\|here\\|i\\(ndow\\|th\\)\\)\\)"
 
439
                "\\|va\\(lue\\|r\\)\\|w\\(eight\\|here\\|i\\(ndow\\|th\\)\\)"
 
440
 
 
441
        ;; IML statements that are not also SAS statements
 
442
                "\\|append\\|c\\(lose\\(file\\)?\\|reate\\)\\|edit\\|f\\(ind\\|orce\\|ree\\)"
 
443
                "\\|insert\\|load\\|mattrib\\|p\\(a[ru]se\\|rint\\|urge\\)"
 
444
                "\\|re\\(move\\|peat\\|place\\|set\\|sume\\)"
 
445
                "\\|s\\(et\\(in\\|out\\)\\|how\\|ort\\|tore\\|ummary\\)\\|use\\)?"
 
446
 
443
447
                "\\>")                              font-lock-keyword-face)
444
 
;;       (cons "\\<\\(\\(\\(then\\|else\\)[ \t]*\\)?do\\([ \t]*over\\)?\\|else\\)\\>"
445
 
         (cons "\\<\\(\\(then\\|else\\)[ \t]*\\)?\\(do\\([ \t]*over\\)?\\|else\\)\\>"
446
 
                                                    font-lock-keyword-face)
 
448
 
 
449
 
 
450
 
 
451
;;       (cons "\\<\\(\\(then\\|else\\)[ \t]*\\)?\\(do\\([ \t]*over\\)?\\|else\\)\\>"
 
452
;;                                                  font-lock-keyword-face)
447
453
 
448
454
         ;; SAS statements that must be followed by a semi-colon
449
455
         (cons (concat
450
456
                "\\(^[0-9]*\\|):\\|[;,]\\|then\\|else\\)[ \t]*"
451
 
                "\\(cards4?\\|end\\|l\\(ist\\|ostcard\\)\\|page\\|return\\|stop\\)?"
 
457
                "\\(cards4?\\|datalines\\|end\\|l\\(ostcard\\)\\|page\\|return\\|stop\\)?"
452
458
                "[ \t]*;")                          font-lock-keyword-face)
453
459
 
454
460
         ;; SAS/GRAPH statements not handled above
457
463
                "\\(axis\\|legend\\|pattern\\|symbol\\)"
458
464
                "\\([1-9][0-9]?\\)?\\>")            font-lock-keyword-face)
459
465
 
460
 
         ;; SAS functions and SAS macro functions
 
466
         ;; SAS Datastep functions and SAS macro functions
461
467
         (cons "%[a-z_][a-z_0-9]*[ \t]*[(;]"
462
468
                                                    font-lock-function-name-face)
463
469
         (cons "\\<call[ \t]+[a-z_][a-z_0-9]*[ \t]*("
489
495
                "\\|c\\(nonct\\|ompbl\\)\\|d\\(airy\\|equote\\)\\|fnonct\\|tnonct"
490
496
                "\\|i\\(bessel\\|n\\(dexw\\|put[cn]\\)\\)\\|jbessel\\|put[cn]"
491
497
                "\\|lowcase\\|quote\\|resolve\\|s\\(oundex\\|ysprod\\)\\|tr\\(anwrd\\|imn\\)"
492
 
                
 
498
 
 
499
;;;    ;; IML functions that are not also Datastep functions
 
500
                "\\|a\\(ll\\|ny\\|pply\\|rmasim\\)\\|b\\(lock\\|ranks\\|tran\\)"
 
501
                "\\|c\\(har\\|hoose\\|on\\(cat\\|tents\\|vexit\\|vmod\\)\\|ovlag\\|shape\\|usum\\|vexhull\\)"
 
502
                "\\|d\\(atasets\\|esignf?\\|et\\|iag\\|o\\|uration\\)"
 
503
                "\\|e\\(chelon\\|igv\\(al\\|ec\\)\\)\\|f\\(ft\\|orward\\)\\|ginv"
 
504
                "\\|h\\(alf\\|ankel\\|dir\\|ermite\\|omogen\\)"
 
505
                "\\|i\\(\\|fft\\|nsert\\|nv\\(updt\\)?\\)\\|j\\(\\|root\\)\\|loc\\|mad"
 
506
                "\\|n\\(ame\\|col\\|leng\\|row\\|um\\)\\|o\\(pscal\\|rpol\\)"
 
507
                "\\|p\\(olyroot\\|roduct\\|v\\)\\|r\\(anktie\\|ates\\|atio\\|emove\\|eturn\\|oot\\|owcatc?\\)"
 
508
                "\\|s\\(etdif\\|hape\\|olve\\|plinev\\|pot\\|qrsym\\|ssq\\|torage\\|weep\\|ymsqr\\)"
 
509
                "\\|t\\(\\|eigv\\(al\\|ec\\)\\|oeplitz\\|race\\|risolv\\|ype\\)"
 
510
                "\\|uni\\(on\\|que\\)\\|v\\(alue\\|ecdiag\\)\\|x\\(mult\\|sect\\)\\|yield"
 
511
 
493
512
;;;    ;; SCL functions that are known to work with SAS macro function %sysfunc
494
513
 
495
514
                "\\|attr[cn]\\|c\\(exist\\|lose\\)\\|d\\(close\\|num\\|open\\|read\\)"
496
515
                "\\|exist\\|f\\(close\\|etchobs\\|i\\(leexist\\|nfo\\)\\|open\\|put\\|write\\)"
497
516
                "\\|get\\(option\\|var[cn]\\)\\|lib\\(name\\|ref\\)\\|op\\(en\\|t\\(getn\\|setn\\)\\)"
498
 
                "\\|pathname\\|sysmsg\\|var\\(fmt\\|label\\|num\\|type\\)\\)"
 
517
                "\\|pathname\\|sysmsg\\|var\\(fmt\\|l\\(abel\\|en\\)\\|n\\(ame\\|um\\)\\|type\\)\\)"
499
518
                "[ \t]*(")                          font-lock-function-name-face)
500
519
         ))
501
520
        "Font Lock regexs for SAS.")
502
 
)); only if window-system
 
521
)
 
522
  (defvar SAS-mode-font-lock-keywords "") ;; empty if not window-system
 
523
); only if window-system
503
524
 
504
525
(defvar SAS-editing-alist
505
526
  '((sentence-end                 . ";[\t\n */]*")
716
737
      (beginning-of-line)
717
738
      (while ok
718
739
        (if (re-search-forward
719
 
             "\\(^[ \t]*run[ ;]\\)\\|\\(^[ \t]*proc \\|^[ \t]*data[ ;]\\)" 
 
740
             "\\(^[ \t]*run[ ;]\\)\\|\\(^[ \t]*proc \\|^[ \t]*data[ ;]\\)"
720
741
             nil 1)
721
742
            (if (match-beginning 2)
722
743
                (if (re-search-forward
854
875
  (let ((name (buffer-file-name)))
855
876
    (cond ((not name))
856
877
          ((string-match (substring name -4 nil)
857
 
                         "\\.sas\\|\\.lst\\|\\.log") 
 
878
                         "\\.sas\\|\\.lst\\|\\.log")
858
879
 
859
880
           (setq sas-file-name (substring name 0 (- (length name) 4)))
860
881
           (setq sas-buffer-name (buffer-name))