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/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 $
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)
109
105
"Fundamental mode with `ess-listing-minor-mode' and read-only."
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.
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))
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)
168
(defcustom sas-get-options nil
161
(defcustom sas-get-options nil
169
162
"Options to be passed to SAS in sas-get-dataset."
164
:type '(choice (const nil) string))
173
166
(defcustom sas-get-options-history nil
174
167
"History list of Options passed to SAS in sas-get-dataset."
193
186
(defcustom sas-file-name nil
194
187
"*The name of the current sas file."
189
:type '(choice (const nil) file))
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)
378
371
(cons "^ERROR: .*$" font-lock-keyword-face)
380
373
;; .log WARNING: messages
381
(cons "^WARNING: .*$" font-lock-function-name-face)
374
(cons "^WARNING: .*$" font-lock-function-name-face)
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)
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)
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\\)"
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)
425
418
;; SAS statements
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\\)\\)"
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
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)
446
;; (cons "\\<\\(\\(then\\|else\\)[ \t]*\\)?\\(do\\([ \t]*over\\)?\\|else\\)\\>"
447
;; font-lock-keyword-face)
446
449
;; SAS statements that must be followed by a semi-colon
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)
452
455
;; SAS/GRAPH statements not handled above
455
458
"\\(axis\\|legend\\|pattern\\|symbol\\)"
456
459
"\\([1-9][0-9]?\\)?\\>") font-lock-keyword-face)
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\\)"
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"
491
509
;;; ;; SCL functions that are known to work with SAS macro function %sysfunc
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)
499
517
"Font Lock regexs for SAS.")
500
)); only if window-system
519
(defvar SAS-mode-font-lock-keywords "") ;; empty if not window-system
520
); only if window-system
502
522
(defvar SAS-editing-alist
503
523
'((sentence-end . ";[\t\n */]*")
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")
857
877
(setq sas-file-name (substring name 0 (- (length name) 4)))
858
878
(setq sas-buffer-name (buffer-name))