1
1
;;; essl-sas.el --- SAS customization
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.
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 $
10
;; Maintainers: ESS-core <ESS-core@stat.math.ethz.ch>
16
12
;; Keywords: start up, configuration.
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
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.
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))
119
117
(fset 'sas-log-mode 'SAS-log-mode)
120
118
(fset 'SAS-transcript-mode 'SAS-log-mode)
168
(defcustom sas-get-options nil
166
(defcustom sas-get-options nil
169
167
"Options to be passed to SAS in sas-get-dataset."
169
:type '(choice (const nil) string))
173
171
(defcustom sas-get-options-history nil
174
172
"History list of Options passed to SAS in sas-get-dataset."
193
191
(defcustom sas-file-name nil
194
192
"*The name of the current sas file."
194
:type '(choice (const nil) file))
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)
378
376
(cons "^ERROR: .*$" font-lock-keyword-face)
380
378
;; .log WARNING: messages
381
(cons "^WARNING: .*$" font-lock-function-name-face)
379
(cons "^WARNING: .*$" font-lock-function-name-face)
384
382
;; /* */ handled by grammar above
395
393
font-lock-reference-face)
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)
425
423
;; SAS statements
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\\)\\)"
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\\)?"
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)
451
;; (cons "\\<\\(\\(then\\|else\\)[ \t]*\\)?\\(do\\([ \t]*over\\)?\\|else\\)\\>"
452
;; font-lock-keyword-face)
448
454
;; SAS statements that must be followed by a semi-colon
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)
454
460
;; SAS/GRAPH statements not handled above
457
463
"\\(axis\\|legend\\|pattern\\|symbol\\)"
458
464
"\\([1-9][0-9]?\\)?\\>") font-lock-keyword-face)
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\\)"
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"
493
512
;;; ;; SCL functions that are known to work with SAS macro function %sysfunc
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)
501
520
"Font Lock regexs for SAS.")
502
)); only if window-system
522
(defvar SAS-mode-font-lock-keywords "") ;; empty if not window-system
523
); only if window-system
504
525
(defvar SAS-editing-alist
505
526
'((sentence-end . ";[\t\n */]*")
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")
859
880
(setq sas-file-name (substring name 0 (- (length name) 4)))
860
881
(setq sas-buffer-name (buffer-name))