~ubuntu-branches/ubuntu/raring/ess/raring-proposed

« back to all changes in this revision

Viewing changes to lisp/ess-sas-a.el

  • Committer: Package Import Robot
  • Author(s): Dirk Eddelbuettel
  • Date: 2012-05-09 08:00:38 UTC
  • mfrom: (1.2.23)
  • Revision ID: package-import@ubuntu.com-20120509080038-7an3nhbtgaj02a17
Tags: 12.04-1-1
New upstream patch version released today

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
;;; ess-sas-a.el -- clean-room implementation of many SAS-mode features
 
1
;;; ess-sas-a.el --- clean-room implementation of many SAS-mode features
2
2
 
3
3
;; Copyright (C) 1997--2009 A.J. Rossini, Rich M. Heiberger, Martin
4
 
;;      Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
 
4
;;      Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
5
5
 
6
 
;; Original Author: Rodney A. Sparapani
 
6
;; Author: Rodney A. Sparapani
7
7
;; Maintainer: ESS-core@r-project.org
8
8
;; Created: 17 November 1999
9
 
;; Keywords: SAS
 
9
;; Keywords: languages
10
10
 
11
11
;; This file is part of ESS
12
12
 
23
23
;; You should have received a copy of the GNU General Public License
24
24
;; along with GNU Emacs; see the file COPYING.  If not, write to
25
25
;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26
 
;;
27
 
;; In short: you may use this code any way you like, as long as you
28
 
;; don't charge money for it, remove this notice, or hold anyone liable
29
 
;; for its results.
30
26
 
31
 
;; Code:
 
27
;;; Code:
32
28
 
33
29
;;; Table of Contents
34
30
;;; Section 1:  Variable Definitions
85
81
  :type  'string)
86
82
 
87
83
(defcustom ess-sas-graph-view-viewer-alist
88
 
;;creates something like
89
 
;;'(("[pP][dD][fF]" . "/usr/local/bin/acroread") ("[eE]?[pP][sS]" . "/usr/local/bin/gv")))
90
 
    (let ((ess-tmp-alist nil)
 
84
  ;;creates something like
 
85
  ;;'(("[pP][dD][fF]" . "/usr/local/bin/acroread") ("[eE]?[pP][sS]" . "/usr/local/bin/gv")))
 
86
  (let ((ess-tmp-alist nil)
91
87
        (ess-tmp-ps nil) (ess-tmp-pdf nil))
92
88
 
93
89
    (setq ess-tmp-ps (executable-find (if ess-microsoft-p "gsview32" "gsview")))
100
96
 
101
97
    (if (not ess-tmp-pdf) (setq ess-tmp-pdf (executable-find "xpdf")))
102
98
 
103
 
    (if (not ess-tmp-pdf) (setq ess-tmp-pdf (if ess-microsoft-p "acrord32" "acroread"))) 
 
99
    (if (not ess-tmp-pdf) (setq ess-tmp-pdf (if ess-microsoft-p "acrord32" "acroread")))
104
100
 
105
101
    (if (and ess-tmp-ps ess-tmp-pdf)
106
 
        (setq ess-tmp-alist (list (cons "[eE]?[pP][sS]" ess-tmp-ps)
107
 
            (cons "[pP][dD][fF]" ess-tmp-pdf)))
 
102
        (setq ess-tmp-alist (list (cons "[eE]?[pP][sS]" ess-tmp-ps)
 
103
                                  (cons "[pP][dD][fF]" ess-tmp-pdf)))
108
104
 
109
 
        (if ess-tmp-ps
110
 
            (setq ess-tmp-alist (list (cons "[eE]?[pP][sS]" ess-tmp-ps)
111
 
                (cons "[pP][dD][fF]" ess-tmp-ps))))))
 
105
      (if ess-tmp-ps
 
106
          (setq ess-tmp-alist (list (cons "[eE]?[pP][sS]" ess-tmp-ps)
 
107
                                    (cons "[pP][dD][fF]" ess-tmp-ps))))))
112
108
 
113
109
  "*Associate file name extensions with graphics image file viewers."
114
110
  :group 'ess-sas
174
170
 
175
171
(defvar ess-sas-submit-method
176
172
  (if ess-microsoft-p
177
 
    (if (w32-shell-dos-semantics) 'ms-dos 'sh)
 
173
      (if (w32-shell-dos-semantics) 'ms-dos 'sh)
178
174
    (if (or (equal system-type 'Apple-Macintosh)
179
 
            (and ess-sas-submit-mac-virtual-pc (equal system-type 'darwin)))
180
 
        'apple-script 'sh))
181
 
"Method used by `ess-sas-submit'.
 
175
            (and ess-sas-submit-mac-virtual-pc (equal system-type 'darwin)))
 
176
        'apple-script 'sh))
 
177
  "Method used by `ess-sas-submit'.
182
178
The default is based on the value of the emacs variable `system-type'
183
179
and, on Windows, the function `w32-shell-dos-semantics'.
184
180
'sh               if *shell* runs sh, ksh, csh, tcsh or bash
230
226
      ;; an environment where all shells are treated equally
231
227
 
232
228
      (let* ((temp-shell (getenv "SHELL"))
233
 
             ;; AJR: old CYGWIN versions return nil for (getenv
234
 
             ;; "SHELL"), so we need to deal with it 'cause I have to
235
 
             (temp-char (if temp-shell
236
 
                            (string-match "/" temp-shell)
237
 
                          nil)))
238
 
        (while temp-char
239
 
          (setq temp-shell (substring temp-shell (+ 1 temp-char)))
240
 
          (setq temp-char (string-match "/" temp-shell)))
 
229
             ;; AJR: old CYGWIN versions return nil for (getenv
 
230
             ;; "SHELL"), so we need to deal with it 'cause I have to
 
231
             (temp-char (if temp-shell
 
232
                            (string-match "/" temp-shell)
 
233
                          nil)))
 
234
        (while temp-char
 
235
          (setq temp-shell (substring temp-shell (+ 1 temp-char)))
 
236
          (setq temp-char (string-match "/" temp-shell)))
241
237
 
242
 
        (cond ((or (equal temp-shell "csh") (equal temp-shell "tcsh"))
243
 
               "nohup nice +6")
244
 
              (t "nohup nice")))
 
238
        (cond ((or (equal temp-shell "csh") (equal temp-shell "tcsh"))
 
239
               "nohup nice +6")
 
240
              (t "nohup nice")))
245
241
    (if ess-microsoft-p "start"))
246
242
  "*Command-line statement to precede SAS invocation, e.g. start or nohup"
247
243
  :group 'ess-sas
259
255
 
260
256
(defcustom ess-sas-suffix-regexp
261
257
  (concat "[.]\\([sS][aA][sS]\\|[lL][oO][gG]\\|[lL][sS][tT]"
262
 
          (if ess-sas-suffix-1 (concat
263
 
                                "\\|" (downcase ess-sas-suffix-1) "\\|" (upcase ess-sas-suffix-1)))
264
 
          (if ess-sas-suffix-2 (concat
265
 
                                "\\|" (downcase ess-sas-suffix-2) "\\|" (upcase ess-sas-suffix-2)))
266
 
          "\\)")
 
258
          (if ess-sas-suffix-1 (concat
 
259
                                "\\|" (downcase ess-sas-suffix-1) "\\|" (upcase ess-sas-suffix-1)))
 
260
          (if ess-sas-suffix-2 (concat
 
261
                                "\\|" (downcase ess-sas-suffix-2) "\\|" (upcase ess-sas-suffix-2)))
 
262
          "\\)")
267
263
  "*Regular expression for SAS suffixes."
268
264
  :group 'ess-sas
269
265
  :type  'string)
297
293
 
298
294
 
299
295
(defun ess-ebcdic-to-ascii-search-and-replace ()
300
 
    "*Search and replace EBCDIC text with ASCII equivalents."
301
 
    (interactive)
302
 
    (let ((ess-tmp-dd (executable-find "dd")) (ess-tmp-recode (executable-find "recode"))
303
 
          (ess-tmp-util nil) (ess-tmp-util-args nil))
 
296
  "*Search and replace EBCDIC text with ASCII equivalents."
 
297
  (interactive)
 
298
  (let ((ess-tmp-dd (executable-find "dd")) (ess-tmp-recode (executable-find "recode"))
 
299
        (ess-tmp-util nil) (ess-tmp-util-args nil))
304
300
 
305
301
    (if ess-tmp-dd (progn
306
 
        (setq ess-tmp-util ess-tmp-dd)
307
 
        (setq ess-tmp-util-args "conv=ascii"))
 
302
                     (setq ess-tmp-util ess-tmp-dd)
 
303
                     (setq ess-tmp-util-args "conv=ascii"))
308
304
 
309
 
        (setq ess-tmp-util ess-tmp-recode)
310
 
        (setq ess-tmp-util-args "EBCDIC..ISO-8859-1"))
 
305
      (setq ess-tmp-util ess-tmp-recode)
 
306
      (setq ess-tmp-util-args "EBCDIC..ISO-8859-1"))
311
307
 
312
308
    (if ess-tmp-util
313
 
        (while (search-forward-regexp "[^\f\t\n -~][^\f\t\n -?A-JQ-Yb-jp-y]*[^\f\t\n -~]?" nil t)
314
 
            (call-process-region (match-beginning 0) (match-end 0)
315
 
                    ess-tmp-util t (list t nil) t ess-tmp-util-args)))))
 
309
        (while (search-forward-regexp "[^\f\t\n -~][^\f\t\n -?A-JQ-Yb-jp-y]*[^\f\t\n -~]?" nil t)
 
310
          (call-process-region (match-beginning 0) (match-end 0)
 
311
                               ess-tmp-util t (list t nil) t ess-tmp-util-args)))))
316
312
 
317
313
 
318
314
(defun ess-exit-notify-sh (string)
319
 
"Detect completion or failure of submitted job and notify the user."
320
 
  ;(let* ((exit-done "\\[[0-9]+\\]\\ *\\+*\\ *\\(Exit\\|Done\\).*$")
 
315
  "Detect completion or failure of submitted job and notify the user."
 
316
                                        ;(let* ((exit-done "\\[[0-9]+\\]\\ *\\+*\\ *\\(Exit\\|Done\\).*$")
321
317
  (let* ((exit-done "\\[[0-9]+\\]\\ *\\+*\\ *\\(Exit\\|Done\\)[^\r\n]*") ; GNU Emacs needs this
322
 
         (beg (string-match exit-done string)))
 
318
         (beg (string-match exit-done string)))
323
319
    (if beg
324
 
        (message (substring string beg (match-end 0))))))
 
320
        (message (substring string beg (match-end 0))))))
325
321
 
326
322
 
327
323
(defun ess-sas-append-log ()
328
 
    "Append ess-temp.log to the current .log file."
329
 
    (interactive)
330
 
    (ess-sas-goto "log" 'revert)
331
 
    (goto-char (point-max))
332
 
    (insert-file-contents (concat (ess-sas-temp-root) ".log"))
333
 
    (save-buffer))
 
324
  "Append ess-temp.log to the current .log file."
 
325
  (interactive)
 
326
  (ess-sas-goto "log" 'revert)
 
327
  (goto-char (point-max))
 
328
  (insert-file-contents (concat (ess-sas-temp-root) ".log"))
 
329
  (save-buffer))
334
330
 
335
331
(defun ess-sas-append-lst ()
336
 
    "Append ess-temp.lst to the current .lst file."
337
 
    (interactive)
338
 
    (ess-sas-goto "lst" 'revert)
339
 
    (goto-char (point-max))
340
 
    (insert-file-contents (concat (ess-sas-temp-root) ".lst"))
341
 
    (save-buffer))
 
332
  "Append ess-temp.lst to the current .lst file."
 
333
  (interactive)
 
334
  (ess-sas-goto "lst" 'revert)
 
335
  (goto-char (point-max))
 
336
  (insert-file-contents (concat (ess-sas-temp-root) ".lst"))
 
337
  (save-buffer))
342
338
 
343
339
(defun ess-sas-backward-delete-tab ()
344
340
  "Moves the cursor to the previous tab-stop, deleting any characters
346
342
  (interactive)
347
343
 
348
344
  (let* (;; point of search
349
 
         ;;(ess-sas-search-point nil)
350
 
         ;; column of search
351
 
         ;;(ess-sas-search-column nil)
352
 
         ;; limit of search
353
 
         ;;(ess-sas-search-limit nil)
354
 
         ;; text to be inserted after a back-tab, if any
355
 
         ;;(ess-sas-end-text "end;")
356
 
         ;; current-column
357
 
         (ess-sas-column (current-column))
358
 
         ;; remainder of current-column and sas-indent-width
359
 
         (ess-sas-remainder (% ess-sas-column sas-indent-width)))
 
345
         ;;(ess-sas-search-point nil)
 
346
         ;; column of search
 
347
         ;;(ess-sas-search-column nil)
 
348
         ;; limit of search
 
349
         ;;(ess-sas-search-limit nil)
 
350
         ;; text to be inserted after a back-tab, if any
 
351
         ;;(ess-sas-end-text "end;")
 
352
         ;; current-column
 
353
         (ess-sas-column (current-column))
 
354
         ;; remainder of current-column and sas-indent-width
 
355
         (ess-sas-remainder (% ess-sas-column sas-indent-width)))
360
356
 
361
357
    (if (not (= ess-sas-column 0))
362
 
        (progn
363
 
          (if (= ess-sas-remainder 0)
364
 
              (setq ess-sas-remainder sas-indent-width))
 
358
        (progn
 
359
          (if (= ess-sas-remainder 0)
 
360
              (setq ess-sas-remainder sas-indent-width))
365
361
 
366
 
         (let ((backward-delete-char-untabify-method 'nil))
367
 
              (backward-delete-char-untabify ess-sas-remainder t)
368
 
              (setq ess-sas-column (- ess-sas-column ess-sas-remainder))
369
 
              (move-to-column ess-sas-column)
370
 
             (setq left-margin ess-sas-column))
 
362
          (let ((backward-delete-char-untabify-method 'nil))
 
363
            (backward-delete-char-untabify ess-sas-remainder t)
 
364
            (setq ess-sas-column (- ess-sas-column ess-sas-remainder))
 
365
            (move-to-column ess-sas-column)
 
366
            (setq left-margin ess-sas-column))
 
367
          ))
371
368
    ))
372
 
))
373
369
 
374
370
;; this feature was far too complicated to perfect
375
371
;;      (if ess-sas-smart-back-tab (progn
376
 
;;        (save-excursion
377
 
;;          (setq ess-sas-search-point
378
 
;;              (search-backward-regexp "end" nil t))
379
 
 
380
 
;;          (if (and ess-sas-search-point
381
 
;;              (search-backward-regexp "%" (+ ess-sas-search-point -1) t))
382
 
;;              (setq ess-sas-search-point (+ ess-sas-search-point -1))
383
 
;;          )
384
 
 
385
 
;;          (if (and ess-sas-search-point
386
 
;;              (not (equal ess-sas-column (current-column))))
387
 
;;              (setq ess-sas-search-point nil))
388
 
;;          )
389
 
 
390
 
;;        (save-excursion
391
 
;;          (setq ess-sas-search-point
392
 
;;              (search-backward-regexp "do\\|select"
393
 
;;                  ess-sas-search-point t))
394
 
 
395
 
;;          (setq ess-sas-search-column (current-column))
396
 
 
397
 
;;          (if ess-sas-search-point (progn
398
 
;;              (save-excursion
399
 
;;               (search-backward-regexp "^" nil t)
400
 
;;               (setq ess-sas-search-limit (point))
401
 
;;              )
402
 
 
403
 
;;              (if (search-backward-regexp "if.*then\\|else" ess-sas-search-limit t)
404
 
;;                  (setq ess-sas-search-point (point)))
405
 
 
406
 
;;              (if (search-backward-regexp "%" ess-sas-search-limit t) (progn
407
 
;;                  (setq ess-sas-end-text "%end;")
408
 
;;                  (setq ess-sas-search-point (point))
409
 
;;              ))
410
 
 
411
 
;;              (setq ess-sas-search-column (current-column))
412
 
 
413
 
;;              (if (not (equal ess-sas-column ess-sas-search-column))
414
 
;;                 (setq ess-sas-search-point nil))
415
 
;;        )))
416
 
 
417
 
;;        (if ess-sas-search-point (insert ess-sas-end-text))
 
372
;;        (save-excursion
 
373
;;          (setq ess-sas-search-point
 
374
;;              (search-backward-regexp "end" nil t))
 
375
 
 
376
;;          (if (and ess-sas-search-point
 
377
;;              (search-backward-regexp "%" (+ ess-sas-search-point -1) t))
 
378
;;              (setq ess-sas-search-point (+ ess-sas-search-point -1))
 
379
;;          )
 
380
 
 
381
;;          (if (and ess-sas-search-point
 
382
;;              (not (equal ess-sas-column (current-column))))
 
383
;;              (setq ess-sas-search-point nil))
 
384
;;          )
 
385
 
 
386
;;        (save-excursion
 
387
;;          (setq ess-sas-search-point
 
388
;;              (search-backward-regexp "do\\|select"
 
389
;;                  ess-sas-search-point t))
 
390
 
 
391
;;          (setq ess-sas-search-column (current-column))
 
392
 
 
393
;;          (if ess-sas-search-point (progn
 
394
;;              (save-excursion
 
395
;;               (search-backward-regexp "^" nil t)
 
396
;;               (setq ess-sas-search-limit (point))
 
397
;;              )
 
398
 
 
399
;;              (if (search-backward-regexp "if.*then\\|else" ess-sas-search-limit t)
 
400
;;                  (setq ess-sas-search-point (point)))
 
401
 
 
402
;;              (if (search-backward-regexp "%" ess-sas-search-limit t) (progn
 
403
;;                  (setq ess-sas-end-text "%end;")
 
404
;;                  (setq ess-sas-search-point (point))
 
405
;;              ))
 
406
 
 
407
;;              (setq ess-sas-search-column (current-column))
 
408
 
 
409
;;              (if (not (equal ess-sas-column ess-sas-search-column))
 
410
;;                 (setq ess-sas-search-point nil))
 
411
;;        )))
 
412
 
 
413
;;        (if ess-sas-search-point (insert ess-sas-end-text))
418
414
;;         ))
419
415
 
420
416
(defun ess-sas-cd ()
421
 
"Change directory, taking into account various issues with respect to
 
417
  "Change directory, taking into account various issues with respect to
422
418
`ess-sas-file-path'."
423
 
    ;(interactive)
424
 
    (ess-sas-file-path)
425
 
    (ess-sas-goto-shell t)
426
 
    (comint-send-input)
427
 
    (if (equal ess-sas-submit-method 'sh)
 
419
                                        ;(interactive)
 
420
  (ess-sas-file-path)
 
421
  (ess-sas-goto-shell t)
 
422
  (comint-send-input)
 
423
  (if (equal ess-sas-submit-method 'sh)
428
424
      (insert "cd " (car (last (split-string (file-name-directory ess-sas-file-path)
429
 
        "\\([a-zA-Z][a-zA-Z]:\\|]\\)"))))
430
 
        (if (equal ess-sas-submit-method 'ms-dos) (progn
431
 
            (if (string-equal ":" (substring ess-sas-file-path 1 2)) (progn
432
 
                (insert (substring ess-sas-file-path 0 2))
433
 
                (comint-send-input)))
434
 
            (insert "cd \"" (convert-standard-filename
435
 
                (file-name-directory ess-sas-file-path)) "\""))))
436
 
    (comint-send-input))
 
425
                                             "\\([a-zA-Z][a-zA-Z]:\\|]\\)"))))
 
426
    (if (equal ess-sas-submit-method 'ms-dos) (progn
 
427
                                                (if (string-equal ":" (substring ess-sas-file-path 1 2)) (progn
 
428
                                                                                                           (insert (substring ess-sas-file-path 0 2))
 
429
                                                                                                           (comint-send-input)))
 
430
                                                (insert "cd \"" (convert-standard-filename
 
431
                                                                 (file-name-directory ess-sas-file-path)) "\""))))
 
432
  (comint-send-input))
437
433
 
438
434
(defun ess-sas-create-local-variables-alist (&optional file-or-buffer)
439
 
"Create an alist of local variables from file-or-buffer, use the
 
435
  "Create an alist of local variables from file-or-buffer, use the
440
436
current buffer if nil."
441
437
 
442
 
(if file-or-buffer (set-buffer (ess-get-file-or-buffer file-or-buffer)))
 
438
  (if file-or-buffer (set-buffer (ess-get-file-or-buffer file-or-buffer)))
443
439
 
444
 
(ess-change-alist 'ess-kermit-remote-directory ess-kermit-remote-directory nil))
 
440
  (ess-change-alist 'ess-kermit-remote-directory ess-kermit-remote-directory nil))
445
441
 
446
442
(defun ess-sas-data-view-fsview (&optional ess-sas-data)
447
443
  "Open a dataset for viewing with PROC FSVIEW."
448
 
    (interactive)
449
 
    (ess-save-and-set-local-variables)
450
 
 
451
 
 (save-excursion (let ((ess-tmp-sas-data nil)
452
 
    (ess-tmp-sas-data-view-fsview-statement ess-sas-data-view-fsview-statement)
453
 
    (ess-search-regexp
454
 
    "[ \t=]\\([a-zA-Z_][a-zA-Z_0-9]*[.][a-zA-Z_][a-zA-Z_0-9]*\\)\\(&.*\\)?[. ,()\t;/]")
455
 
    (ess-search-except
456
 
    "^\\([wW][oO][rR][kK]\\|[fF][iI][rR][sS][tT]\\|[lL][aA][sS][tT]\\)[.]"))
457
 
 
458
 
    (if ess-sas-data nil (save-match-data
459
 
        (search-backward-regexp "[ \t=]" nil t)
460
 
 
461
 
        (save-excursion
462
 
            (setq ess-tmp-sas-data
463
 
                (ess-search-except ess-search-regexp ess-search-except)))
464
 
 
465
 
        (if (not ess-tmp-sas-data)
466
 
            (setq ess-tmp-sas-data
467
 
                (ess-search-except ess-search-regexp ess-search-except t)))
468
 
 
469
 
        (setq ess-sas-data (read-string "Permanent SAS Dataset: " ess-tmp-sas-data))
470
 
 
471
 
        (ess-sas-goto-shell t)
472
 
        (ess-sas-cd)
473
 
 
474
 
        (insert (concat ess-sas-submit-pre-command " " ess-sas-submit-command
475
 
            " -initstmt \"" ess-sas-data-view-libname ess-sas-data-view-fsview-command
476
 
            ess-sas-data ";" ess-tmp-sas-data-view-fsview-statement "; run;\" "
477
 
            ess-sas-submit-command-options " "
478
 
            ess-sas-data-view-submit-options " " ess-sas-submit-post-command))
479
 
    (comint-send-input)
480
 
)))))
 
444
  (interactive)
 
445
  (ess-save-and-set-local-variables)
 
446
 
 
447
  (save-excursion (let ((ess-tmp-sas-data nil)
 
448
                        (ess-tmp-sas-data-view-fsview-statement ess-sas-data-view-fsview-statement)
 
449
                        (ess-search-regexp
 
450
                         "[ \t=]\\([a-zA-Z_][a-zA-Z_0-9]*[.][a-zA-Z_][a-zA-Z_0-9]*\\)\\(&.*\\)?[. ,()\t;/]")
 
451
                        (ess-search-except
 
452
                         "^\\([wW][oO][rR][kK]\\|[fF][iI][rR][sS][tT]\\|[lL][aA][sS][tT]\\)[.]"))
 
453
 
 
454
                    (if ess-sas-data nil (save-match-data
 
455
                                           (search-backward-regexp "[ \t=]" nil t)
 
456
 
 
457
                                           (save-excursion
 
458
                                             (setq ess-tmp-sas-data
 
459
                                                   (ess-search-except ess-search-regexp ess-search-except)))
 
460
 
 
461
                                           (if (not ess-tmp-sas-data)
 
462
                                               (setq ess-tmp-sas-data
 
463
                                                     (ess-search-except ess-search-regexp ess-search-except t)))
 
464
 
 
465
                                           (setq ess-sas-data (read-string "Permanent SAS Dataset: " ess-tmp-sas-data))
 
466
 
 
467
                                           (ess-sas-goto-shell t)
 
468
                                           (ess-sas-cd)
 
469
 
 
470
                                           (insert (concat ess-sas-submit-pre-command " " ess-sas-submit-command
 
471
                                                           " -initstmt \"" ess-sas-data-view-libname ess-sas-data-view-fsview-command
 
472
                                                           ess-sas-data ";" ess-tmp-sas-data-view-fsview-statement "; run;\" "
 
473
                                                           ess-sas-submit-command-options " "
 
474
                                                           ess-sas-data-view-submit-options " " ess-sas-submit-post-command))
 
475
                                           (comint-send-input)
 
476
                                           )))))
481
477
 
482
478
(defun ess-sas-data-view-insight (&optional ess-sas-data)
483
479
  "Open a dataset for viewing with PROC INSIGHT."
484
 
    (interactive)
485
 
    (ess-save-and-set-local-variables)
486
 
 
487
 
 (save-excursion (let ((ess-tmp-sas-data nil)
488
 
    (ess-tmp-sas-data-view-insight-statement ess-sas-data-view-insight-statement)
489
 
    (ess-search-regexp
490
 
    "[ \t=]\\([a-zA-Z_][a-zA-Z_0-9]*[.][a-zA-Z_][a-zA-Z_0-9]*\\)\\(&.*\\)?[. ,()\t;]")
491
 
    (ess-search-except
492
 
    "^\\([wW][oO][rR][kK]\\|[fF][iI][rR][sS][tT]\\|[lL][aA][sS][tT]\\)[.]"))
493
 
 
494
 
    (if ess-sas-data nil (save-match-data
495
 
        (search-backward-regexp "[ \t=]" nil t)
496
 
 
497
 
        (save-excursion
498
 
            (setq ess-tmp-sas-data
499
 
                (ess-search-except ess-search-regexp ess-search-except)))
500
 
 
501
 
        (if (not ess-tmp-sas-data)
502
 
            (setq ess-tmp-sas-data
503
 
                (ess-search-except ess-search-regexp ess-search-except t)))
504
 
 
505
 
        (setq ess-sas-data (read-string "Permanent SAS Dataset: " ess-tmp-sas-data))
506
 
 
507
 
        (ess-sas-goto-shell t)
508
 
        (ess-sas-cd)
509
 
 
510
 
        (insert (concat ess-sas-submit-pre-command " " ess-sas-submit-command
511
 
            " -initstmt \"" ess-sas-data-view-libname ess-sas-data-view-insight-command
512
 
            ess-sas-data ";" ess-tmp-sas-data-view-insight-statement "; run;\" "
513
 
            ess-sas-data-view-submit-options " " ess-sas-submit-post-command))
514
 
    (comint-send-input)
515
 
)))))
 
480
  (interactive)
 
481
  (ess-save-and-set-local-variables)
 
482
 
 
483
  (save-excursion (let ((ess-tmp-sas-data nil)
 
484
                        (ess-tmp-sas-data-view-insight-statement ess-sas-data-view-insight-statement)
 
485
                        (ess-search-regexp
 
486
                         "[ \t=]\\([a-zA-Z_][a-zA-Z_0-9]*[.][a-zA-Z_][a-zA-Z_0-9]*\\)\\(&.*\\)?[. ,()\t;]")
 
487
                        (ess-search-except
 
488
                         "^\\([wW][oO][rR][kK]\\|[fF][iI][rR][sS][tT]\\|[lL][aA][sS][tT]\\)[.]"))
 
489
 
 
490
                    (if ess-sas-data nil (save-match-data
 
491
                                           (search-backward-regexp "[ \t=]" nil t)
 
492
 
 
493
                                           (save-excursion
 
494
                                             (setq ess-tmp-sas-data
 
495
                                                   (ess-search-except ess-search-regexp ess-search-except)))
 
496
 
 
497
                                           (if (not ess-tmp-sas-data)
 
498
                                               (setq ess-tmp-sas-data
 
499
                                                     (ess-search-except ess-search-regexp ess-search-except t)))
 
500
 
 
501
                                           (setq ess-sas-data (read-string "Permanent SAS Dataset: " ess-tmp-sas-data))
 
502
 
 
503
                                           (ess-sas-goto-shell t)
 
504
                                           (ess-sas-cd)
 
505
 
 
506
                                           (insert (concat ess-sas-submit-pre-command " " ess-sas-submit-command
 
507
                                                           " -initstmt \"" ess-sas-data-view-libname ess-sas-data-view-insight-command
 
508
                                                           ess-sas-data ";" ess-tmp-sas-data-view-insight-statement "; run;\" "
 
509
                                                           ess-sas-data-view-submit-options " " ess-sas-submit-post-command))
 
510
                                           (comint-send-input)
 
511
                                           )))))
516
512
 
517
513
(defun ess-sas-graph-view ()
518
514
  "Open a GSASFILE for viewing."
519
515
  (interactive)
520
 
;  (ess-sas-file-path)
 
516
                                        ;  (ess-sas-file-path)
521
517
  (ess-sas-goto-log 'no-error-check)
522
518
 
523
519
  (save-excursion (let (
524
 
        (ess-tmp-length (length ess-sas-graph-view-viewer-alist))
525
 
        (ess-tmp-counter 0)
526
 
        (ess-tmp-graph nil)
527
 
        (ess-tmp-graph-alist nil)
528
 
        (ess-tmp-glyph nil)
529
 
        (ess-tmp-graph-regexp
530
 
           ; (concat "[ ]RECORDS[ ]WRITTEN[ ]+TO[ ]\n?[ ]*\\(\\(\n\\|[^.]\\)*"
531
 
            (concat "[ ][rR][eE][cC][oO][rR][dD][sS][ ][wW][rR][iI][tT][tT][eE][nN][ ]+[tT][oO][ ]\n?[ ]*\\(.*"
532
 
                ess-sas-graph-view-suffix-regexp "\\)")))
533
 
;           (concat "['\"]\\(.*" ess-sas-graph-suffix-regexp "\\)['\"]")))
534
 
 
535
 
    (save-match-data
536
 
       (search-backward-regexp "[ \t=]" nil t)
537
 
 
538
 
       (save-excursion
539
 
            (setq ess-tmp-graph (ess-search-except ess-tmp-graph-regexp)))
540
 
 
541
 
        (if (not ess-tmp-graph)
542
 
            (setq ess-tmp-graph (ess-search-except ess-tmp-graph-regexp nil t)))
543
 
 
544
 
        (setq ess-tmp-graph (read-string "GSASFILE: "
545
 
            (or ess-tmp-graph ess-sas-file-path)))
546
 
 
547
 
          (if (fboundp 'ess-xemacs-insert-glyph) (progn
548
 
              (if (string-match "[.][gG][iI][fF]" ess-tmp-graph)
549
 
                 (setq ess-tmp-glyph 'gif)
550
 
              ;;else
551
 
              (if (string-match "[.][jJ][pP][eE]?[gG]" ess-tmp-graph)
552
 
                 (setq ess-tmp-glyph 'jpeg)))))
553
 
 
554
 
          ;;GNU Emacs graphics file image viewing mode loaded?
555
 
          (if (and (boundp 'auto-image-file-mode) auto-image-file-mode
556
 
              (string-match "[.][jJ][pP][eE]?[gG]" ess-tmp-graph))
557
 
              (find-file ess-tmp-graph)
558
 
          ;;else XEmacs graphics file image viewing mode loaded?
559
 
          (if (and (fboundp 'image-mode)
560
 
                (string-match "[.]\\([jJ][pP][eE]?[gG]\\|[gG][iI][fF]\\)"
561
 
                    ess-tmp-graph))
562
 
              (find-file ess-tmp-graph)
563
 
          ;;else XEmacs graphics file image viewing primitives loaded?
564
 
          (if ess-tmp-glyph (progn
565
 
                (switch-to-buffer (file-name-nondirectory ess-tmp-graph))
566
 
                (ess-xemacs-insert-glyph
567
 
                    (make-glyph (vector ess-tmp-glyph :file ess-tmp-graph))))
568
 
 
569
 
          ;;else use the appropriate graphics file image viewer
570
 
            (while (< ess-tmp-counter ess-tmp-length)
571
 
                (setq ess-tmp-graph-alist
572
 
                    (nth ess-tmp-counter ess-sas-graph-view-viewer-alist))
573
 
                (setq ess-tmp-graph-regexp (car ess-tmp-graph-alist))
574
 
 
575
 
                (if (string-match
576
 
                        (concat "[.]" ess-tmp-graph-regexp) ess-tmp-graph)
577
 
                    (progn
578
 
                        (ess-sas-goto-shell t)
579
 
                        (insert ess-sas-submit-pre-command " "
580
 
                            (cdr ess-tmp-graph-alist) " " ess-tmp-graph
581
 
                            (if (equal ess-sas-submit-method 'sh) " &"))
582
 
                        (setq ess-tmp-glyph 'alist)
583
 
                        (setq ess-tmp-counter ess-tmp-length))
584
 
                    ;;else
585
 
                    (setq ess-tmp-counter (+ ess-tmp-counter 1))))
586
 
 
587
 
            (if (not ess-tmp-glyph) (progn
588
 
                (ess-sas-goto-shell t)
589
 
                (insert ess-sas-submit-pre-command " "
590
 
                    ess-sas-graph-view-viewer-default " " ess-tmp-graph
591
 
                    (if (equal ess-sas-submit-method 'sh) " &"))))
592
 
 
593
 
            (comint-send-input))))))))
 
520
                        (ess-tmp-length (length ess-sas-graph-view-viewer-alist))
 
521
                        (ess-tmp-counter 0)
 
522
                        (ess-tmp-graph nil)
 
523
                        (ess-tmp-graph-alist nil)
 
524
                        (ess-tmp-glyph nil)
 
525
                        (ess-tmp-graph-regexp
 
526
                                        ; (concat "[ ]RECORDS[ ]WRITTEN[ ]+TO[ ]\n?[ ]*\\(\\(\n\\|[^.]\\)*"
 
527
                         (concat "[ ][rR][eE][cC][oO][rR][dD][sS][ ][wW][rR][iI][tT][tT][eE][nN][ ]+[tT][oO][ ]\n?[ ]*\\(.*"
 
528
                                 ess-sas-graph-view-suffix-regexp "\\)")))
 
529
                                        ;           (concat "['\"]\\(.*" ess-sas-graph-suffix-regexp "\\)['\"]")))
 
530
 
 
531
                    (save-match-data
 
532
                      (search-backward-regexp "[ \t=]" nil t)
 
533
 
 
534
                      (save-excursion
 
535
                        (setq ess-tmp-graph (ess-search-except ess-tmp-graph-regexp)))
 
536
 
 
537
                      (if (not ess-tmp-graph)
 
538
                          (setq ess-tmp-graph (ess-search-except ess-tmp-graph-regexp nil t)))
 
539
 
 
540
                      (setq ess-tmp-graph (read-string "GSASFILE: "
 
541
                                                       (or ess-tmp-graph ess-sas-file-path)))
 
542
 
 
543
                      (if (fboundp 'ess-xemacs-insert-glyph) (progn
 
544
                                                               (if (string-match "[.][gG][iI][fF]" ess-tmp-graph)
 
545
                                                                   (setq ess-tmp-glyph 'gif)
 
546
                                                                 ;;else
 
547
                                                                 (if (string-match "[.][jJ][pP][eE]?[gG]" ess-tmp-graph)
 
548
                                                                     (setq ess-tmp-glyph 'jpeg)))))
 
549
 
 
550
                      ;;GNU Emacs graphics file image viewing mode loaded?
 
551
                      (if (and (boundp 'auto-image-file-mode) auto-image-file-mode
 
552
                               (string-match "[.][jJ][pP][eE]?[gG]" ess-tmp-graph))
 
553
                          (find-file ess-tmp-graph)
 
554
                        ;;else XEmacs graphics file image viewing mode loaded?
 
555
                        (if (and (fboundp 'image-mode)
 
556
                                 (string-match "[.]\\([jJ][pP][eE]?[gG]\\|[gG][iI][fF]\\)"
 
557
                                               ess-tmp-graph))
 
558
                            (find-file ess-tmp-graph)
 
559
                          ;;else XEmacs graphics file image viewing primitives loaded?
 
560
                          (if ess-tmp-glyph (progn
 
561
                                              (switch-to-buffer (file-name-nondirectory ess-tmp-graph))
 
562
                                              (ess-xemacs-insert-glyph
 
563
                                               (make-glyph (vector ess-tmp-glyph :file ess-tmp-graph))))
 
564
 
 
565
                            ;;else use the appropriate graphics file image viewer
 
566
                            (while (< ess-tmp-counter ess-tmp-length)
 
567
                              (setq ess-tmp-graph-alist
 
568
                                    (nth ess-tmp-counter ess-sas-graph-view-viewer-alist))
 
569
                              (setq ess-tmp-graph-regexp (car ess-tmp-graph-alist))
 
570
 
 
571
                              (if (string-match
 
572
                                   (concat "[.]" ess-tmp-graph-regexp) ess-tmp-graph)
 
573
                                  (progn
 
574
                                    (ess-sas-goto-shell t)
 
575
                                    (insert ess-sas-submit-pre-command " "
 
576
                                            (cdr ess-tmp-graph-alist) " " ess-tmp-graph
 
577
                                            (if (equal ess-sas-submit-method 'sh) " &"))
 
578
                                    (setq ess-tmp-glyph 'alist)
 
579
                                    (setq ess-tmp-counter ess-tmp-length))
 
580
                                ;;else
 
581
                                (setq ess-tmp-counter (+ ess-tmp-counter 1))))
 
582
 
 
583
                            (if (not ess-tmp-glyph) (progn
 
584
                                                      (ess-sas-goto-shell t)
 
585
                                                      (insert ess-sas-submit-pre-command " "
 
586
                                                              ess-sas-graph-view-viewer-default " " ess-tmp-graph
 
587
                                                              (if (equal ess-sas-submit-method 'sh) " &"))))
 
588
 
 
589
                            (comint-send-input))))))))
594
590
 
595
591
(defun ess-sas-file-path (&optional force)
596
 
 "Define `ess-sas-file-path' to be the current buffer depending on suffix."
 
592
  "Define `ess-sas-file-path' to be the current buffer depending on suffix."
597
593
  (interactive)
598
594
 
599
595
  (save-match-data (let ((ess-sas-temp-file (expand-file-name (buffer-name))))
600
 
    (if (or force (string-match ess-sas-suffix-regexp ess-sas-temp-file)) ;;(progn
601
 
        (setq ess-sas-file-path
602
 
           (nth 0 (split-string ess-sas-temp-file "[<]")))))))
603
 
        ;; (setq ess-directory (file-name-directory ess-sas-file-path)))))))
 
596
                     (if (or force (string-match ess-sas-suffix-regexp ess-sas-temp-file)) ;;(progn
 
597
                         (setq ess-sas-file-path
 
598
                               (nth 0 (split-string ess-sas-temp-file "[<]")))))))
 
599
;; (setq ess-directory (file-name-directory ess-sas-file-path)))))))
604
600
 
605
601
(defun ess-sas-file-path-remote-host ()
606
 
"Return the remote host, if any, associated with `ess-sas-file-path'."
607
 
(interactive)
 
602
  "Return the remote host, if any, associated with `ess-sas-file-path'."
 
603
  (interactive)
608
604
 
609
 
(let* ((temp-colon-pos (string-match ":" ess-sas-file-path))
610
 
       (temp-list
611
 
        (if (or (not temp-colon-pos) (> temp-colon-pos 2))
612
 
                (if (equal ess-sas-file-path ".") nil
613
 
                    (split-string (file-name-directory ess-sas-file-path)
614
 
                        "\\(@\\|:\\|]\\)"))
615
 
        (list ess-sas-file-path)))
616
 
       (temp-list-length (length temp-list)))
 
605
  (let* ((temp-colon-pos (string-match ":" ess-sas-file-path))
 
606
         (temp-list
 
607
          (if (or (not temp-colon-pos) (> temp-colon-pos 2))
 
608
              (if (equal ess-sas-file-path ".") nil
 
609
                (split-string (file-name-directory ess-sas-file-path)
 
610
                              "\\(@\\|:\\|]\\)"))
 
611
            (list ess-sas-file-path)))
 
612
         (temp-list-length (length temp-list)))
617
613
    (if (= temp-list-length 1) (setq temp-list nil)
618
 
        (if (= temp-list-length 2) (setq temp-list (car temp-list))
619
 
            (setq temp-list (nth 1 temp-list))))
 
614
      (if (= temp-list-length 2) (setq temp-list (car temp-list))
 
615
        (setq temp-list (nth 1 temp-list))))
620
616
 
621
617
    (if temp-list (setq temp-list
622
 
                (car (last (split-string temp-list "/")))))
 
618
                        (car (last (split-string temp-list "/")))))
623
619
    temp-list))
624
620
 
625
621
(defun ess-sas-goto (suffix &optional revert no-create)
627
623
  (let ((ess-temp-regexp (concat ess-sas-suffix-regexp "\\(@.+\\)?")))
628
624
    (save-match-data
629
625
      (if (or (string-match ess-temp-regexp (expand-file-name (buffer-name)))
630
 
              (string-match ess-temp-regexp ess-sas-file-path))
631
 
          (progn
632
 
            (ess-sas-file-path)
633
 
            (let* (
634
 
                   (ess-sas-temp-file (replace-match (concat "." suffix) t t
635
 
                                                     ess-sas-file-path))
636
 
                   (ess-sas-temp-buff (find-buffer-visiting ess-sas-temp-file))
637
 
                   (ess-temp-kermit-remote-directory ess-kermit-remote-directory))
638
 
 
639
 
              (if ess-sas-temp-buff (switch-to-buffer ess-sas-temp-buff)
640
 
                ;; else
641
 
                (if no-create (setq revert nil)
642
 
                    (if (file-exists-p ess-sas-temp-file)
643
 
                        (find-file ess-sas-temp-file))))
644
 
                    ;; else
645
 
                    ;;  (let* ((ess-sas-buffer-list (buffer-list))
646
 
                    ;;         (ess-sas-buffer-list-index 0)
647
 
                    ;;         (ess-sas-buffer-list-file nil)
648
 
                    ;;         (ess-sas-buffer-list-length (length ess-sas-buffer-list)))
649
 
                    ;;      (while (< ess-sas-buffer-list-index ess-sas-buffer-list-length)
650
 
                    ;;          (setq ess-sas-buffer-list-file
651
 
                    ;;              (buffer-file-name (nth ess-sas-buffer-list-index ess-sas-buffer-list)))
652
 
                    ;;          (if (and ess-sas-buffer-list-file
653
 
                    ;;              (string-match (concat "." suffix) ess-sas-buffer-list-file))
654
 
                    ;;              (switch-to-buffer (nth ess-sas-buffer-list-index ess-sas-buffer-list))
655
 
                    ;;              (setq ess-sas-buffer-list-index ess-sas-buffer-list-length)
656
 
                    ;;          )
657
 
                    ;;          (setq ess-sas-buffer-list-index (+ 1 ess-sas-buffer-list-index))
658
 
                    ;;    )))
659
 
 
660
 
              (if (and (not no-create)
661
 
                       (or (string-equal suffix "log")
662
 
                           (string-equal suffix "lst")))
663
 
                  (ess-kermit-get (file-name-nondirectory ess-sas-temp-file)
664
 
                                  ess-temp-kermit-remote-directory))
665
 
 
666
 
              (if revert
667
 
                  (if (and (> ess-sas-log-max 0) (string-equal suffix "log")
668
 
                           (> (ess-num-or-zero (nth 7 (file-attributes ess-sas-temp-file)))
669
 
                              ess-sas-log-max))
670
 
                      (progn
671
 
                        (insert-file-contents ess-sas-temp-file nil 0
672
 
                                              ess-sas-log-max t)
673
 
                        t)
674
 
 
675
 
                    (ess-revert-wisely)) nil)))))))
 
626
              (string-match ess-temp-regexp ess-sas-file-path))
 
627
          (progn
 
628
            (ess-sas-file-path)
 
629
            (let* (
 
630
                   (ess-sas-temp-file (replace-match (concat "." suffix) t t
 
631
                                                     ess-sas-file-path))
 
632
                   (ess-sas-temp-buff (find-buffer-visiting ess-sas-temp-file))
 
633
                   (ess-temp-kermit-remote-directory ess-kermit-remote-directory))
 
634
 
 
635
              (if ess-sas-temp-buff (switch-to-buffer ess-sas-temp-buff)
 
636
                ;; else
 
637
                (if no-create (setq revert nil)
 
638
                  (if (file-exists-p ess-sas-temp-file)
 
639
                      (find-file ess-sas-temp-file))))
 
640
              ;; else
 
641
              ;;        (let* ((ess-sas-buffer-list (buffer-list))
 
642
              ;;         (ess-sas-buffer-list-index 0)
 
643
              ;;         (ess-sas-buffer-list-file nil)
 
644
              ;;         (ess-sas-buffer-list-length (length ess-sas-buffer-list)))
 
645
              ;;      (while (< ess-sas-buffer-list-index ess-sas-buffer-list-length)
 
646
              ;;                (setq ess-sas-buffer-list-file
 
647
              ;;              (buffer-file-name (nth ess-sas-buffer-list-index ess-sas-buffer-list)))
 
648
              ;;                (if (and ess-sas-buffer-list-file
 
649
              ;;              (string-match (concat "." suffix) ess-sas-buffer-list-file))
 
650
              ;;              (switch-to-buffer (nth ess-sas-buffer-list-index ess-sas-buffer-list))
 
651
              ;;              (setq ess-sas-buffer-list-index ess-sas-buffer-list-length)
 
652
              ;;                )
 
653
              ;;                (setq ess-sas-buffer-list-index (+ 1 ess-sas-buffer-list-index))
 
654
              ;;    )))
 
655
 
 
656
              (if (and (not no-create)
 
657
                       (or (string-equal suffix "log")
 
658
                           (string-equal suffix "lst")))
 
659
                  (ess-kermit-get (file-name-nondirectory ess-sas-temp-file)
 
660
                                  ess-temp-kermit-remote-directory))
 
661
 
 
662
              (if revert
 
663
                  (if (and (> ess-sas-log-max 0) (string-equal suffix "log")
 
664
                           (> (ess-num-or-zero (nth 7 (file-attributes ess-sas-temp-file)))
 
665
                              ess-sas-log-max))
 
666
                      (progn
 
667
                        (insert-file-contents ess-sas-temp-file nil 0
 
668
                                              ess-sas-log-max t)
 
669
                        t)
 
670
 
 
671
                    (ess-revert-wisely)) nil)))))))
676
672
 
677
673
;;(defun ess-sas-file (suffix &optional revert)
678
674
;;  "Please use `ess-sas-goto' instead."
679
675
;;  (let* ((tail (downcase (car (split-string
680
 
;;          (car (last (split-string (buffer-name) "[.]"))) "[<]"))))
681
 
        ;;(if (fboundp 'file-name-extension) (file-name-extension (buffer-name))
682
 
        ;;               (substring (buffer-name) -3)))
683
 
;;       (tail-in-tail-list (member tail (list "sas" "log" "lst"
684
 
;;                           ess-sas-suffix-1 ess-sas-suffix-2)))
685
 
;;       (root (if tail-in-tail-list (expand-file-name (buffer-name))
686
 
;;               ess-sas-file-path))
687
 
;;       (ess-sas-arg (concat (file-name-sans-extension root) "." suffix))
688
 
;;       (ess-sas-buf (find-buffer-visiting ess-sas-arg)))
 
676
;;          (car (last (split-string (buffer-name) "[.]"))) "[<]"))))
 
677
;;(if (fboundp 'file-name-extension) (file-name-extension (buffer-name))
 
678
;;               (substring (buffer-name) -3)))
 
679
;;       (tail-in-tail-list (member tail (list "sas" "log" "lst"
 
680
;;                           ess-sas-suffix-1 ess-sas-suffix-2)))
 
681
;;       (root (if tail-in-tail-list (expand-file-name (buffer-name))
 
682
;;               ess-sas-file-path))
 
683
;;       (ess-sas-arg (concat (file-name-sans-extension root) "." suffix))
 
684
;;       (ess-sas-buf (find-buffer-visiting ess-sas-arg)))
689
685
;;    (if (equal tail suffix) (if revert (ess-revert-wisely))
690
 
;;      (if (not ess-sas-buf) (find-file ess-sas-arg)
691
 
;;          (switch-to-buffer ess-sas-buf)
692
 
;;          (if revert (ess-revert-wisely))))))
 
686
;;      (if (not ess-sas-buf) (find-file ess-sas-arg)
 
687
;;          (switch-to-buffer ess-sas-buf)
 
688
;;          (if revert (ess-revert-wisely))))))
693
689
 
694
690
 
695
691
(defun ess-sas-goto-file-1 ()
707
703
  (interactive)
708
704
 
709
705
  (let ((ess-sas-error (concat
710
 
    "^ERROR [0-9]+-[0-9]+:\\|^ERROR:\\|_ERROR_=1 _N_=\\|_ERROR_=1[ ]?$"
711
 
    "\\|NOTE: MERGE statement has more than one data set with repeats"
712
 
    "\\|NOTE: Variable .* is uninitialized."
713
 
    "\\|NOTE: SAS went to a new line when INPUT statement reached past"
714
 
    "\\|NOTE 485-185: Informat .* was not found"
715
 
    "\\|NOTE: Estimated G matrix is not positive definite."
716
 
    "\\|NOTE: Compressing data set .* increased size by"
717
 
    "\\|NOTE: ERROR DETECTED IN ANNOTATE="
718
 
    "\\|WARNING: Apparent symbolic reference .* not resolved."
719
 
    "\\|WARNING: Length of character variable has already been set."
720
 
    "\\|WARNING: Not all variables in the list "
721
 
    "\\|WARNING: RUN statement ignored due to previous errors."
722
 
    "\\|WARNING: Values exist outside the axis range"
723
 
    "\\|Bus Error In Task\\|Segmentation Violation In Task"))
724
 
        (ess-sas-save-point nil)); (ess-sas-pop-mark nil))
725
 
 
726
 
  (if (ess-sas-goto "log" 'revert) (progn
727
 
        (setq ess-sas-save-point (point))
728
 
        (goto-char (point-min)))
729
 
    (setq ess-sas-save-point (point)))
730
 
 
731
 
;(if (number-char-or-marker-p ess-sas-save-point) (progn
732
 
(if ess-tmp-no-error-check (goto-char ess-sas-save-point)
733
 
  (if (or (search-forward-regexp ess-sas-error nil t)
734
 
        (and (goto-char (point-min))
735
 
            (search-forward-regexp ess-sas-error nil t)))
736
 
                t
737
 
; this feature never worked quite right (and was XEmacs only to boot)
738
 
; after highlighting an error message, moving point would cause an unwanted
739
 
; highlighting between point and mark; why god, why?!?
740
 
;
741
 
;       (if (and (boundp 'zmacs-regions) zmacs-regions)
742
 
;           (progn
743
 
;               (if ess-sas-pop-mark (pop-mark)
744
 
;                   (setq ess-sas-pop-mark t))
745
 
;               (push-mark (match-beginning 0) t)
746
 
;               (zmacs-activate-region)))
747
 
        (goto-char ess-sas-save-point)))))
 
706
                        "^ERROR [0-9]+-[0-9]+:\\|^ERROR:\\|_ERROR_=1 _N_=\\|_ERROR_=1[ ]?$"
 
707
                        "\\|NOTE: MERGE statement has more than one data set with repeats"
 
708
                        "\\|NOTE: Variable .* is uninitialized."
 
709
                        "\\|NOTE: SAS went to a new line when INPUT statement reached past"
 
710
                        "\\|NOTE 485-185: Informat .* was not found"
 
711
                        "\\|NOTE: Estimated G matrix is not positive definite."
 
712
                        "\\|NOTE: Compressing data set .* increased size by"
 
713
                        "\\|NOTE: ERROR DETECTED IN ANNOTATE="
 
714
                        "\\|WARNING: Apparent symbolic reference .* not resolved."
 
715
                        "\\|WARNING: Length of character variable has already been set."
 
716
                        "\\|WARNING: Not all variables in the list "
 
717
                        "\\|WARNING: RUN statement ignored due to previous errors."
 
718
                        "\\|WARNING: Values exist outside the axis range"
 
719
                        "\\|Bus Error In Task\\|Segmentation Violation In Task"))
 
720
        (ess-sas-save-point nil)); (ess-sas-pop-mark nil))
 
721
 
 
722
    (if (ess-sas-goto "log" 'revert) (progn
 
723
                                       (setq ess-sas-save-point (point))
 
724
                                       (goto-char (point-min)))
 
725
      (setq ess-sas-save-point (point)))
 
726
 
 
727
                                        ;(if (number-char-or-marker-p ess-sas-save-point) (progn
 
728
    (if ess-tmp-no-error-check (goto-char ess-sas-save-point)
 
729
      (if (or (search-forward-regexp ess-sas-error nil t)
 
730
              (and (goto-char (point-min))
 
731
                   (search-forward-regexp ess-sas-error nil t)))
 
732
          t
 
733
                                        ; this feature never worked quite right (and was XEmacs only to boot)
 
734
                                        ; after highlighting an error message, moving point would cause an unwanted
 
735
                                        ; highlighting between point and mark; why god, why?!?
 
736
                                        ;
 
737
                                        ;       (if (and (boundp 'zmacs-regions) zmacs-regions)
 
738
                                        ;           (progn
 
739
                                        ;               (if ess-sas-pop-mark (pop-mark)
 
740
                                        ;                   (setq ess-sas-pop-mark t))
 
741
                                        ;               (push-mark (match-beginning 0) t)
 
742
                                        ;               (zmacs-activate-region)))
 
743
        (goto-char ess-sas-save-point)))))
748
744
 
749
745
(defun ess-sas-goto-lst ()
750
746
  "Switch to the .lst file and revert from disk."
757
753
  (ess-sas-goto "sas" revert))
758
754
 
759
755
(defun ess-sas-goto-shell (&optional set-buffer)
760
 
"Set `ess-sas-file-path' and goto `ess-sas-shell-buffer'.  If
 
756
  "Set `ess-sas-file-path' and goto `ess-sas-shell-buffer'.  If
761
757
optional argument is non-nil, then set-buffer rather than switch."
762
758
  (interactive)
763
759
  (ess-sas-file-path)
764
760
 
765
 
; The following let* block is an attempt to deal with remote directories.
766
 
    (let* ((temp-shell-buffer-remote-host
767
 
            (or ess-sas-shell-buffer-remote-host (ess-sas-file-path-remote-host)))
768
 
        (temp-shell-buffer-remote-init ess-sas-shell-buffer-remote-init)
769
 
        (temp-shell-buffer
770
 
            (if temp-shell-buffer-remote-host
771
 
                (concat "*" temp-shell-buffer-remote-host "*")
772
 
                ess-sas-shell-buffer))
773
 
)
774
 
 
775
 
  (if (get-buffer temp-shell-buffer)
776
 
    (if set-buffer (set-buffer temp-shell-buffer)
777
 
                   (switch-to-buffer temp-shell-buffer))
778
 
    (shell)
779
 
    (rename-buffer temp-shell-buffer)
780
 
    (ess-sleep) ; GNU Emacs needs this
781
 
 
782
 
    (if temp-shell-buffer-remote-host (progn
783
 
        (insert (concat
784
 
            temp-shell-buffer-remote-init " " temp-shell-buffer-remote-host))
785
 
        (comint-send-input))
786
 
    )
787
 
 
788
 
    (if (eq ess-sas-submit-method 'sh)
789
 
        (add-hook 'comint-output-filter-functions 'ess-exit-notify-sh)) ;; 19.28
790
 
                                          ;; nil t) works for newer emacsen
791
 
    )
 
761
                                        ; The following let* block is an attempt to deal with remote directories.
 
762
  (let* ((temp-shell-buffer-remote-host
 
763
          (or ess-sas-shell-buffer-remote-host (ess-sas-file-path-remote-host)))
 
764
         (temp-shell-buffer-remote-init ess-sas-shell-buffer-remote-init)
 
765
         (temp-shell-buffer
 
766
          (if temp-shell-buffer-remote-host
 
767
              (concat "*" temp-shell-buffer-remote-host "*")
 
768
            ess-sas-shell-buffer))
 
769
         )
 
770
 
 
771
    (if (get-buffer temp-shell-buffer)
 
772
        (if set-buffer (set-buffer temp-shell-buffer)
 
773
          (switch-to-buffer temp-shell-buffer))
 
774
      (shell)
 
775
      (rename-buffer temp-shell-buffer)
 
776
      (ess-sleep) ; GNU Emacs needs this
 
777
 
 
778
      (if temp-shell-buffer-remote-host (progn
 
779
                                          (insert (concat
 
780
                                                   temp-shell-buffer-remote-init " " temp-shell-buffer-remote-host))
 
781
                                          (comint-send-input))
 
782
        )
 
783
 
 
784
      (if (eq ess-sas-submit-method 'sh)
 
785
          (add-hook 'comint-output-filter-functions 'ess-exit-notify-sh)) ;; 19.28
 
786
      ;; nil t) works for newer emacsen
 
787
      )
 
788
    )
 
789
 
 
790
  (goto-char (point-max))
 
791
                                        ; (insert "cd " ess-temp-directory)
 
792
                                        ; (comint-send-input))
792
793
  )
793
794
 
794
 
  (goto-char (point-max))
795
 
; (insert "cd " ess-temp-directory)
796
 
; (comint-send-input))
797
 
)
798
 
 
799
795
(defun ess-sas-interactive ()
800
 
"And now for something completely different."
801
 
    (interactive)
802
 
    (ess-sas-file-path)
 
796
  "And now for something completely different."
 
797
  (interactive)
 
798
  (ess-sas-file-path)
803
799
 
804
 
    (let ((ess-temp-sas-file
805
 
(nth 0 (split-string
806
 
(car (last (split-string ess-sas-file-path "\\([a-zA-Z][a-zA-Z]:\\|]\\)"))) "[.]"))))
807
 
;;    (message "%s" ess-temp-sas-file)
 
800
  (let ((ess-temp-sas-file
 
801
         (nth 0 (split-string
 
802
                 (car (last (split-string ess-sas-file-path "\\([a-zA-Z][a-zA-Z]:\\|]\\)"))) "[.]"))))
 
803
    ;;    (message "%s" ess-temp-sas-file)
808
804
    (setq ess-sas-shell-buffer "*iESS[SAS]*")
809
805
    (ess-sas-goto-shell)
810
806
    (insert (concat ess-sas-submit-command " " ess-sas-submit-command-options
811
 
        " -altlog " ess-temp-sas-file ".log -altprint "
812
 
            ess-temp-sas-file ".lst -stdio < /dev/tty"))
 
807
                    " -altlog " ess-temp-sas-file ".log -altprint "
 
808
                    ess-temp-sas-file ".lst -stdio < /dev/tty"))
813
809
    (comint-send-input)
814
810
    (ess-add-ess-process)
815
811
    (ess-sas-goto-sas)
816
812
    (setq ess-sas-submit-method 'iESS)
817
813
    (setq ess-eval-visibly-p nil)
818
 
))
 
814
    ))
819
815
;;(defun ess-sas-interactive ()
820
816
;;    (interactive)
821
817
;;    (ess-sas-file-path)
844
840
;;    (sleep-for ess-sleep-for)
845
841
;;    (save-excursion (setq ess-temp-stdin (ess-search-except "\\(/dev/[a-z0-9/]+\\)" nil t)))
846
842
;;    (insert (concat ess-sas-submit-command " " ess-sas-submit-command-options " -stdio <"
847
 
;;      ess-temp-stdin " >1 " ess-temp-stdout " >2 " ess-temp-stderr))
 
843
;;      ess-temp-stdin " >1 " ess-temp-stdout " >2 " ess-temp-stderr))
848
844
;;    (comint-send-input)
849
845
;;    (ess-add-ess-process)
850
846
;;    (ess-sas-goto-sas)
851
847
;;))
852
848
 
853
849
(defun ess-sas-kill-buffers ()
854
 
"Kill all buffers related to a .sas file."
 
850
  "Kill all buffers related to a .sas file."
855
851
  (interactive)
856
852
  (ess-sas-file-path)
857
853
  (ess-sas-goto "log" nil t)
864
860
  (kill-buffer nil)
865
861
  (ess-sas-goto "sas" nil t)
866
862
  (kill-buffer nil)
867
 
)
 
863
  )
868
864
 
869
 
;  (condition-case nil
870
 
;      (progn
871
 
;        (require 'rtf-support)
872
 
;        (when (featurep 'rtf-support)
 
865
                                        ;  (condition-case nil
 
866
                                        ;      (progn
 
867
                                        ;        (require 'rtf-support)
 
868
                                        ;        (when (featurep 'rtf-support)
873
869
 
874
870
(defun ess-rtf-replace-chars ()
875
 
"Convert a text file to an MS RTF file."
 
871
  "Convert a text file to an MS RTF file."
876
872
  (interactive)
877
873
  (goto-char (point-min))
878
874
  (while (re-search-forward "\n" nil t) (replace-match "\\par\n" nil t))
882
878
  (while (re-search-forward "\t" nil t) (replace-match "\\tab" nil t)))
883
879
 
884
880
(defun ess-sas-rtf-portrait (&optional ess-tmp-font-size)
885
 
"Creates an MS RTF portrait file from the current buffer."
886
 
    (interactive)
887
 
    (ess-sas-file-path t)
888
 
    (ess-revert-wisely)
889
 
 
890
 
;    (if (equal ess-tmp-font-size nil)
891
 
;       (setq ess-tmp-font-size "21"))
892
 
 
893
 
    (let
894
 
        ((ess-temp-rtf-file 
895
 
          (replace-regexp-in-string "[.][^.]*$" ".rtf" ess-sas-file-path)))
896
 
        ;(rtf-export ess-temp-rtf-file)
897
 
        (copy-file ess-sas-file-path ess-temp-rtf-file t)
898
 
        (ess-sas-goto "rtf" t)
899
 
        (ess-rtf-replace-chars)
900
 
        ;(goto-char (point-min))
901
 
        ;;(replace-regexp "\\\\fmodern .*;" (concat "\\\\fmodern " ess-sas-rtf-font-name ";"))
902
 
        ;(if (re-search-forward "\\\\fmodern .*;" nil t)
903
 
        ;    (replace-match (concat "\\\\fmodern " ess-sas-rtf-font-name ";") nil nil))
904
 
        ;(goto-line 2)
905
 
        (goto-char (point-min)) 
906
 
        (insert (concat
907
 
                 "{\\rtf1\\ansi{\\fonttbl\\f1\\fmodern " ess-sas-rtf-font-name ";}\n"
908
 
                 "\\margl720\\margr720\\margt720\\margb720\n"
909
 
                 "{\\colortbl;\\red0\\green0\\blue0;\\red0\\green0\\blue255;\\red0\\green255\\blue255;\\red0\\green255\\blue0;\\red255\\green0\\blue255;\\red255\\green0\\blue0;\\red255\\green255\\blue0;\\red255\\green255\\blue255;\\red0\\green0\\blue128;\\red0\\green128\\blue128;\\red0\\green128\\blue0;\\red128\\green0\\blue128;\\red128\\green0\\blue0;\\red128\\green128\\blue0;\\red128\\green128\\blue128;\\red192\\green192\\blue192;}\n"
910
 
                 "{\\stylesheet{\\s15\\plain\\f1\\fs16\\cf1\\cb8\\lang1024 Emacs Text;}{\\*\\cs16 \\additive\\f1\\fs16\\cf1\\cb8\\lang1024 Emacs Base Style;}}\n"
911
 
                 "{\\plain\\s15{\\cs16\\cs16\\f1\\fs16\\cf1\\cb8\\lang1024{\\cs16\\f1\\fs16\\cf1\\cb8\\lang1024\n"))        
912
 
 
913
 
        (goto-char (point-max))
914
 
        (insert "}}}}\n")
915
 
        ;(goto-char (point-min))
916
 
        ;;(while (replace-regexp "\\\\fs[0-9]+" (concat "\\\\fs" ess-tmp-font-size)) nil)
917
 
        ;(while (re-search-forward "\\\\fs[0-9]+" nil t)
918
 
        ;  (replace-match (concat "\\\\fs" ess-tmp-font-size) nil nil))
919
 
        (save-buffer)
920
 
        (kill-buffer (current-buffer))))
 
881
  "Creates an MS RTF portrait file from the current buffer."
 
882
  (interactive)
 
883
  (ess-sas-file-path t)
 
884
  (ess-revert-wisely)
 
885
 
 
886
                                        ;    (if (equal ess-tmp-font-size nil)
 
887
                                        ;       (setq ess-tmp-font-size "21"))
 
888
 
 
889
  (let
 
890
      ((ess-temp-rtf-file
 
891
        (replace-regexp-in-string "[.][^.]*$" ".rtf" ess-sas-file-path)))
 
892
                                        ;(rtf-export ess-temp-rtf-file)
 
893
    (copy-file ess-sas-file-path ess-temp-rtf-file t)
 
894
    (ess-sas-goto "rtf" t)
 
895
    (ess-rtf-replace-chars)
 
896
                                        ;(goto-char (point-min))
 
897
    ;;(replace-regexp "\\\\fmodern .*;" (concat "\\\\fmodern " ess-sas-rtf-font-name ";"))
 
898
                                        ;(if (re-search-forward "\\\\fmodern .*;" nil t)
 
899
                                        ;    (replace-match (concat "\\\\fmodern " ess-sas-rtf-font-name ";") nil nil))
 
900
                                        ;(goto-line 2)
 
901
    (goto-char (point-min))
 
902
    (insert (concat
 
903
             "{\\rtf1\\ansi{\\fonttbl\\f1\\fmodern " ess-sas-rtf-font-name ";}\n"
 
904
             "\\margl720\\margr720\\margt720\\margb720\n"
 
905
             "{\\colortbl;\\red0\\green0\\blue0;\\red0\\green0\\blue255;\\red0\\green255\\blue255;\\red0\\green255\\blue0;\\red255\\green0\\blue255;\\red255\\green0\\blue0;\\red255\\green255\\blue0;\\red255\\green255\\blue255;\\red0\\green0\\blue128;\\red0\\green128\\blue128;\\red0\\green128\\blue0;\\red128\\green0\\blue128;\\red128\\green0\\blue0;\\red128\\green128\\blue0;\\red128\\green128\\blue128;\\red192\\green192\\blue192;}\n"
 
906
             "{\\stylesheet{\\s15\\plain\\f1\\fs16\\cf1\\cb8\\lang1024 Emacs Text;}{\\*\\cs16 \\additive\\f1\\fs16\\cf1\\cb8\\lang1024 Emacs Base Style;}}\n"
 
907
             "{\\plain\\s15{\\cs16\\cs16\\f1\\fs16\\cf1\\cb8\\lang1024{\\cs16\\f1\\fs16\\cf1\\cb8\\lang1024\n"))
 
908
 
 
909
    (goto-char (point-max))
 
910
    (insert "}}}}\n")
 
911
                                        ;(goto-char (point-min))
 
912
    ;;(while (replace-regexp "\\\\fs[0-9]+" (concat "\\\\fs" ess-tmp-font-size)) nil)
 
913
                                        ;(while (re-search-forward "\\\\fs[0-9]+" nil t)
 
914
                                        ;  (replace-match (concat "\\\\fs" ess-tmp-font-size) nil nil))
 
915
    (save-buffer)
 
916
    (kill-buffer (current-buffer))))
921
917
 
922
918
(defun ess-sas-rtf-us-landscape ()
923
 
"Creates an MS RTF US landscape file from the current buffer."
924
 
    (interactive)
925
 
    (ess-sas-rtf-portrait "16")
926
 
    (ess-sas-goto "rtf" t)
927
 
    (goto-char (point-min))
928
 
    (forward-line 3)
929
 
    (insert (concat "{\\*\\pgdsctbl\n"
930
 
"{\\pgdsc0\\pgdscuse195\\lndscpsxn\\pgwsxn15840\\pghsxn12240\\marglsxn1800\\margrsxn1800\\margtsxn1440\\margbsxn1440\\pgdscnxt0 Default;}}\n"
931
 
"\\landscape\\paperh12240\\paperw15840\\margl1800\\margr1800\\margt1440\\margb1440\\sectd\\sbknone\\lndscpsxn\\pgwsxn15840\\pghsxn12240\\marglsxn1800\\margrsxn1800\\margtsxn1440\\margbsxn1440\\ftnbj\\ftnstart1\\ftnrstcont\\ftnnar\\aenddoc\\aftnrstcont\\aftnstart1\\aftnnrlc\n"))
932
 
    (save-buffer)
933
 
    (kill-buffer (current-buffer)))
 
919
  "Creates an MS RTF US landscape file from the current buffer."
 
920
  (interactive)
 
921
  (ess-sas-rtf-portrait "16")
 
922
  (ess-sas-goto "rtf" t)
 
923
  (goto-char (point-min))
 
924
  (forward-line 3)
 
925
  (insert (concat "{\\*\\pgdsctbl\n"
 
926
                  "{\\pgdsc0\\pgdscuse195\\lndscpsxn\\pgwsxn15840\\pghsxn12240\\marglsxn1800\\margrsxn1800\\margtsxn1440\\margbsxn1440\\pgdscnxt0 Default;}}\n"
 
927
                  "\\landscape\\paperh12240\\paperw15840\\margl1800\\margr1800\\margt1440\\margb1440\\sectd\\sbknone\\lndscpsxn\\pgwsxn15840\\pghsxn12240\\marglsxn1800\\margrsxn1800\\margtsxn1440\\margbsxn1440\\ftnbj\\ftnstart1\\ftnrstcont\\ftnnar\\aenddoc\\aftnrstcont\\aftnstart1\\aftnnrlc\n"))
 
928
  (save-buffer)
 
929
  (kill-buffer (current-buffer)))
934
930
 
935
931
(defun ess-sas-rtf-a4-landscape ()
936
 
"Creates an MS RTF A4 landscape file from the current buffer."
937
 
    (interactive)
938
 
    (ess-sas-rtf-portrait "16")
939
 
    (ess-sas-goto "rtf" t)
940
 
    (goto-char (point-min))
941
 
    (forward-line 3)
942
 
    (insert (concat "{\\*\\pgdsctbl\n"
943
 
"{\\pgdsc0\\pgdscuse195\\lndscpsxn\\pgwsxn16837\\pghsxn11905\\marglsxn1800\\margrsxn1800\\margtsxn1440\\margbsxn1440\\pgdscnxt0 Default;}}\n"
944
 
"\\landscape\\paperh11905\\paperw16837\\margl1800\\margr1800\\margt1440\\margb1440\\sectd\\sbknone\\lndscpsxn\\pgwsxn16837\\pghsxn11905\\marglsxn1800\\margrsxn1800\\margtsxn1440\\margbsxn1440\\ftnbj\\ftnstart1\\ftnrstcont\\ftnnar\\aenddoc\\aftnrstcont\\aftnstart1\\aftnnrlc\n"))
945
 
    (save-buffer)
946
 
    (kill-buffer (current-buffer)))
947
 
;))
948
 
;    (error nil)) 
 
932
  "Creates an MS RTF A4 landscape file from the current buffer."
 
933
  (interactive)
 
934
  (ess-sas-rtf-portrait "16")
 
935
  (ess-sas-goto "rtf" t)
 
936
  (goto-char (point-min))
 
937
  (forward-line 3)
 
938
  (insert (concat "{\\*\\pgdsctbl\n"
 
939
                  "{\\pgdsc0\\pgdscuse195\\lndscpsxn\\pgwsxn16837\\pghsxn11905\\marglsxn1800\\margrsxn1800\\margtsxn1440\\margbsxn1440\\pgdscnxt0 Default;}}\n"
 
940
                  "\\landscape\\paperh11905\\paperw16837\\margl1800\\margr1800\\margt1440\\margb1440\\sectd\\sbknone\\lndscpsxn\\pgwsxn16837\\pghsxn11905\\marglsxn1800\\margrsxn1800\\margtsxn1440\\margbsxn1440\\ftnbj\\ftnstart1\\ftnrstcont\\ftnnar\\aenddoc\\aftnrstcont\\aftnstart1\\aftnnrlc\n"))
 
941
  (save-buffer)
 
942
  (kill-buffer (current-buffer)))
 
943
                                        ;))
 
944
                                        ;    (error nil))
949
945
 
950
946
(defun ess-sas-submit ()
951
947
  "Save the .sas file and submit to shell using a function that
955
951
  (ess-sas-goto-sas)
956
952
  (save-buffer)
957
953
  (hack-local-variables)
958
 
  ;(ess-save-and-set-local-variables)
 
954
                                        ;(ess-save-and-set-local-variables)
959
955
 
960
956
  (cond
961
957
   ((eq ess-sas-submit-method 'apple-script)
962
 
        (ess-sas-submit-mac ess-sas-submit-command
963
 
            ess-sas-submit-command-options))
 
958
    (ess-sas-submit-mac ess-sas-submit-command
 
959
                        ess-sas-submit-command-options))
964
960
   ((eq ess-sas-submit-method 'ms-dos)
965
 
        (ess-sas-submit-windows ess-sas-submit-command
966
 
            ess-sas-submit-command-options))
 
961
    (ess-sas-submit-windows ess-sas-submit-command
 
962
                            ess-sas-submit-command-options))
967
963
   ((eq ess-sas-submit-method 'iESS)
968
 
        (ess-sas-submit-iESS ess-sas-submit-command
969
 
            ess-sas-submit-command-options))
 
964
    (ess-sas-submit-iESS ess-sas-submit-command
 
965
                         ess-sas-submit-command-options))
970
966
   ((eq ess-sas-submit-method 'sh)
971
 
        (ess-sas-submit-sh ess-sas-submit-command
972
 
            ess-sas-submit-command-options))
 
967
    (ess-sas-submit-sh ess-sas-submit-command
 
968
                       ess-sas-submit-command-options))
973
969
   (t (ess-sas-submit-sh ess-sas-submit-command
974
 
        ess-sas-submit-command-options)))
975
 
;  (ess-sas-goto-sas)
976
 
)
 
970
                         ess-sas-submit-command-options)))
 
971
                                        ;  (ess-sas-goto-sas)
 
972
  )
977
973
 
978
974
(defun ess-sas-submit-iESS (arg1 arg2)
979
975
  "iESS
991
987
their files from the remote computer.  Local copies of the .sas .lst
992
988
.log and others may be made manually with `write-buffer'."
993
989
  ;;  (ess-eval-linewise (concat "cd  default-directory))
994
 
  (ess-force-buffer-current "Process to load into: ")
995
 
  (ess-eval-linewise
996
 
    (concat "cd " (car (last
997
 
        (split-string (file-name-directory ess-sas-file-path) "\\(:\\|]\\)")))))
998
 
  (ess-eval-linewise (concat arg1 " " arg2 " " (buffer-name) " &")))
 
990
(ess-force-buffer-current "Process to load into: ")
 
991
(ess-eval-linewise
 
992
 (concat "cd " (car (last
 
993
                     (split-string (file-name-directory ess-sas-file-path) "\\(:\\|]\\)")))))
 
994
(ess-eval-linewise (concat arg1 " " arg2 " " (buffer-name) " &")))
999
995
 
1000
996
(defun ess-sas-submit-mac (arg1 arg2)
1001
 
"If you are using Mac SAS, then arg1, `ess-sas-submit-command', should be
 
997
  "If you are using Mac SAS, then arg1, `ess-sas-submit-command', should be
1002
998
the AppleScript command \"invoke SAS using program file\", and, if necessary,
1003
999
arg2, `ess-sas-submit-command-options', is a string of the form
1004
1000
\"with options { \\\"option-1\\\", \\\"option-2\\\", etc.}\".  If you are
1005
1001
using Windows SAS with the PC emulator Virtual PC, then `ess-sas-submit-command'
1006
1002
should be ..."
1007
 
  ;(ess-save-and-set-local-variables)
 
1003
                                        ;(ess-save-and-set-local-variables)
1008
1004
 
1009
1005
  (do-applescript (concat arg1 " \""
1010
 
     (if (not ess-sas-submit-mac-virtual-pc)
1011
 
            (unix-filename-to-mac default-directory))
1012
 
        (buffer-name) "\"" arg2)))
 
1006
                          (if (not ess-sas-submit-mac-virtual-pc)
 
1007
                              (unix-filename-to-mac default-directory))
 
1008
                          (buffer-name) "\"" arg2)))
1013
1009
 
1014
1010
(defun ess-sas-submit-region ()
1015
 
    "Write region to temporary file, and submit to SAS."
1016
 
    (interactive)
1017
 
    (ess-sas-file-path)
1018
 
    (hack-local-variables t)
1019
 
    (write-region (region-beginning) (region-end)
1020
 
        (concat (ess-sas-temp-root) ".sas"))
 
1011
  "Write region to temporary file, and submit to SAS."
 
1012
  (interactive)
 
1013
  (ess-sas-file-path)
 
1014
  (hack-local-variables t)
 
1015
  (write-region (region-beginning) (region-end)
 
1016
                (concat (ess-sas-temp-root) ".sas"))
1021
1017
 
1022
 
    (let ((arg1 ess-sas-submit-command)
1023
 
          (arg2 ess-sas-submit-command-options))
 
1018
  (let ((arg1 ess-sas-submit-command)
 
1019
        (arg2 ess-sas-submit-command-options))
1024
1020
    (save-excursion
1025
1021
      (ess-sas-goto-shell t)
1026
1022
 
1027
 
    (if (and (w32-shell-dos-semantics)
1028
 
        (string-equal ":" (substring ess-sas-file-path 1 2)))
1029
 
        (progn
1030
 
                (insert (substring ess-sas-file-path 0 2))
1031
 
                (comint-send-input)
1032
 
    ))
1033
 
 
1034
 
    (insert "cd \"" (convert-standard-filename
1035
 
        (file-name-directory ess-sas-file-path)) "\"")
1036
 
    (comint-send-input)
1037
 
 
1038
 
    (insert (concat ess-sas-submit-pre-command " " arg1
1039
 
          " " arg2
1040
 
          " " (ess-sas-temp-root) " " ess-sas-submit-post-command))
1041
 
    (comint-send-input)
1042
 
    ))
1043
 
)
 
1023
      (if (and (w32-shell-dos-semantics)
 
1024
               (string-equal ":" (substring ess-sas-file-path 1 2)))
 
1025
          (progn
 
1026
            (insert (substring ess-sas-file-path 0 2))
 
1027
            (comint-send-input)
 
1028
            ))
 
1029
 
 
1030
      (insert "cd \"" (convert-standard-filename
 
1031
                       (file-name-directory ess-sas-file-path)) "\"")
 
1032
      (comint-send-input)
 
1033
 
 
1034
      (insert (concat ess-sas-submit-pre-command " " arg1
 
1035
                      " " arg2
 
1036
                      " " (ess-sas-temp-root) " " ess-sas-submit-post-command))
 
1037
      (comint-send-input)
 
1038
      ))
 
1039
  )
1044
1040
 
1045
1041
(defun ess-sas-submit-sh (arg1 arg2)
1046
1042
  "Unix or bash in the *shell* buffer.
1049
1045
SAS or you can specify the PATHNAME (PATHNAME can NOT contain spaces),
1050
1046
i.e. let arg1 be your local equivalent of
1051
1047
\"/usr/local/sas612/sas\"."
1052
 
    (if (string-equal (substring
1053
 
            (file-name-nondirectory ess-sas-file-path) 0 1) ess-kermit-prefix)
 
1048
  (if (string-equal (substring
 
1049
                     (file-name-nondirectory ess-sas-file-path) 0 1) ess-kermit-prefix)
1054
1050
      (progn
1055
 
       (ess-kermit-send)
1056
 
       (ess-sas-goto-shell t)
1057
 
       (insert ess-sas-submit-pre-command " " arg1 " "
1058
 
         (substring (file-name-sans-extension
1059
 
            (file-name-nondirectory ess-sas-file-path)) 1)
1060
 
         " " arg2 " " ess-sas-submit-post-command)
1061
 
        (comint-send-input))
 
1051
        (ess-kermit-send)
 
1052
        (ess-sas-goto-shell t)
 
1053
        (insert ess-sas-submit-pre-command " " arg1 " "
 
1054
                (substring (file-name-sans-extension
 
1055
                            (file-name-nondirectory ess-sas-file-path)) 1)
 
1056
                " " arg2 " " ess-sas-submit-post-command)
 
1057
        (comint-send-input))
1062
1058
    ;;else
1063
 
      (ess-sas-goto-shell t)
1064
 
      (ess-sas-cd)
1065
 
;      (insert "cd " (car (last (split-string (file-name-directory ess-sas-file-path)
1066
 
;"\\([a-zA-Z][a-zA-Z]:\\|]\\)"))))
1067
 
;      (comint-send-input)
1068
 
      (insert ess-sas-submit-pre-command " " arg1 " "
1069
 
        (file-name-sans-extension (file-name-nondirectory ess-sas-file-path))
1070
 
        " " arg2 " " ess-sas-submit-post-command))
1071
 
;    (ess-sleep)
1072
 
    (comint-send-input))
 
1059
    (ess-sas-goto-shell t)
 
1060
    (ess-sas-cd)
 
1061
                                        ;      (insert "cd " (car (last (split-string (file-name-directory ess-sas-file-path)
 
1062
                                        ;"\\([a-zA-Z][a-zA-Z]:\\|]\\)"))))
 
1063
                                        ;      (comint-send-input)
 
1064
    (insert ess-sas-submit-pre-command " " arg1 " "
 
1065
            (file-name-sans-extension (file-name-nondirectory ess-sas-file-path))
 
1066
            " " arg2 " " ess-sas-submit-post-command))
 
1067
                                        ;    (ess-sleep)
 
1068
  (comint-send-input))
1073
1069
 
1074
1070
(defun ess-sas-submit-windows (arg1 arg2)
1075
1071
  "Windows using MS-DOS prompt in the *shell* buffer.
1084
1080
`ess-sas-submit-command' be \"\\\"C:\\Program Files\\SAS\\sas.exe\\\"\".
1085
1081
Keep in mind that the maximum command line length in MS-DOS is
1086
1082
127 characters so altering your PATH is preferable."
1087
 
    ;(ess-save-and-set-local-variables)
1088
 
    (ess-sas-goto-shell t)
1089
 
    (if (string-equal ":" (substring ess-sas-file-path 1 2))
1090
 
        (progn
1091
 
                (insert (substring ess-sas-file-path 0 2))
1092
 
                (comint-send-input)
1093
 
        )
 
1083
                                        ;(ess-save-and-set-local-variables)
 
1084
  (ess-sas-goto-shell t)
 
1085
  (if (string-equal ":" (substring ess-sas-file-path 1 2))
 
1086
      (progn
 
1087
        (insert (substring ess-sas-file-path 0 2))
 
1088
        (comint-send-input)
 
1089
        )
1094
1090
    )
1095
 
    (insert "cd \"" (convert-standard-filename
1096
 
        (file-name-directory ess-sas-file-path)) "\"")
1097
 
    (comint-send-input)
1098
 
    (insert ess-sas-submit-pre-command " " arg1 " -sysin \""
1099
 
        (file-name-sans-extension (file-name-nondirectory ess-sas-file-path)) "\" "
1100
 
        arg2 " " ess-sas-submit-post-command)
1101
 
    (comint-send-input))
 
1091
  (insert "cd \"" (convert-standard-filename
 
1092
                   (file-name-directory ess-sas-file-path)) "\"")
 
1093
  (comint-send-input)
 
1094
  (insert ess-sas-submit-pre-command " " arg1 " -sysin \""
 
1095
          (file-name-sans-extension (file-name-nondirectory ess-sas-file-path)) "\" "
 
1096
          arg2 " " ess-sas-submit-post-command)
 
1097
  (comint-send-input))
1102
1098
 
1103
1099
(defun ess-sas-tab-to-tab-stop ()
1104
1100
  "Tab to next tab-stop and set left margin."
1105
1101
  (interactive)
1106
1102
  (tab-to-tab-stop)
1107
1103
  (setq left-margin (current-column))
1108
 
)
 
1104
  )
1109
1105
 
1110
1106
(defun ess-sas-temp-root ()
1111
 
"Return `ess-sas-file-path' sans extension with `ess-sas-temp-root' appended."
1112
 
(concat (file-name-sans-extension ess-sas-file-path) ess-sas-temp-root))
 
1107
  "Return `ess-sas-file-path' sans extension with `ess-sas-temp-root' appended."
 
1108
  (concat (file-name-sans-extension ess-sas-file-path) ess-sas-temp-root))
1113
1109
 
1114
1110
(defun ess-sas-transcript (&optional strip)
1115
 
"Comment .log messages to create a .sas program; use C-u to strip."
1116
 
(interactive "P")
1117
 
(save-excursion
 
1111
  "Comment .log messages to create a .sas program; use C-u to strip."
 
1112
  (interactive "P")
 
1113
  (save-excursion
1118
1114
    (goto-char (point-min))
1119
1115
 
1120
1116
    (while (search-forward-regexp (concat
1121
 
           "^\\(\\(1[ \t]+The SAS System\\| \\|NOTE\\|WARNING\\|ERROR\\|"
1122
 
           "[ \t]+\\(\\(real\\|cpu\\) time\\|Licensed to\\|Engine:\\|"
1123
 
           "Physical Name:\\|File Name=\\|Owner Name=\\|Group Name=\\|"
1124
 
           "Access Permission=\\|File Size (bytes)=\\|Pipe command=\\|"
1125
 
           "RECFM=[DFNPV],LRECL=\\|[0-9]+:[0-9]+[ /t]+[0-9]+:[0-9]+\\|"
1126
 
           "[1-9][0-9]* at [0-9]+:[0-9]+[ /t]+[1-9][0-9]* at [0-9]+:[0-9]+\\)\\).*$"
1127
 
           "\\|[0-9]+\\([ \t]+!\\)?\\|MPRINT([_A-Z]+):\\|"
1128
 
           "[ \t]+\\(values at the places given by: (Line):(Column).\\|"
1129
 
           "The m\\(in\\|ax\\)imum record length was [1-9][0-9]*.\\|"
1130
 
           "One or more lines were truncated.\\|"
1131
 
           "Each place is given by: (Number of times) at (Line):(Column).\\|"
1132
 
           "[0-9][0-9]:[0-9][0-9] [MTWFS][aeioudhnrst]+day, [JFMASOND]"
1133
 
           "[aeiouybcghlmnprstv]+ [1-9][0-9]?, 20[0-9][0-9]\\)\\)")
1134
 
           nil t) (replace-match (if strip " " "/*\\&*/") t))
1135
 
))
 
1117
                                   "^\\(\\(1[ \t]+The SAS System\\| \\|NOTE\\|WARNING\\|ERROR\\|"
 
1118
                                   "[ \t]+\\(\\(real\\|cpu\\) time\\|Licensed to\\|Engine:\\|"
 
1119
                                   "Physical Name:\\|File Name=\\|Owner Name=\\|Group Name=\\|"
 
1120
                                   "Access Permission=\\|File Size (bytes)=\\|Pipe command=\\|"
 
1121
                                   "RECFM=[DFNPV],LRECL=\\|[0-9]+:[0-9]+[ /t]+[0-9]+:[0-9]+\\|"
 
1122
                                   "[1-9][0-9]* at [0-9]+:[0-9]+[ /t]+[1-9][0-9]* at [0-9]+:[0-9]+\\)\\).*$"
 
1123
                                   "\\|[0-9]+\\([ \t]+!\\)?\\|MPRINT([_A-Z]+):\\|"
 
1124
                                   "[ \t]+\\(values at the places given by: (Line):(Column).\\|"
 
1125
                                   "The m\\(in\\|ax\\)imum record length was [1-9][0-9]*.\\|"
 
1126
                                   "One or more lines were truncated.\\|"
 
1127
                                   "Each place is given by: (Number of times) at (Line):(Column).\\|"
 
1128
                                   "[0-9][0-9]:[0-9][0-9] [MTWFS][aeioudhnrst]+day, [JFMASOND]"
 
1129
                                   "[aeiouybcghlmnprstv]+ [1-9][0-9]?, 20[0-9][0-9]\\)\\)")
 
1130
                                  nil t) (replace-match (if strip " " "/*\\&*/") t))
 
1131
    ))
1136
1132
 
1137
1133
(defun ess-sas-toggle-sas-listing-mode (&optional force)
1138
1134
  "Toggle SAS-listing-mode for .lst files."
1139
1135
  (interactive)
1140
1136
  (ess-sas-goto-lst)
1141
1137
 
1142
 
(if (equal (cdr (assoc "\\.[lL][sS][tT]\\'" auto-mode-alist)) 'SAS-listing-mode) (progn
1143
 
      (setq auto-mode-alist (delete '("\\.[lL][sS][tT]\\'" . SAS-listing-mode) auto-mode-alist))
1144
 
      (setq buffer-read-only nil)
1145
 
      (ess-listing-minor-mode 0))
1146
 
      (setq auto-mode-alist (append '(("\\.[lL][sS][tT]\\'" . SAS-listing-mode)) auto-mode-alist))
1147
 
      (setq buffer-read-only t)
1148
 
      (ess-listing-minor-mode 1)))
 
1138
  (if (equal (cdr (assoc "\\.[lL][sS][tT]\\'" auto-mode-alist)) 'SAS-listing-mode) (progn
 
1139
                                                                                     (setq auto-mode-alist (delete '("\\.[lL][sS][tT]\\'" . SAS-listing-mode) auto-mode-alist))
 
1140
                                                                                     (setq buffer-read-only nil)
 
1141
                                                                                     (ess-listing-minor-mode 0))
 
1142
    (setq auto-mode-alist (append '(("\\.[lL][sS][tT]\\'" . SAS-listing-mode)) auto-mode-alist))
 
1143
    (setq buffer-read-only t)
 
1144
    (ess-listing-minor-mode 1)))
1149
1145
 
1150
1146
(defun ess-sas-toggle-sas-log-mode ()
1151
1147
  "Toggle SAS-log-mode for .log files."
1154
1150
  (ess-sas-goto-log)
1155
1151
  (kill-buffer nil)
1156
1152
 
1157
 
;  (if (equal (cdr (assoc "\\.[lL][oO][gG]\\'" auto-mode-alist)) 'SAS-log-mode) (progn
1158
 
;      (setq auto-mode-alist (delete '("\\.[lL][oO][gG]\\'" . SAS-log-mode) auto-mode-alist))
1159
 
;      (setq buffer-read-only nil)
1160
 
;      (ess-transcript-minor-mode 0)
1161
 
;      (font-lock-mode 0))
1162
 
;      (setq auto-mode-alist (append '(("\\.[lL][oO][gG]\\'" . SAS-log-mode)) auto-mode-alist))
1163
 
;      (setq buffer-read-only t)
1164
 
;      (ess-transcript-minor-mode 1)
1165
 
;      (font-lock-mode 1)
1166
 
;      (font-lock-fontify-buffer))
 
1153
                                        ;  (if (equal (cdr (assoc "\\.[lL][oO][gG]\\'" auto-mode-alist)) 'SAS-log-mode) (progn
 
1154
                                        ;      (setq auto-mode-alist (delete '("\\.[lL][oO][gG]\\'" . SAS-log-mode) auto-mode-alist))
 
1155
                                        ;      (setq buffer-read-only nil)
 
1156
                                        ;      (ess-transcript-minor-mode 0)
 
1157
                                        ;      (font-lock-mode 0))
 
1158
                                        ;      (setq auto-mode-alist (append '(("\\.[lL][oO][gG]\\'" . SAS-log-mode)) auto-mode-alist))
 
1159
                                        ;      (setq buffer-read-only t)
 
1160
                                        ;      (ess-transcript-minor-mode 1)
 
1161
                                        ;      (font-lock-mode 1)
 
1162
                                        ;      (font-lock-fontify-buffer))
1167
1163
 
1168
1164
  (if (equal (cdr (assoc "\\.[lL][oO][gG]\\'" auto-mode-alist)) 'SAS-log-mode)
1169
1165
      (setq auto-mode-alist (delete '("\\.[lL][oO][gG]\\'" . SAS-log-mode) auto-mode-alist))
1170
 
      (setq auto-mode-alist (append '(("\\.[lL][oO][gG]\\'" . SAS-log-mode)) auto-mode-alist)))
 
1166
    (setq auto-mode-alist (append '(("\\.[lL][oO][gG]\\'" . SAS-log-mode)) auto-mode-alist)))
1171
1167
  (ess-sas-goto-log))
1172
1168
 
1173
1169
(defun ess-sas-versions-create ()
1181
1177
  ;; This works by creating a temp buffer where the template function is
1182
1178
  ;; edited so that V is replaced by the version number
1183
1179
  (let ((template "")
1184
 
        (beg)
1185
 
        (versions)
1186
 
        (version)
1187
 
        (eval-buf (get-buffer-create "*ess-temp-sas-evals*"))
1188
 
        (ess-sas-versions-created)
1189
 
        )
 
1180
        (beg)
 
1181
        (versions)
 
1182
        (version)
 
1183
        (eval-buf (get-buffer-create "*ess-temp-sas-evals*"))
 
1184
        (ess-sas-versions-created)
 
1185
        )
1190
1186
    ;;
1191
1187
    ;; This is the template function used for creating M-x SASV.
1192
1188
    (setq template "(defun SASV (&optional start-args)
1205
1201
      ;; Find which versions of SAS we want.  Remove the pathname, leaving just
1206
1202
      ;; the name of the executable.
1207
1203
      (setq versions
1208
 
            (ess-uniq-list
1209
 
             (mapcar 'file-name-nondirectory
1210
 
                     (apply 'nconc
1211
 
                            (mapcar 'ess-find-exec-completions
1212
 
                                    ess-sas-versions)))))
 
1204
            (ess-uniq-list
 
1205
             (mapcar 'file-name-nondirectory
 
1206
                     (apply 'nconc
 
1207
                            (mapcar 'ess-find-exec-completions
 
1208
                                    ess-sas-versions)))))
1213
1209
      (ess-write-to-dribble-buffer
1214
1210
       (format "(SAS): ess-sas-versions-create making M-x defuns for %s"
1215
 
               (mapconcat 'identity versions " ")))
 
1211
               (mapconcat 'identity versions " ")))
1216
1212
      (setq ess-sas-versions-created versions) ;keep copy for returning at end.
1217
1213
      ;; Iterate over each string in VERSIONS, creating a new defun each time.
1218
1214
      (while versions
1219
 
        (setq version (car versions)
1220
 
              versions (cdr versions))
1221
 
        (setq beg (point))
1222
 
        (insert template)
1223
 
        (goto-char beg)
1224
 
        (while (search-forward "SASV" nil t)
1225
 
          (replace-match version t t))
1226
 
        (goto-char (point-max))
1227
 
        )
 
1215
        (setq version (car versions)
 
1216
              versions (cdr versions))
 
1217
        (setq beg (point))
 
1218
        (insert template)
 
1219
        (goto-char beg)
 
1220
        (while (search-forward "SASV" nil t)
 
1221
          (replace-match version t t))
 
1222
        (goto-char (point-max))
 
1223
        )
1228
1224
      ;; buffer has now been created with defuns, so eval them!
1229
1225
      (eval-buffer)
1230
1226
      (kill-buffer eval-buf)
1236
1232
 
1237
1233
 
1238
1234
(defun ess-sas-edit-keys-set (&optional arg)
1239
 
"Set TAB/RET key in `SAS-mode'.
 
1235
  "Set TAB/RET key in `SAS-mode'.
1240
1236
If arg is nil
1241
1237
    TAB is `sas-indent-line' and
1242
1238
    RET is `newline-and-indent'.
1248
1244
 
1249
1245
  (if arg
1250
1246
      (progn
1251
 
        (if (and (equal emacs-major-version 19) (equal emacs-minor-version 28))
1252
 
            (define-key sas-mode-local-map [C-tab] 'ess-sas-backward-delete-tab)
1253
 
          ;;else
1254
 
          (define-key sas-mode-local-map [(control tab)] 'ess-sas-backward-delete-tab))
1255
 
        (define-key sas-mode-local-map [return] 'newline)
1256
 
        (define-key sas-mode-local-map "\t" 'ess-sas-tab-to-tab-stop))
 
1247
        (if (and (equal emacs-major-version 19) (equal emacs-minor-version 28))
 
1248
            (define-key sas-mode-local-map [C-tab] 'ess-sas-backward-delete-tab)
 
1249
          ;;else
 
1250
          (define-key sas-mode-local-map [(control tab)] 'ess-sas-backward-delete-tab))
 
1251
        (define-key sas-mode-local-map [return] 'newline)
 
1252
        (define-key sas-mode-local-map "\t" 'ess-sas-tab-to-tab-stop))
1257
1253
    ;;else
1258
1254
    (define-key sas-mode-local-map [return] 'newline-and-indent)
1259
1255
    (define-key sas-mode-local-map "\t" 'sas-indent-line)))
1260
1256
 
1261
1257
(defvar ess-sas-edit-keys-toggle nil
1262
 
"Toggle TAB/RET key in `SAS-mode'.
 
1258
  "Toggle TAB/RET key in `SAS-mode'.
1263
1259
nil binds TAB to `sas-indent-line' and RET to `newline-and-indent'.
1264
1260
Non-nil binds TAB to `ess-sas-tab-to-tab-stop',
1265
1261
C-TAB to `ess-sas-backward-delete-tab', and RET to `newline'.")
1266
1262
 
1267
1263
(defun ess-sas-edit-keys-toggle (&optional arg)
1268
 
"Toggle `ess-sas-edit-keys-toggle'.  Optional arg is still
 
1264
  "Toggle `ess-sas-edit-keys-toggle'.  Optional arg is still
1269
1265
accepted for backward compatibility, however, arg is ignored."
1270
1266
  (interactive)
1271
1267
 
1272
1268
  (setq ess-sas-edit-keys-toggle (not ess-sas-edit-keys-toggle))
1273
1269
  (ess-sas-edit-keys-set ess-sas-edit-keys-toggle)
1274
 
)
 
1270
  )
1275
1271
 
1276
1272
(defvar ess-sas-global-pc-keys nil
1277
1273
  "Non-nil if function keys use PC-like SAS key definitions in all modes.")
1300
1296
  (global-set-key [(control f11)] 'ess-ebcdic-to-ascii-search-and-replace)
1301
1297
  (global-set-key (quote [f12]) 'ess-sas-graph-view)
1302
1298
  (if (and ess-sas-edit-keys-toggle
1303
 
           (equal emacs-major-version 19) (equal emacs-minor-version 28))
 
1299
           (equal emacs-major-version 19) (equal emacs-minor-version 28))
1304
1300
      (global-set-key [C-tab] 'ess-sas-backward-delete-tab)
1305
 
                                        ;else
 
1301
                                        ;else
1306
1302
    (global-set-key [(control tab)] 'ess-sas-backward-delete-tab))
1307
 
  ;(define-key sas-mode-local-map "\C-c\C-p" 'ess-sas-file-path)
 
1303
                                        ;(define-key sas-mode-local-map "\C-c\C-p" 'ess-sas-file-path)
1308
1304
  (setq ess-sas-global-pc-keys t)
1309
1305
  (setq ess-sas-global-unix-keys nil)
1310
1306
  (setq ess-sas-local-pc-keys nil)
1311
1307
  (setq ess-sas-local-unix-keys nil)
1312
 
)
 
1308
  )
1313
1309
 
1314
1310
(defvar ess-sas-global-unix-keys nil
1315
1311
  "Non-nil if function keys use Unix-like SAS key definitions in all modes.")
1337
1333
  (global-set-key (quote [f11]) 'ess-sas-goto-file-2)
1338
1334
  (global-set-key [(control f11)] 'ess-ebcdic-to-ascii-search-and-replace)
1339
1335
  (global-set-key (quote [f12]) 'ess-sas-graph-view)
1340
 
        (if (and ess-sas-edit-keys-toggle
1341
 
            (equal emacs-major-version 19) (equal emacs-minor-version 28))
1342
 
            (global-set-key [C-tab] 'ess-sas-backward-delete-tab)
1343
 
            ;else
1344
 
            (global-set-key [(control tab)] 'ess-sas-backward-delete-tab))
1345
 
  ;(define-key sas-mode-local-map "\C-c\C-p" 'ess-sas-file-path)
 
1336
  (if (and ess-sas-edit-keys-toggle
 
1337
           (equal emacs-major-version 19) (equal emacs-minor-version 28))
 
1338
      (global-set-key [C-tab] 'ess-sas-backward-delete-tab)
 
1339
                                        ;else
 
1340
    (global-set-key [(control tab)] 'ess-sas-backward-delete-tab))
 
1341
                                        ;(define-key sas-mode-local-map "\C-c\C-p" 'ess-sas-file-path)
1346
1342
  (setq ess-sas-global-pc-keys nil)
1347
1343
  (setq ess-sas-global-unix-keys t)
1348
1344
  (setq ess-sas-local-pc-keys nil)
1349
1345
  (setq ess-sas-local-unix-keys nil)
1350
 
)
 
1346
  )
1351
1347
 
1352
1348
(defvar ess-sas-local-pc-keys nil
1353
1349
  "Non-nil if function keys use PC-like SAS key definitions
1376
1372
  (define-key sas-mode-local-map (quote [f11]) 'ess-sas-goto-file-2)
1377
1373
  (define-key sas-mode-local-map [(control f11)] 'ess-ebcdic-to-ascii-search-and-replace)
1378
1374
  (define-key sas-mode-local-map (quote [f12]) 'ess-sas-graph-view)
1379
 
  ;(define-key sas-mode-local-map "\C-c\C-p" 'ess-sas-file-path)
 
1375
                                        ;(define-key sas-mode-local-map "\C-c\C-p" 'ess-sas-file-path)
1380
1376
  (setq ess-sas-global-pc-keys nil)
1381
1377
  (setq ess-sas-global-unix-keys nil)
1382
1378
  (setq ess-sas-local-pc-keys t)
1383
1379
  (setq ess-sas-local-unix-keys nil)
1384
 
)
 
1380
  )
1385
1381
 
1386
1382
(defvar ess-sas-local-unix-keys nil
1387
1383
  "Non-nil if function keys use Unix-like SAS key definitions
1410
1406
  (define-key sas-mode-local-map (quote [f11]) 'ess-sas-goto-file-2)
1411
1407
  (define-key sas-mode-local-map [(control f11)] 'ess-ebcdic-to-ascii-search-and-replace)
1412
1408
  (define-key sas-mode-local-map (quote [f12]) 'ess-sas-graph-view)
1413
 
  ;(define-key sas-mode-local-map "\C-c\C-p" 'ess-sas-file-path)
 
1409
                                        ;(define-key sas-mode-local-map "\C-c\C-p" 'ess-sas-file-path)
1414
1410
  (setq ess-sas-global-pc-keys nil)
1415
1411
  (setq ess-sas-global-unix-keys nil)
1416
1412
  (setq ess-sas-local-pc-keys nil)
1417
1413
  (setq ess-sas-local-unix-keys t)
1418
 
)
 
1414
  )
1419
1415
 
1420
1416
(provide 'ess-sas-a)
1421
1417