Commits

cvs2hg  committed a98d38d

fixup commit for tag 'sumo-current'

  • Participants
  • Parent commits f6d56b8
  • Tags sumo-current

Comments (0)

Files changed (15)

File lisp/ess-batch.el

+;;; ess-batch.el --- Emacs functions used by ESS[SAS] and ESS[BUGS]
+
+;; Copyright (C) 2002 R. Sparapani.
+
+;; Author: Rodney Sparapani <rsparapa@mcw.edu>
+;; Maintainer: Rodney Sparapani <rsparapa@mcw.edu>
+;; Created: 23 Jan 2002
+;; Modified: $Date$
+;; Version: $Revision$
+;; RCS: $Id$
+
+;; This file is part of ESS (Emacs Speaks Statistics).
+
+;; This file is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; This file is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to
+;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+
+(defun ess-set-file-path ()
+ "*Set `ess-sas-file-path' or `ess-bugs-file-path' depending on suffix."
+  (interactive)
+
+  (save-match-data (let ((ess-temp-file (expand-file-name (buffer-name))))
+    (if (string-match ess-sas-suffix-regexp ess-temp-file) 
+	(setq ess-sas-file-path (nth 0 (split-string ess-temp-file "[<]")))
+    ;;else
+    (if (string-match ess-bugs-suffix-regexp ess-temp-file) 
+	(setq ess-bugs-file-path (nth 0 (split-string ess-temp-file "[<]"))))))))
+
+(provide 'ess-batch)

File lisp/ess-dump.el

+;;; ess-dump.el --- Getting objects into text files for editing
+
+;; Copyright (C) 2000--2004 A.J. Rossini, Rich M. Heiberger, Martin
+;;	Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
+
+;; Original Author:  A.J. Rossini <rossini@u.washington.edu>
+;; Created: 3 Sept 2000
+;; Maintainers: ESS-core <ESS-core@stat.math.ethz.ch>
+
+;; This file is part of ESS
+
+;; This file is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; This file is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to
+;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+
+;;; Commentary:
+
+;; Code for sending statistical objects to text files for editing.
+;;
+;; THIS IS STRICTLY NOT USED, BUT IS FOR PLANNING.
+
+;;; Code:
+
+
 ; Requires and autoloads
+
+(require 'ess)
+
+(defun ess-check-source (fname)
+  "If file FNAME has an unsaved buffer, offer to save it.
+Returns t if the buffer existed and was modified, but was not saved."
+  (let ((buff (get-file-buffer fname)))
+    ;; RMH: Corrections noted below are needed for C-c C-l to work
+    ;; correctly when issued from *S* buffer.
+    ;; The following barfs since
+    ;; 1. `if' does not accept a buffer argument, `not' does.
+    ;; 2. (buffer-file-name) is not necessarily defined for *S*
+    ;;(if buff
+    ;; (let ((deleted (not (file-exists-p (buffer-file-name)))))
+    ;; Next 2 lines are RMH's solution:
+    (if (not(not buff))
+	(let ((deleted (not (file-exists-p fname))))
+	  (if (and deleted (not (buffer-modified-p buff)))
+	      ;; Buffer has been silently deleted, so silently save
+	      (save-excursion
+		(set-buffer buff)
+		(set-buffer-modified-p t)
+		(save-buffer))
+	    (if (and (buffer-modified-p buff)
+		     (or ess-mode-silently-save
+			 (y-or-n-p
+			  (format "Save buffer %s first? "
+				  (buffer-name buff)))))
+		(save-excursion
+		  (set-buffer buff)
+		  (save-buffer))))
+	  (buffer-modified-p buff)))))
+
+
+(defun ess-dump-object-into-edit-buffer (object)
+  "Edit an ESS object in its own buffer.
+
+Without a prefix argument, this simply finds the file pointed to by
+`ess-source-directory'. If this file does not exist, or if a
+prefix argument is given, a dump() command is sent to the ESS process to
+generate the source buffer."
+  (interactive
+   (progn
+     (ess-force-buffer-current "Process to dump from: ")
+     (ess-read-object-name "Object to edit: ")))
+  (let* ((dirname (file-name-as-directory
+		   (if (stringp ess-source-directory)
+		       ess-source-directory
+		     (save-excursion
+		       (set-buffer
+			(process-buffer (get-ess-process
+					 ess-local-process-name)))
+		       (ess-setq-vars-local ess-customize-alist)
+		       (apply ess-source-directory nil)))))
+	 (filename (concat dirname (format ess-dump-filename-template object)))
+	 (old-buff (get-file-buffer filename)))
+
+    ;; If the directory doesn't exist, offer to create it
+    (if (file-exists-p (directory-file-name dirname)) nil
+      (if (y-or-n-p	; Approved
+	   (format "Directory %s does not exist. Create it? " dirname))
+	  (make-directory (directory-file-name dirname))
+	(error "Directory %s does not exist." dirname)))
+
+    ;; Three options:
+    ;;  (1) Pop to an existing buffer containing the file in question
+    ;;  (2) Find an existing file
+    ;;  (3) Create a new file by issuing a dump() command to S
+    ;; Force option (3) if there is a prefix arg
+
+    (if current-prefix-arg
+	(ess-dump-object object filename)
+      (if old-buff
+	  (progn
+	    (pop-to-buffer old-buff)
+	    (message "Popped to edit buffer."))
+	;; No current buffer containing desired file
+	(if (file-exists-p filename)
+	    (progn
+	      (ess-find-dump-file-other-window filename)
+	      (message "Read %s" filename))
+	  ;; No buffer and no file
+	  (ess-dump-object object filename))))))
+
+(defun ess-dump-object (object filename)
+  "Dump the ESS object OBJECT into file FILENAME."
+  (let ((complete-dump-command (format inferior-ess-dump-command
+				       object filename)))
+    (if (file-writable-p filename) nil
+      (error "Can't dump %s as %f is not writeable." object filename))
+
+    ;; Make sure we start fresh
+    (if (get-file-buffer filename)
+	(or (kill-buffer (get-file-buffer filename))
+	    (error "Aborted.")))
+
+    (ess-command complete-dump-command)
+    (message "Dumped in %s" filename)
+
+    (ess-find-dump-file-other-window filename)
+
+    ;; PD, 1Apr97
+    ;;This ensures that the object gets indented according to ess-mode,
+    ;;not as the R/S deparser does it. At the same time, it gets rid
+    ;;of the mess generated by sending TAB characters to the readline
+    ;;functions in R when you eval-buffer-*.
+    (indent-region (point-min-marker) (point-max-marker) nil)
+    (set-buffer-modified-p nil)
+
+    ;; Don't make backups for temporary files; it only causes clutter.
+    ;; The ESS object itself is a kind of backup, anyway.
+    (if ess-keep-dump-files nil
+      (make-local-variable 'make-backup-files)
+      (setq make-backup-files nil))
+
+    ;; Don't get confirmation to delete dumped files when loading
+    (if (eq ess-keep-dump-files 'check)
+	(setq ess-keep-dump-files nil))
+
+    ;; Delete the file if necessary
+    (if ess-delete-dump-files
+	(delete-file (buffer-file-name)))))
+
+(defun ess-find-dump-file-other-window (filename)
+  "Find ESS source file FILENAME in another window."
+
+  (if (file-exists-p filename) nil
+    (ess-write-to-dribble-buffer
+     (format "%s does not exist. Bad dump, starting fresh." filename)))
+
+  ;; Generate a buffer with the dumped data
+  (find-file-other-window filename)
+  (ess-mode ess-customize-alist)
+
+  (auto-save-mode 1)		; Auto save in this buffer
+  (setq ess-local-process-name ess-current-process-name)
+
+  (if ess-function-template
+      (progn
+	(goto-char (point-max))
+	(if (re-search-backward ess-dumped-missing-re nil t)
+	    (progn
+	      (replace-match ess-function-template t t)
+	      (set-buffer-modified-p nil) ; Don't offer to save if killed now
+	      (goto-char (point-min))
+	      (condition-case nil
+		  ;; This may fail if there are no opens
+		  (down-list 1)
+		(error nil)))))))
+
+
+;; AJR: XEmacs, makes sense to dump into "other frame".
+
+(defun ess-dump-object-into-edit-buffer-other-frame (object)
+  "Edit an ESS object in its own frame."
+  (switch-to-buffer-other-frame (ess-dump-object-into-edit-buffer object)))
+
+
+
+
+
+(provide 'ess-dump)
+
+
 ; Local variables section
+
+;;; This file is automatically placed in Outline minor mode.
+;;; The file is structured as follows:
+;;; Chapters:     ^L ;
+;;; Sections:    ;;*;;
+;;; Subsections: ;;;*;;;
+;;; Components:  defuns, defvars, defconsts
+;;;              Random code beginning with a ;;;;* comment
+
+;;; Local variables:
+;;; mode: emacs-lisp
+;;; outline-minor-mode: nil
+;;; mode: outline-minor
+;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*"
+;;; End:
+
+;;; ess-dump.el ends here
+

File lisp/ess-iw32b.el

+;; ESS-command games that mimic what is currently in ess-iw32.el
+;; Today (03/19/01) this doesn't work on R 1.2.1 for Windows
+;; It works correctly for S-Plus 4.5 SE and probably for S-Plus 6.
+;; I haven't tested it on Unix yet.
+
+(defun ess-command-ddeclient (com &optional buf)
+  "ddeclient bypass of real ess-command"
+  (ess-eval-linewise com))
+
+(fset 'ess-command-original (symbol-function 'ess-command))
+
+(defun ess-command (com &optional buf)
+  "Send the ESS process command COM and delete the output
+from the ESS process buffer.  If an optional second argument BUF exists
+save the output in that buffer. BUF is erased before use.
+COM should have a terminating newline.
+Guarantees that the value of .Last.value will be preserved."
+  (interactive)
+  (if (equal (ess-get-process-variable
+	      ess-current-process-name 'inferior-ess-ddeclient)
+	     (default-value 'inferior-ess-ddeclient))
+      (ess-command-original com buf)
+    (ess-force-buffer-current "Process to load into: ")
+    (ess-command-ddeclient com buf))
+)
+
+

File lisp/ess-sas-make-regexp.el

+	 ;; SAS execution blocks, DATA/RUN, PROC/RUN, %MACRO statements
+(insert (make-regexp 
+	'("data" "run" "%macro" "%mend" "%go[ \t]*to" "%global" "%else" "%end")
+	 t))
+(insert (make-regexp 
+	 '("%if" "%to" "%then" "%local" "%let" "%put" "%input" "%include" "%sysexec")
+	 t))
+
+	 ;; SAS statements
+(insert (make-regexp 
+	 '("abort" "array" "attrib" "by" "delete" "display" "dm" "drop")
+	 t))
+(insert (make-regexp 
+	  '("else" "error" "file" "filename" "footnote\\(10?\\|[2-9]\\)?" "format")
+	 t))
+(insert (make-regexp 
+	  '("go[ \t]*to" "goptions" "options" "if" "infile" "informat" "input" "keep" )
+	 t))
+(insert (make-regexp 
+	  '("label" "length" "libname" "link" "merge" "missing" "modify" "note")
+	 t))
+(insert (make-regexp 
+	  '("out" "otherwise" "output" "put" "rename" "retain" "select" "set" "skip")
+	 t))
+(insert (make-regexp 
+	  '("when" "to" "then" "title\\(10?\\|[2-9]\\)?" "where" "window" "update")
+	 t))
+(insert (make-regexp 
+	  '("change" "class" "exchange" "exclude" "freq" "id" "index")
+	 t))
+(insert (make-regexp 
+	  '("plot" "save" "sum" "tables?" "weight" "with")
+	 t))
+(insert (make-regexp 
+	  '("manova" "model" "repeated" "var" "value" "random")
+	 t))
+
+	 ;; SAS statements that must be followed by a semi-colon
+(insert (make-regexp 
+	 '("cards4?" "end" "endsas" "list" "lostcard" "page" "return" "stop")
+	 t))
+
+	 ;; SAS/GRAPH statements not handled above
+(insert (make-regexp 
+	 '("axis" "legend" "pattern" "symbol")
+	 t))
+
+	 ;; SAS functions and SAS macro functions
+(insert (make-regexp 
+	 '("abs" "arcos" "arsin" "atan" "betainv" "byte")
+	 t))
+(insert (make-regexp 
+	'("ceil" "cinv" "collate" "compress" "cosh?" "css" "cv")
+	 t))
+(insert (make-regexp 
+	'("daccdb" "daccdbsl" "daccsl" "daccsyd" "dacctab")
+	 t))
+(insert (make-regexp 
+	'("depdb" "depdbsl" "depsl" "depsyd" "deptab")
+	 t))
+(insert (make-regexp 
+	'("date" "datejul" "datepart" "datetime" "day" "dhms" "dif" "digamma" "dim")
+	 t))
+(insert (make-regexp 
+	'("erfc?" "exp") 
+	 t))
+(insert (make-regexp 
+	'("finv" "fipnamel?" "fipstate" "floor" "fuzz" "gaminv" "gamma")
+	 t))
+(insert (make-regexp 
+	'("hms" "hbound" "hour" "indexc?" "input" "int" "intck" "intnx" "intrr" "irr")
+	 t))
+(insert (make-regexp 
+	'("juldate" "kurtosis" "lag" "lbound" "left" "length" "lgamma" "log" "log10" "log2")
+	 t))
+(insert (make-regexp 
+	'("max" "mdy" "mean" "min" "minute" "mod" "month" "mort" "n" "netpv" "nmiss" "normal" "npv")
+	 t))
+(insert (make-regexp 
+	'("probbeta" "probbnml" "probchi" "probf" "probgam" "probhypr" "probit" "probnegb" "probnorm" "probt")
+	 t))
+(insert (make-regexp 
+	'("ordinal" "poisson" "put" "qtr" "repeat" "reverse" "right" "round")
+	 t))
+(insert (make-regexp 
+	'("range" "rank" "ranbin" "rancau" "ranexp" "rangam" "rannor" "ranpoi" "rantbl" "rantri" "ranuni")
+	 t))
+(insert (make-regexp 
+	'("saving" "scan" "second" "sign" "sinh?" "sqrt" "std" "stderr" "stfips" "stnamel?" "substr" "sum" "symget")
+	 t))
+(insert (make-regexp 
+	'("tanh?" "time" "timepart" "tinv" "today" "translate" "trigamma" "trim" "trunc")
+	 t))
+(insert (make-regexp 
+	'("uniform" "upcase" "uss" "var" "verify")
+	 t))
+(insert (make-regexp 
+	'("weekday" "year" "yyq" "zipfips" "zipnamel?" "zipstate")
+	 t))
+
+       ;; SAS functions introduced in Technical Report P-222
+(insert (make-regexp 
+	'("airy" "band" "blshift" "brshift" "bnot" "bor" "bxor")
+	 t))
+(insert (make-regexp 
+	'("cnonct" "fnonct" "tnonct" "compbl" "dairy" "dequote")
+	 t))
+(insert (make-regexp 
+	'("ibessel" "jbessel" "indexw" "inputc" "inputn" "putc" "putn" )
+	 t))
+(insert (make-regexp 
+	'("lowcase" "quote" "resolve" "soundex" "sysprod" "tranwrd" "trimn")
+	 t))
+
+       ;; SCL functions that are known to work with SAS macro function %sysfunc
+(insert (make-regexp 
+	'("attrc" "attrn" "close" "dclose" "dnum" "dopen" "dread" "fopen" "fclose")
+	 t))
+(insert (make-regexp 
+	'("cexist" "exist" "fetchobs" "fileexist" "finfo" "fput" "fwrite")
+	 t))
+(insert (make-regexp 
+	'("getoption" "getvarc" "getvarn" "libname" "libref" "open" "optgetn" "optsetn")
+	 t))
+(insert (make-regexp 
+	'("pathname" "sysmsg" "varfmt" "varlabel" "varnum" "vartype")
+	 t))

File lisp/ess-sysdp.el

+;;; sysdep.el --- consolidate Emacs-version dependencies in one file.
+
+;; Copyright (c) 1995 - 1997 Ben Wing.
+
+;; Author: Ben Wing <ben@xemacs.org>, William Perry <wmperry@cs.indiana.edu>
+;; Keywords: lisp, tools
+;; Version: 0.003
+
+;; Modified 05June2000 to reflect use for ESS
+;; A.J. Rossini (rossini@biostat.washington.edu). 
+
+;; The purpose of this file is to eliminate the cruftiness that
+;; would otherwise be required of packages that want to run on multiple
+;; versions of Emacs.  The idea is that we make it look like we're running
+;; the latest version of XEmacs (currently 19.12) by emulating all the
+;; missing functions.
+
+;; #### This file does not currently do any advising but should.
+;; Unfortunately, advice.el is a hugely big package.  Is any such
+;; thing as `advice-lite' possible?
+
+;; #### - This package is great, but its role needs to be thought out a bit
+;; more.  Sysdep will not permit programs written for the old XEmacs API to
+;; run on new versions of XEmacs.  Sysdep is a backward-compatibility
+;; package for the latest and greatest XEmacs API.  It permits programmers
+;; to use the latest XEmacs functionality and still have their programs run
+;; on older versions of XEmacs...perhaps even on FSF Emacs.  It should NEVER
+;; ever need to be loaded in the newest XEmacs.  It doesn't even make sense
+;; to put it in the lisp/utils part of the XEmacs distribution because it's
+;; real purpose is to be distributed with packages like w3 which take
+;; advantage of the latest and greatest features of XEmacs but still need to
+;; be run on older versions.  --Stig
+
+;; Any packages that wish to use this file should load it using
+;; `load-library'.  It will not load itself if a version of sysdep.el
+;; that is at least as recent has already been loaded, but will
+;; load over an older version of sysdep.el.  It will attempt to
+;; not redefine functions that have already been custom-redefined,
+;; but will redefine a function if the supplied definition came from
+;; an older version of sysdep.el.
+
+;; Packages such as w3 that wish to include this file with the package
+;; should rename it to something unique, such as `w3-sysdep.el', and
+;; load it with `load-library'.  That will ensure that no conflicts
+;; arise if more than one package in the load path provides a version
+;; of sysdep.el.  If multiple packages load sysdep.el, the most recent
+;; version will end up loaded; as long as I'm careful not to
+;; introduce bugs in previously working definitions, this should work
+;; fine.
+
+;; You may well discover deficiencies in this file as you use it.
+;; The preferable way of dealing with this is to send me a patch
+;; to sysdep.el; that way, the collective body of knowledge gets
+;; increased.
+
+;; IMPORTANT: leave the version string in the format X.XXX (e.g. 1.001)
+;; so that string comparisons to other versions work properly.
+
+(defconst sysdep-potential-version "0.003")
+
+;; this macro means: define the function, but only if either it
+;; wasn't bound before, or the supplied binding comes from an older
+;; version of sysdep.el.  That way, user-supplied bindings don't
+;; get overridden.
+
+;; note: sysdep-defalias is often more useful than this function,
+;; esp. since you can do load-time conditionalizing and can
+;; optionally leave the function undefined. (e.g. frame functions
+;; in v18.)
+
+(defmacro sysdep-defun (function &rest everything-else)
+  (` (cond ((and (not (fboundp (quote (, function))))
+		 (or
+		  (not
+		   (stringp (get (quote (, function)) 'sysdep-defined-this)))
+		  (and (get (quote (, function)) 'sysdep-defined-this)
+		       (string-lessp
+			(get (quote (, function)) 'sysdep-defined-this)
+			sysdep-potential-version))))
+	    (put (quote (, function)) 'sysdep-defined-this
+		 sysdep-potential-version)
+	    (defun (, function) (,@ everything-else))))))
+
+(defmacro sysdep-defvar (function &rest everything-else)
+  (` (cond ((and (not (boundp (quote (, function))))
+		 (or 
+		  (not
+		   (stringp (get (quote (, function)) 'sysdep-defined-this)))
+		  (and (get (quote (, function)) 'sysdep-defined-this)
+		       (string-lessp
+			(get (quote (, function)) 'sysdep-defined-this)
+			sysdep-potential-version))))
+	    (put (quote (, function)) 'sysdep-defined-this t)
+	    (defvar (, function) (,@ everything-else))))))
+
+(defmacro sysdep-defconst (function &rest everything-else)
+  (` (cond ((and (not (boundp (quote (, function))))
+		 (or
+		  (not
+		   (stringp (get (quote (, function)) 'sysdep-defined-this)))
+		  (and (get (quote (, function)) 'sysdep-defined-this)
+		       (string-lessp
+			(get (quote (, function)) 'sysdep-defined-this)
+			sysdep-potential-version))))
+	    (put (quote (, function)) 'sysdep-defined-this t)
+	    (defconst (, function) (,@ everything-else))))))
+
+;; similar for fset and defalias.  No need to quote as the argument
+;; is already quoted.
+
+(defmacro sysdep-fset (function def)
+  (` (cond ((and (not (fboundp (, function)))
+		 (or (not (stringp
+			   (get (, function) 'sysdep-defined-this)))
+		     (and (get (, function) 'sysdep-defined-this)
+			  (string-lessp
+			   (get (, function) 'sysdep-defined-this)
+			   sysdep-potential-version)))
+		 (, def))
+	    (put (, function) 'sysdep-defined-this t)
+	    (fset (, function) (, def))))))
+
+(defmacro sysdep-defalias (function def)
+  (` (cond ((and (not (fboundp (, function)))
+		 (or (not (stringp
+			   (get (, function) 'sysdep-defined-this)))
+		     (and (get (, function) 'sysdep-defined-this)
+			  (string-lessp
+			   (get (, function) 'sysdep-defined-this)
+			   sysdep-potential-version)))
+		 (, def)
+		 (or (listp (, def))
+		     (and (symbolp (, def))
+			  (fboundp (, def)))))
+	    (put (, function) 'sysdep-defined-this t)
+	    (defalias (, function) (, def))))))
+
+;; bootstrapping: defalias and define-function don't exist
+;; in older versions of lemacs
+
+(sysdep-fset 'defalias 'fset)
+(sysdep-defalias 'define-function 'defalias)
+
+;; useful ways of determining what version is running
+;; emacs-major-version and emacs-minor-version are
+;; already defined in recent versions of FSF Emacs and XEmacs
+
+(sysdep-defconst emacs-major-version
+		 ;; will string-match ever fail?  If so, assume 19.0.
+		 ;; (should we assume 18.something?)
+		 (if (string-match "^[0-9]+" emacs-version)
+		     (string-to-int
+		      (substring emacs-version
+				 (match-beginning 0) (match-end 0)))
+		   19))
+
+(sysdep-defconst emacs-minor-version
+		 (if (string-match "^[0-9]+\\.\\([0-9]+\\)" emacs-version)
+		     (string-to-int
+		      (substring emacs-version
+				 (match-beginning 1) (match-end 1)))
+		   0))
+
+(sysdep-defconst sysdep-running-xemacs
+		 (or (string-match "Lucid" emacs-version)
+		     (string-match "XEmacs" emacs-version)))
+
+(sysdep-defconst window-system nil)
+(sysdep-defconst window-system-version 0)
+
+(sysdep-defvar list-buffers-directory nil)
+(sysdep-defvar x-library-search-path (`
+				      ("/usr/X11R6/lib/X11/"
+				       "/usr/X11R5/lib/X11/"
+				       "/usr/lib/X11R6/X11/"
+				       "/usr/lib/X11R5/X11/"
+				       "/usr/local/X11R6/lib/X11/"
+				       "/usr/local/X11R5/lib/X11/"
+				       "/usr/local/lib/X11R6/X11/"
+				       "/usr/local/lib/X11R5/X11/"
+				       "/usr/X11/lib/X11/"
+				       "/usr/lib/X11/"
+				       "/usr/local/lib/X11/"
+				       "/usr/X386/lib/X11/"
+				       "/usr/x386/lib/X11/"
+				       "/usr/XFree86/lib/X11/"
+				       "/usr/unsupported/lib/X11/"
+				       "/usr/athena/lib/X11/"
+				       "/usr/local/x11r5/lib/X11/"
+				       "/usr/lpp/Xamples/lib/X11/"
+				       "/usr/openwin/lib/X11/"
+				       "/usr/openwin/share/lib/X11/"
+				       (, data-directory)
+				       )
+				      )
+  "Search path used for X11 libraries.")
+
+;; frame-related stuff.
+
+(sysdep-defalias 'buffer-dedicated-frame 'buffer-dedicated-screen)
+(sysdep-defalias 'deiconify-frame
+  (cond ((fboundp 'deiconify-screen) 'deiconify-screen)
+	;; make-frame-visible will be defined as necessary
+	(t 'make-frame-visible)))
+(sysdep-defalias 'delete-frame 'delete-screen)
+(sysdep-defalias 'event-frame 'event-screen)
+(sysdep-defalias 'event-glyph-extent 'event-glyph)
+(sysdep-defalias 'find-file-other-frame 'find-file-other-screen)
+(sysdep-defalias 'find-file-read-only-other-frame
+  'find-file-read-only-other-screen)
+(sysdep-defalias 'frame-height 'screen-height)
+(sysdep-defalias 'frame-iconified-p 'screen-iconified-p)
+(sysdep-defalias 'frame-left-margin-width 'screen-left-margin-width)
+(sysdep-defalias 'frame-list 'screen-list)
+(sysdep-defalias 'frame-live-p
+  (cond ((fboundp 'screen-live-p) 'screen-live-p)
+	((fboundp 'live-screen-p) 'live-screen-p)
+	;; #### not sure if this is correct (this is for Epoch)
+	;; but gnuserv.el uses it this way
+	((fboundp 'screenp) 'screenp)))
+(sysdep-defalias 'frame-name 'screen-name)
+(sysdep-defalias 'frame-parameters 'screen-parameters)
+(sysdep-defalias 'frame-pixel-height 'screen-pixel-height)
+(sysdep-defalias 'frame-pixel-width 'screen-pixel-width)
+(sysdep-defalias 'frame-right-margin-width 'screen-right-margin-width)
+(sysdep-defalias 'frame-root-window 'screen-root-window)
+(sysdep-defalias 'frame-selected-window 'screen-selected-window)
+(sysdep-defalias 'frame-totally-visible-p 'screen-totally-visible-p)
+(sysdep-defalias 'frame-visible-p 'screen-visible-p)
+(sysdep-defalias 'frame-width 'screen-width)
+(sysdep-defalias 'framep 'screenp)
+(sysdep-defalias 'get-frame-for-buffer 'get-screen-for-buffer)
+(sysdep-defalias 'get-frame-for-buffer-noselect 'get-screen-for-buffer-noselect)
+(sysdep-defalias 'get-other-frame 'get-other-screen)
+(sysdep-defalias 'iconify-frame 'iconify-screen)
+(sysdep-defalias 'lower-frame 'lower-screen)
+(sysdep-defalias 'mail-other-frame 'mail-other-screen)
+
+(sysdep-defun frame-parameter (frame parameter)
+  "Return FRAME's value for parameter PARAMETER.
+  If FRAME is omitted, describe the currently selected frame."
+  (cdr (assq parameter (frame-parameters frame))))
+
+(sysdep-defalias 'make-frame
+  (cond ((fboundp 'make-screen)
+	 (function (lambda (&optional parameters device)
+		     (make-screen parameters))))
+	((fboundp 'x-create-screen)
+	 (function (lambda (&optional parameters device)
+		     (x-create-screen parameters))))))
+
+(sysdep-defalias 'make-frame-invisible 'make-screen-invisible)
+(sysdep-defalias 'make-frame-visible
+  (cond ((fboundp 'make-screen-visible) 'make-screen-visible)
+	((fboundp 'mapraised-screen) 'mapraised-screen)
+	((fboundp 'x-remap-window)
+	 (lambda (&optional x)
+	   (x-remap-window)
+	   (accept-process-output)))))
+(sysdep-defalias 'modify-frame-parameters 'modify-screen-parameters)
+(sysdep-defalias 'new-frame 'new-screen)
+(sysdep-defalias 'next-frame 'next-screen)
+(sysdep-defalias 'next-multiframe-window 'next-multiscreen-window)
+(sysdep-defalias 'other-frame 'other-screen)
+(sysdep-defalias 'previous-frame 'previous-screen)
+(sysdep-defalias 'previous-multiframe-window 'previous-multiscreen-window)
+(sysdep-defalias 'raise-frame
+  (cond ((fboundp 'raise-screen) 'raise-screen)
+	((fboundp 'mapraise-screen) 'mapraise-screen)))
+(sysdep-defalias 'redraw-frame 'redraw-screen)
+(sysdep-defalias 'select-frame 'select-screen)
+(sysdep-defalias 'selected-frame 'selected-screen)
+(sysdep-defalias 'set-buffer-dedicated-frame 'set-buffer-dedicated-screen)
+(sysdep-defalias 'set-frame-height 'set-screen-height)
+(sysdep-defalias 'set-frame-left-margin-width 'set-screen-left-margin-width)
+(sysdep-defalias 'set-frame-position 'set-screen-position)
+(sysdep-defalias 'set-frame-right-margin-width 'set-screen-right-margin-width)
+(sysdep-defalias 'set-frame-size 'set-screen-size)
+(sysdep-defalias 'set-frame-width 'set-screen-width)
+(sysdep-defalias 'show-temp-buffer-in-current-frame 'show-temp-buffer-in-current-screen)
+(sysdep-defalias 'switch-to-buffer-other-frame 'switch-to-buffer-other-screen)
+(sysdep-defalias 'visible-frame-list 'visible-screen-list)
+(sysdep-defalias 'window-frame 'window-screen)
+(sysdep-defalias 'x-create-frame 'x-create-screen)
+(sysdep-defalias 'x-set-frame-icon-pixmap 'x-set-screen-icon-pixmap)
+(sysdep-defalias 'x-set-frame-pointer 'x-set-screen-pointer)
+(sysdep-defalias 'x-display-color-p 'x-color-display-p)
+(sysdep-defalias 'x-display-grayscale-p 'x-grayscale-display-p)
+(sysdep-defalias 'menu-event-p 'misc-user-event-p)
+
+(sysdep-defun event-point (event)
+  (let ((posn (event-end event)))
+    (if posn 
+ 	(posn-point posn))))
+
+;;;; WMP - commenting these out so that Emacs 19 doesn't get screwed by them.
+;;;; In particular, this makes the 'custom' package blow up quite well.
+;;(sysdep-defun add-submenu (menu-path submenu &optional before)
+;;  "Add a menu to the menubar or one of its submenus.
+;;If the named menu exists already, it is changed.
+;;MENU-PATH identifies the menu under which the new menu should be inserted.
+;; It is a list of strings; for example, (\"File\") names the top-level \"File\"
+;; menu.  (\"File\" \"Foo\") names a hypothetical submenu of \"File\".
+;; If MENU-PATH is nil, then the menu will be added to the menubar itself.
+;;SUBMENU is the new menu to add.
+;; See the documentation of `current-menubar' for the syntax.
+;;BEFORE, if provided, is the name of a menu before which this menu should
+;; be added, if this menu is not on its parent already.  If the menu is already
+;; present, it will not be moved."
+;;  (add-menu menu-path (car submenu) (cdr submenu) before))
+
+;;(sysdep-defun add-menu-button (menu-path menu-leaf &optional before)
+;;  "Add a menu item to some menu, creating the menu first if necessary.
+;;If the named item exists already, it is changed.
+;;MENU-PATH identifies the menu under which the new menu item should be inserted.
+;; It is a list of strings; for example, (\"File\") names the top-level \"File\"
+;; menu.  (\"File\" \"Foo\") names a hypothetical submenu of \"File\".
+;;MENU-LEAF is a menubar leaf node.  See the documentation of `current-menubar'.
+;;BEFORE, if provided, is the name of a menu item before which this item should
+;; be added, if this item is not on the menu already.  If the item is already
+;; present, it will not be moved."
+;; (add-menu-item menu-path (aref menu-leaf 0) (aref menu-leaf 1)
+;;		(aref menu-leaf 2) before))
+
+(sysdep-defun make-glyph (&optional spec-list)
+  (if (and spec-list (cdr-safe (assq 'x spec-list)))
+      (make-pixmap (cdr-safe (assq 'x spec-list)))))
+
+(sysdep-defalias 'face-list 'list-faces)
+
+(sysdep-defun set-keymap-parent (keymap new-parent)
+  (let ((tail keymap))
+    (while (and tail (cdr tail) (not (eq (car (cdr tail)) 'keymap)))
+      (setq tail (cdr tail)))
+    (if tail
+	(setcdr tail new-parent))))
+
+;; Property list functions
+;;
+(sysdep-defun plist-put (plist prop val)
+  "Change value in PLIST of PROP to VAL.
+PLIST is a property list, which is a list of the form
+(PROP1 VALUE1 PROP2 VALUE2 ...).  PROP is a symbol and VAL is any object.
+If PROP is already a property on the list, its value is set to VAL,
+otherwise the new PROP VAL pair is added.  The new plist is returned;
+use `(setq x (plist-put x prop val))' to be sure to use the new value.
+The PLIST is modified by side effects."
+  (let ((node (memq prop plist)))
+    (if node
+	(setcar (cdr node) val)
+      (setq plist (cons prop (cons val plist))))
+    plist))
+
+(sysdep-defun plist-get (plist prop)
+  "Extract a value from a property list.
+PLIST is a property list, which is a list of the form
+(PROP1 VALUE1 PROP2 VALUE2...).  This function returns the value
+corresponding to the given PROP, or nil if PROP is not
+one of the properties on the list."
+  (while (and plist (not (eq (car plist) prop)))
+    (setq plist (cdr (cdr plist))))
+  (and plist (car (cdr plist))))
+
+;; Extent stuff
+(sysdep-fset 'delete-extent 'delete-overlay)
+(sysdep-fset 'extent-end-position 'overlay-end)
+(sysdep-fset 'extent-start-position 'overlay-start)
+(sysdep-fset 'set-extent-endpoints 'move-overlay)
+(sysdep-fset 'set-extent-property 'overlay-put)
+(sysdep-fset 'make-extent 'make-overlay)
+
+(sysdep-defun extent-property (extent property &optional default)
+  (or (overlay-get extent property) default))
+
+(sysdep-defun extent-at (pos &optional object property before at-flag)
+  (let ((tmp (overlays-at (point)))
+	ovls)
+    (if property
+	(while tmp
+	  (if (extent-property (car tmp) property)
+	      (setq ovls (cons (car tmp) ovls)))
+	  (setq tmp (cdr tmp)))
+      (setq ovls tmp
+	    tmp nil))
+    (car-safe
+     (sort ovls
+	   (function
+	    (lambda (a b)
+	      (< (- (extent-end-position a) (extent-start-position a))
+		 (- (extent-end-position b) (extent-start-position b)))))))))
+
+(sysdep-defun overlays-in (beg end)
+  "Return a list of the overlays that overlap the region BEG ... END.
+Overlap means that at least one character is contained within the overlay
+and also contained within the specified region.
+Empty overlays are included in the result if they are located at BEG
+or between BEG and END."
+  (let ((ovls (overlay-lists))
+	tmp retval)
+    (if (< end beg)
+	(setq tmp end
+	      end beg
+	      beg tmp))
+    (setq ovls (nconc (car ovls) (cdr ovls)))
+    (while ovls
+      (setq tmp (car ovls)
+	    ovls (cdr ovls))
+      (if (or (and (<= (overlay-start tmp) end)
+		   (>= (overlay-start tmp) beg))
+	      (and (<= (overlay-end tmp) end)
+		   (>= (overlay-end tmp) beg)))
+	  (setq retval (cons tmp retval))))
+    retval))
+
+(sysdep-defun map-extents (function &optional object from to
+				    maparg flags property value)
+  (let ((tmp (overlays-in (or from (point-min))
+			  (or to (point-max))))
+	ovls)
+    (if property
+	(while tmp
+	  (if (extent-property (car tmp) property)
+	      (setq ovls (cons (car tmp) ovls)))
+	  (setq tmp (cdr tmp)))
+      (setq ovls tmp
+	    tmp nil))
+    (catch 'done
+      (while ovls
+	(setq tmp (funcall function (car ovls) maparg)
+	      ovls (cdr ovls))
+	(if tmp
+	    (throw 'done tmp))))))
+
+;; misc
+(sysdep-fset 'make-local-hook 'make-local-variable)
+
+(sysdep-defun buffer-substring-no-properties (beg end)
+  "Return the text from BEG to END, without text properties, as a string."
+  (format "%s" (buffer-substring beg end)))
+  
+(sysdep-defun symbol-value-in-buffer (symbol buffer &optional unbound-value)
+  "Return the value of SYMBOL in BUFFER, or UNBOUND-VALUE if it is unbound."
+  (save-excursion
+    (set-buffer buffer)
+    (if (not (boundp symbol))
+	unbound-value
+      (symbol-value symbol))))
+
+(sysdep-defun insert-file-contents-literally
+  (file &optional visit beg end replace)
+  "Like `insert-file-contents', q.v., but only reads in the file.
+A buffer may be modified in several ways after reading into the buffer due
+to advanced Emacs features, such as file-name-handlers, format decoding,
+find-file-hooks, etc.
+  This function ensures that none of these modifications will take place."
+  (let ((file-name-handler-alist nil)
+	(find-file-hooks nil))
+    (insert-file-contents file visit beg end replace)))
+
+(sysdep-defun alist-to-plist (alist)
+  "Convert association list ALIST into the equivalent property-list form.
+The plist is returned.  This converts from
+
+\((a . 1) (b . 2) (c . 3))
+
+into
+
+\(a 1 b 2 c 3)
+
+The original alist is not modified.  See also `destructive-alist-to-plist'."
+  (let (plist)
+    (while alist
+      (let ((el (car alist)))
+	(setq plist (cons (cdr el) (cons (car el) plist))))
+      (setq alist (cdr alist)))
+    (nreverse plist)))
+
+(sysdep-defun add-minor-mode (toggle name &optional keymap after toggle-fun)
+  "Add a minor mode to `minor-mode-alist' and `minor-mode-map-alist'.
+TOGGLE is a symbol which is used as the variable which toggle the minor mode,
+NAME is the name that should appear in the modeline (it should be a string
+beginning with a space), KEYMAP is a keymap to make active when the minor
+mode is active, and AFTER is the toggling symbol used for another minor
+mode.  If AFTER is non-nil, then it is used to position the new mode in the
+minor-mode alists.  TOGGLE-FUN specifies an interactive function that
+is called to toggle the mode on and off; this affects what appens when
+button2 is pressed on the mode, and when button3 is pressed somewhere
+in the list of modes.  If TOGGLE-FUN is nil and TOGGLE names an
+interactive function, TOGGLE is used as the toggle function.
+
+Example:  (add-minor-mode 'view-minor-mode \" View\" view-mode-map)"
+  (if (not (assq toggle minor-mode-alist))
+      (setq minor-mode-alist (cons (list toggle name) minor-mode-alist)))
+  (if (and keymap (not (assq toggle minor-mode-map-alist)))
+      (setq minor-mode-map-alist (cons (cons toggle keymap)
+				       minor-mode-map-alist))))
+
+(sysdep-defvar x-font-regexp-foundry-and-family
+  (let ((- 		"[-?]")
+	(foundry		"[^-]+")
+	(family 		"[^-]+")
+	)
+    (concat "\\`[-?*]" foundry - "\\(" family "\\)" -)))
+
+(sysdep-defun match-string (num &optional string)
+  "Return string of text matched by last search.
+NUM specifies which parenthesized expression in the last regexp.
+ Value is nil if NUMth pair didn't match, or there were less than NUM pairs.
+Zero means the entire text matched by the whole regexp or whole string.
+STRING should be given if the last search was by `string-match' on STRING."
+  (if (match-beginning num)
+      (if string
+	  (substring string (match-beginning num) (match-end num))
+	(buffer-substring (match-beginning num) (match-end num)))))
+
+(sysdep-defun add-hook (hook-var function &optional at-end)
+  "Add a function to a hook.
+First argument HOOK-VAR (a symbol) is the name of a hook, second
+ argument FUNCTION is the function to add.
+Third (optional) argument AT-END means to add the function at the end
+ of the hook list instead of the beginning.  If the function is already
+ present, this has no effect.
+Returns nil if FUNCTION was already present in HOOK-VAR, else new
+ value of HOOK-VAR."
+      (if (not (boundp hook-var)) (set hook-var nil))
+      (let ((old (symbol-value hook-var)))
+	(if (or (not (listp old)) (eq (car old) 'lambda))
+	    (setq old (list old)))
+	(if (member function old)
+	    nil
+	  (set hook-var
+	       (if at-end
+		   (append old (list function)) ; don't nconc
+		 (cons function old))))))
+
+(sysdep-defalias 'valid-color-name-p
+  (cond
+   ((fboundp 'x-valid-color-name-p)	; XEmacs/Lucid
+    'x-valid-color-name-p)
+   ((and window-system
+	 (fboundp 'color-defined-p))	; NS/Emacs 19
+    'color-defined-p)
+   ((and window-system
+	 (fboundp 'pm-color-defined-p))
+    'pm-color-defined-p)
+   ((and window-system
+	 (fboundp 'x-color-defined-p))	; Emacs 19
+    'x-color-defined-p)
+   ((fboundp 'get-color)		; Epoch
+    (function (lambda (color)
+		(let ((x (get-color color)))
+		  (if x
+		      (setq x (progn
+				(free-color x)
+				t)))
+		  x))))
+   (t 'identity)))			; All others
+
+;; Misc.
+;; NT doesn't have make-symbolic-link
+(sysdep-defalias 'make-symbolic-link 'copy-file)
+(sysdep-defalias 'insert-and-inherit 'insert)
+
+(sysdep-defun run-hook-with-args-until-success (hook &rest args)
+  "Run HOOK with the specified arguments ARGS.
+HOOK should be a symbol, a hook variable.  Its value should
+be a list of functions.  We call those functions, one by one,
+passing arguments ARGS to each of them, until one of them
+returns a non-nil value.  Then we return that value.
+If all the functions return nil, we return nil."
+  (let ((rval nil)
+	(todo (and (boundp hook) (symbol-value hook)))
+	(global (and (boundp hook) (default-value hook)))
+	(cur nil))
+    (while (and (setq cur (car todo)) (not rval))
+      (setq todo (cdr todo))
+      (if (eq cur t)
+	  (if global
+	      (setq todo (append global todo)))
+	(setq rval (apply cur args))))))
+
+(sysdep-defun split-string (string pattern)
+  "Return a list of substrings of STRING which are separated by PATTERN."
+  (let (parts (start 0))
+    (while (string-match pattern string start)
+      (setq parts (cons (substring string start (match-beginning 0)) parts)
+	    start (match-end 0)))
+    (nreverse (cons (substring string start) parts))
+    ))
+
+(sysdep-defun member (elt list)
+  (while (and list (not (equal elt (car list))))
+    (setq list (cdr list)))
+  list)
+
+(sysdep-defun rassoc (key list)
+  (let ((found nil))
+    (while (and list (not found))
+      (if (equal (cdr (car list)) key) (setq found (car list)))
+      (setq list (cdr list)))
+    found))
+
+(sysdep-defun display-error (error-object stream)
+  "Display `error-object' on `stream' in a user-friendly way."
+  (funcall (or (let ((type (car-safe error-object)))
+		 (catch 'error
+		   (and (consp error-object)
+			(symbolp type)
+			;;(stringp (get type 'error-message))
+			(consp (get type 'error-conditions))
+			(let ((tail (cdr error-object)))
+			  (while (not (null tail))
+			    (if (consp tail)
+				(setq tail (cdr tail))
+			      (throw 'error nil)))
+			  t)
+			;; (check-type condition condition)
+			(get type 'error-conditions)
+			;; Search class hierarchy
+			(let ((tail (get type 'error-conditions)))
+			  (while (not (null tail))
+			    (cond ((not (and (consp tail)
+					     (symbolp (car tail))))
+				   (throw 'error nil))
+				  ((get (car tail) 'display-error)
+				   (throw 'error (get (car tail)
+						      'display-error)))
+				  (t
+				   (setq tail (cdr tail)))))
+			  ;; Default method
+			  (function
+			   (lambda (error-object stream)
+			     (let ((type (car error-object))
+				   (tail (cdr error-object))
+				   (first t))
+			       (if (eq type 'error)
+				   (progn (princ (car tail) stream)
+					  (setq tail (cdr tail)))
+				 (princ (or (get type 'error-message) type)
+					stream))
+			       (while tail
+				 (princ (if first ": " ", ") stream)
+				 (prin1 (car tail) stream)
+				 (setq tail (cdr tail)
+				       first nil)))))))))
+	       (function
+		(lambda (error-object stream)
+		  (princ "Peculiar error " stream)
+		  (prin1 error-object stream))))
+	   error-object stream))
+
+(sysdep-defun decode-time (&optional specified-time)
+  (let* ((date (current-time-string specified-time))
+	 (dateinfo (and date (timezone-parse-date date)))
+	 (timeinfo (and dateinfo (timezone-parse-time (aref dateinfo 3)))))
+    (list (aref timeinfo 2) (aref timeinfo 1)
+	  (aref timeinfo 0) (aref dateinfo 2)
+	  (aref dateinfo 1) (aref dateinfo 0)
+	  "unknown" nil 0)))
+
+(sysdep-defun find-face (face)
+  (car-safe (memq face (face-list))))
+
+(sysdep-defun set-marker-insertion-type (marker type)
+  "Set the insertion-type of MARKER to TYPE.
+If TYPE is t, it means the marker advances when you insert text at it.
+If TYPE is nil, it means the marker stays behind when you insert text at it."
+  nil)
+
+;; window functions
+
+;; not defined in v18
+(sysdep-defun eval-buffer (bufname &optional printflag)
+  (interactive)
+  (save-excursion
+    (set-buffer bufname)
+    (eval-current-buffer)))
+
+(sysdep-defun window-minibuffer-p (window)
+  "Returns non-nil if WINDOW is a minibuffer window."
+  (eq window (minibuffer-window)))
+
+(sysdep-defun window-live-p (window)
+  "Returns t if OBJ is a window which is currently visible."
+  (and (windowp window)
+       (window-point window)))
+
+(provide 'ess-sysdp)
+;;; sysdep.el ends here
+
+;;;(sysdep.el) Local Variables:
+;;;(sysdep.el) eval: (put 'sysdep-defun 'lisp-indent-function 'defun)
+;;;(sysdep.el) eval: (put 'sysdep-defalias 'lisp-indent-function 'defun)
+;;;(sysdep.el) eval: (put 'sysdep-defconst 'lisp-indent-function 'defun)
+;;;(sysdep.el) eval: (put 'sysdep-defvar 'lisp-indent-function 'defun)
+;;;(sysdep.el) End:

File lisp/ess-vars.el

+;;;;; ess-vars.el --- Variable definitions for ESS.
+
+;; Copyright (C) 1997--2000 A.J. Rossini, Martin Maechler,
+;; Kurt Hornik, and Richard M. Heiberger.
+
+;; Author: A.J. Rossini <rossini@biostat.washington.edu>
+;; Maintainer: A.J. Rossini <rossini@biostat.washington.edu>
+;; Created: 25 July 1997
+;; Modified: $Date$
+;; Version: $Revision$
+;; RCS: $Id$
+
+
+;; Keywords: editing and process modes.
+
+;; This file is part of ESS
+
+;; This file is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+;;
+;; This file is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to
+;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+;;
+;; In short: you may use this code any way you like, as long as you
+;; don't charge money for it, remove this notice, or hold anyone liable
+;; for its results.
+
+;;;;;;; OBSOLETE.  As of version 5.50.
+
+(provide 'ess-vars)
+
+
 ; Local variables section
+
+;;; This file is automatically placed in Outline minor mode.
+;;; The file is structured as follows:
+;;; Chapters:     ^L ;
+;;; Sections:    ;;*;;
+;;; Subsections: ;;;*;;;
+;;; Components:  defuns, defvars, defconsts
+;;;              Random code beginning with a ;;;;* comment
+
+;;; Local variables:
+;;; mode: emacs-lisp
+;;; mode: outline-minor
+;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*"
+;;; End:
+
+;;; ess-vars.el ends here

File lisp/essd-ipy.el

+;;; essd-ipy.el --- IPython customization
+
+;; Copyright (C) 2002 A.J. Rossini
+
+;; Author: A.J. Rossini <rossini@u.washington.edu>
+;; Maintainers: A.J. Rossini <rossini@u.washington.edu>
+;; Created: 20 Feb 2002
+;; Modified: $Date$
+;; Version: $Revision$
+;; RCS: $Id$
+;;
+;; Keywords: start up, configuration.
+
+;; This file is part of ESS.
+
+;; This file is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; This file is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to
+;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+
+;;; Commentary:
+;;; This file defines all the R customizations for ESS.  See essl-s.el
+;;; for general S language customizations.
+
+;;; Autoloads and Requires
+
+(ess-message "[essd-ipy:] (require 'essl-py)")
+(require 'essl-py)
+
+(ess-message "[essd-ipy:] (autoload ..) & (def** ..)")
+
+(autoload 'inferior-ess "ess-inf" "Run an ESS process.")
+(autoload 'ess-mode     "ess-mode" "Edit an ESS process.")
+
+;;; Code:
+
+(defvar IPy-customize-alist
+  '((ess-local-customize-alist     . 'IPy-customize-alist)
+    (ess-language                  . "Py")
+    (ess-dialect                   . "IPy")
+    (ess-suffix                    . "py")
+    (ess-loop-timeout              . 500000 )
+    (ess-dump-filename-template    . (concat (user-login-name)
+					     ".%s."
+					     ess-suffix))
+    (ess-mode-editing-alist        . ess-py-editing-alist)
+    (ess-mode-syntax-table         . ess-py-syntax-table)
+    (ess-help-sec-regex            . ess-help-py-sec-regex)
+    (ess-help-sec-keys-alist       . ess-py-help-sec-keys-alist)
+    (ess-object-name-db-file       . "ess-ipy-namedb.el" )
+    (ess-retr-lastvalue-command    . nil)
+    (ess-save-lastvalue-command    . nil)
+    (ess-imenu-mode-function       . 'ess-imenu-ipy)
+    (inferior-ess-program          . inferior-IPY-program-name)
+    (inferior-ess-objects-command  . "objects(pos = %d)\n")
+    (inferior-ess-search-list-command   . "search()\n")
+    (inferior-ess-help-command     . "help(\"%s\", htmlhelp=FALSE)\n")
+    (inferior-ess-exit-command     . "q()\n")
+    (inferior-ess-primary-prompt   . "In \[[1234567890]\]: ")
+    (inferior-ess-secondary-prompt . "...: ")
+    (comint-use-prompt-regexp-instead-of-fields . t) ;; emacs 21 and up
+    (inferior-ess-start-file       . nil)            ;; "~/.ess-R"
+    (inferior-ess-start-args       . "")
+    (ess-STERM  . "iESS")
+    (ess-editor . R-editor)
+    (ess-pager  . R-pager)
+    (inferior-ess-language-start .
+				 (concat "options("
+					 "STERM='"  ess-STERM  "'"
+					 (if ess-editor 
+					     (concat ", editor='" ess-editor "'"))
+					 (if ess-pager 
+					     (concat ", pager='"  ess-pager  "'"))
+					 ")")))
+  "Variables to customize for IPython")
+
+;;; AJR: Need to condition on this...!
+(require 'ess-menu)
+
+;; R that does the right thing irregardless of OS.
+(defun IPython (&optional start-args)
+  "Call 'IPython', the CLI for Python.
+Optional prefix (C-u) allows to set command line arguments, such as --vsize."
+  (interactive "P")
+  (setq ess-customize-alist IPy-customize-alist)
+  ;; for debugging only
+  (ess-write-to-dribble-buffer
+   (format
+    "\n(R): ess-dialect=%s, buf=%s, start-arg=%s\n current-prefix-arg=%s\n"
+    ess-dialect (current-buffer) start-args current-prefix-arg))
+  (let* ((r-always-arg "  ")
+	 (r-start-args
+	  (concat r-always-arg
+		  (if start-args
+		      (read-string
+		       (concat "Starting Args [other than `"
+			       r-always-arg
+			       "'] ? "))
+		    nil)))
+	 default-process-coding-system)
+    (if ess-microsoft-p
+	(setq default-process-coding-system '(undecided-dos . undecided-dos)))
+    (inferior-ess r-start-args) ;; (R)
+    (if inferior-ess-language-start
+	(ess-eval-linewise inferior-ess-language-start))))
+
+
+(defun ess-Py-mode  (&optional proc-name)
+  "Major mode for editing R source.  See `ess-mode' for more help."
+  (interactive)
+  (setq ess-customize-alist R-customize-alist)
+  ;;(setq imenu-generic-expression R-imenu-generic-expression)
+  (ess-mode R-customize-alist proc-name)
+  ;;; AJR: Need to condition on this...!
+  ;; MM: and you probably should really use ess-imenu-mode-function from above!
+  (ess-imenu-R))
+
+(fset 'ipy-mode 'IPy-mode)
+
+
+(autoload 'ess-transcript-mode "ess-trns"
+  "Major mode for editing S transcript files." t)
+
+(defun IPy-transcript-mode ()
+  "Does the right thing."
+  (interactive)
+  (ess-transcript-mode R-customize-alist))
+
+(fset 'r-transcript-mode 'R-transcript-mode)
+
+
 ; provides
+
+(provide 'essd-r)
+
+
 ; Local variables section
+
+;;; This file is automatically placed in Outline minor mode.
+;;; The file is structured as follows:
+;;; Chapters:     ^L ;
+;;; Sections:    ;;*;;
+;;; Subsections: ;;;*;;;
+;;; Components:  defuns, defvars, defconsts
+;;;              Random code beginning with a ;;;;* comment
+
+;;; Local variables:
+;;; mode: emacs-lisp
+;;; outline-minor-mode: nil
+;;; mode: outline-minor
+;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*"
+;;; End:
+
+;;; ess-site.el ends here

File lisp/essd-sp4com.el

+;;; essd-sp4com.el
+;;; Run S-Plus 4.x, the GUI, with the Commands window in the emacs buffer
+;;;
+;;; The advantages:
+;;;  * S text output is in an emacs buffer and therefore searchable
+;;;    using emacs commands.
+;;;  * All GUI graphics and buttons are accessible.
+;;;
+;;; The characteristics of this version of the ESS interface:
+;;;  * We can't type in the *S+4* buffer.
+;;;  * Prompts do NOT appear in the *S+4* buffer.
+;;;  * We can type in the S-Plus Commands window, but no results
+;;;    appear there, all results appear in the *S+4* buffer.
+;;;  * Echoed input is reformatted by S-Plus.
+;;;
+;;;
+;;; Uses explicit file S-transcript.st in starting directory.
+;;;
+
+;;; Work in progress.
+
+
+(defun S+4-command ()
+  "Run S-Plus 4.x, the GUI, with the commands window in the emacs buffer.\n
+Enter \\[S+4-command].  S-Plus 4.x will begin.
+You will be asked for permission to delete previous `S-transcript.st'.
+You must say yes to continue!
+Should you say no, then you must rename it manually
+ and then reissue \\[S+4-command]."
+  (interactive)
+  (S+4-command-startup)	  ; S+4-command-startup uses "&" on the command
+  (S+4-tail)
+)
+
+(defun S+4-tail ()
+  "Put the cursor in an *S+4* buffer and enter \\[S+4-tail]."
+  (interactive)
+  (save-excursion
+    (set-buffer (car (buffer-list))) ; get the ESS buffer just created
+    (shell-command "touch -a S-transcript.st");access time doesn't really exist
+    (if (ess-mark-pop-up
+	 " *Deletions*" 'delete "S-transcript.st" dired-deletion-confirmer
+	 (format "Delete %s " "S-transcript.st"))
+	(delete-file "S-transcript.st")
+      (error "Move the file `S-transcript.st' manually to somewhere else.
+Then place the cursor in the *S+4* buffer and
+issue the command `M-x S+4-tail'"))
+    (ess-eval-linewise "options(echo=T);sink(file='S-transcript.st')")
+    (toggle-read-only nil)		; permit writing in ESS buffer
+    (goto-char (point-max))
+    (insert "tail -f S-transcript.st")
+    (inferior-ess-send-input)
+    (toggle-read-only t)		; restore ESS buffer to be read-only
+    (set-variable 'comint-scroll-to-bottom-on-output t)
+    (set-variable 'comint-scroll-show-maximum-output t)
+    ))
+
+;;; based on dired-mark-pop-up
+(defun ess-mark-pop-up (bufname op-symbol files function &rest args)
+  ;;"Args BUFNAME OP-SYMBOL FILES FUNCTION &rest ARGS.
+  ;;Return FUNCTION's result on ARGS after popping up a window (in a buffer
+  ;;named BUFNAME, nil gives \" *Marked Files*\") showing the marked
+  ;;files.  Uses function `dired-pop-to-buffer' to do that.
+  ;; FUNCTION should not manipulate files.
+  ;; It should only read input (an argument or confirmation).
+  ;;The window is not shown if there is just one file or
+  ;; OP-SYMBOL is a member of the list in `dired-no-confirm'.
+  ;;FILES is the list of marked files."
+  (or bufname (setq bufname  " *Marked Files*"))
+  (if (or (eq dired-no-confirm t)
+	  (memq op-symbol dired-no-confirm)
+	  (= (length files) 1))
+      (apply function args)
+    (save-excursion
+      (set-buffer (get-buffer-create bufname))
+      (erase-buffer)
+      (insert files)  ;; replacement line
+      (remove-text-properties (point-min) (point-max) '(mouse-face)))
+    (save-window-excursion
+      (dired-pop-to-buffer bufname)
+      (apply function args))))
+
+
+
+(defun S+4-command-startup (&optional proc-name)
+  "Call 'S-PLUS 4.x', the 'GUI Thing' from StatSci.  Put S-Plus in an
+independent MS-Window (Splus persists even if the *S+4 ddeclient*
+window is killed in emacs).  Do this by creating a comint process that
+calls sh.  Send a shell command in that sh buffer to call Splus.  When
+it completes set up a shell as a placeholder in the *S+4 ddeclient*
+buffer.  The S-Plus options are correctly set.  In particular, the
+S-Plus Commands window is opened if the Options/General
+Settings/Startup menu says it should be.  There is a 30 second delay
+during startup in which the screen will not be refreshed.  This delay
+is here to allow slow disks to start the Splus program."
+  (interactive)
+  (save-excursion
+    (setq ess-customize-alist S+4-customize-alist)
+    (ess-write-to-dribble-buffer
+     (format "\n(S+4): ess-dialect=%s, buf=%s\n" ess-dialect
+	     (current-buffer)))
+    (setq ess-customize-alist		; change inferior-ess-program
+	  (append ess-customize-alist '((inferior-ess-program   . "sh"))))
+    (setq ess-customize-alist		; change inferior-ess-primary-prompt
+	  (append ess-customize-alist '((inferior-ess-primary-prompt   . "^"))))
+    (setq ess-customize-alist		; change inferior-ess-start-args
+	  (append ess-customize-alist '((inferior-ess-start-args   . "-i"))))
+    (let ((s-proj (getenv "S_PROJ")))
+      (setenv "S_PROJ" (directory-file-name default-directory))
+      (inferior-ess)
+      (sleep-for 2) ; need to wait, else working too fast!  The Splus
+		    ; command in *S+4 ddeclient* should follow the "$"
+		    ; prompt.  If not, then increase the sleep-for time!
+      (setenv "S_PROJ" s-proj))
+    (setq ess-customize-alist S+4-customize-alist)
+    (ess-setq-vars-local ess-customize-alist)
+;;; the next three lines belong in customize-alist, but can't be there
+;;; because of the broken ess-setq-vars-default usage in ess-inf.el
+    (setq inferior-ess-ddeclient         "ddeclient")
+    (setq inferior-ess-client-name       "S-PLUS")
+    (setq inferior-ess-client-command    "SCommand")
+;;; end of what belongs in customize-alist
+    (setq comint-process-echoes nil)
+    (setq comint-input-sender 'comint-simple-send)
+    (goto-char (point-max))
+    (insert (concat inferior-S+4-program-name " "
+		    inferior-ess-start-args " &")) ; Note: there is a final "&".
+    ;; The completion of the command with "&" permits the "tail -f" to run.
+    ;; With the "&", the results of  !system.command  in S get lost.
+    ;; Use dos() to get system results.
+    (inferior-ess-send-input)
+    (sleep-for 30) ; Need to wait, else working too fast!
+                   ; If the ess-current-process-name doesn't appear in the
+       		   ; Splus Commands window increase the sleep-for time!
+    (setq ess-local-process-name ess-current-process-name)
+    (ess-eval-linewise (concat "#" ess-current-process-name))
+    (beginning-of-buffer)
+    (insert
+     "This is strictly a transcript buffer.  You can't type anything here.
+Split the screen with `C-x 2' and use `C-x b RET' to return to your file
+in the top half.\n
+Anything sent to this process from an S-mode buffer goes
+directly to the associated Splus Commands window which sends input and output
+back to this buffer.
+The S-Plus Commands window does not need to be visible.
+Input, but no output, appears in the Commands window.
+Any results of the   !system.command   typed at the S prompt in the
+Splus Commands window get lost.  Use the dos() command.\n
+On completion of your S-Plus session, you will need to kill the tail
+process manually, either from a *shell* window or using the ALT-CTRL-DEL
+task manager.\n\n")
+    (goto-char (point-max))		; comint-mode-map makes *S+4 ddeclient*
+;;  (use-local-map comint-mode-map)     ;a shell buffer after Splus is finished.
+    (set-buffer-process-coding-system 'raw-text-dos 'raw-text-unix)
+    (toggle-read-only t)		; force buffer to be read-only
+    (setq mode-name "ddeESSst")))
+

File lisp/essdsp6w.el

+;;; essdsp6w.el --- S-PLUS 6.x  for Windows customization
+
+;;; copied and edited from essd-sp4.el - Richard M. Heiberger, April 2001
+
+;; Copyright (C) 2001 Richard M. Heiberger <rmh@sbm.temple.edu>
+;; Copyright (C) 2002--2004 A.J. Rossini, Rich M. Heiberger, Martin
+;;	Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
+
+;; Original Author: Richard M. Heiberger <rmh@sbm.temple.edu>
+;; Created: April 2001
+;; Maintainers: ESS-core <ESS-core@stat.math.ethz.ch>
+
+;; Keywords: start up, configuration.
+
+;; This file is part of ESS.
+
+;; This file is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; This file is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to
+;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+
+;;; Commentary:
+;;;
+;;; This file defines all the S-PLUS 6.x for Windows customizations
+;;; for ess-mode with ddeclient.
+
+;;; Requires and Autoloads:
+
+(require 'essl-s)
+(require 'ess-iw32)
+
+(autoload 'inferior-ess "ess-inf" "Run an ESS process.")
+(autoload 'ess-mode     "ess-mode" "Edit an ESS process.")
+
+;;; Code:
+
+(defvar S+6-dialect-name "S+6"
+  "Name of 'dialect' for S-PLUS 6.x.
+Easily changeable in a user's `.emacs'.")
+
+(defvar inferior-S+6-start-args " "
+  "Default is empty.  Can be used for license manager information, for example
+`(setq inferior-S+6-start-args \" S_ELMHOST=\\\\\\\\@123.456.789.012  ELMTIMEOUT=60 \")'."
+;; (setq inferior-S+6-start-args " S_ELMHOST=\\\\@123.456.789.012  ELMTIMEOUT=60 ")  ;; use this line as the model for your site-start.el
+)
+
+(defvar inferior-Sqpe-start-args " "
+  "Default is empty.  Can be used for license manager information, for example
+`(setq inferior-Sqpe-start-args \" S_ELMHOST=@123.456.789.012  ELMTIMEOUT=60 \")'."
+;; (setq inferior-Sqpe-start-args " S_ELMHOST=@123.456.789.012  ELMTIMEOUT=60 ")  ;; use this line as the model for your site-start.el
+)
+
+(defvar inferior-S+6-multipleinstances "/MULTIPLEINSTANCES"
+  "Default \"/MULTIPLEINSTANCES\" opens up a new instance of S+6 in a
+GUI window and connects it to the '(ddeESS [S+6])' window.  The
+alternative nil uses an existing S+6 GUI (if there is one) and
+connects it to the '(ddeESS [S+6])' window.")
+
+(defvar S+6-customize-alist
+  '((ess-local-customize-alist     . 'S+6-customize-alist)
+    (ess-language                  . "S")
+    (ess-dialect                   . S+6-dialect-name)
+    (ess-suffix                    . "S")
+    (ess-mode-editing-alist        . S-editing-alist)
+    (ess-mode-syntax-table         . S-syntax-table)
+    (ess-help-sec-regex            . ess-help-S+-sec-regex)
+    (ess-help-sec-keys-alist       . S+-help-sec-keys-alist)
+    (ess-loop-timeout              . ess-S-loop-timeout)
+    (ess-object-name-db-file       . "ess-sp6-namedb.el" )
+    (ess-retr-lastvalue-command
+     . ".Last.value <- get(\".ess.lvsave\",frame=0)\n")
+    (ess-save-lastvalue-command
+     . "assign(\".ess.lvsave\",.Last.value,frame=0)\n")
+    (inferior-ess-program          . inferior-S+6-program-name)
+;;    (inferior-ess-ddeclient        . "ddeclient")
+;;    (inferior-ess-client-name      . "S-PLUS")
+;;    (inferior-ess-client-command   . "SCommand")
+    (inferior-ess-objects-command  . "objects(%d)\n")
+    (inferior-ess-help-command     . "help(\"%s\")\n")
+    (inferior-ess-exit-command     . "q()\n")
+    (inferior-ess-primary-prompt   . "[a-zA-Z0-9() ]*> ?")
+    (inferior-ess-secondary-prompt . "+ ?")
+    (comint-use-prompt-regexp-instead-of-fields . t) ;; emacs 21 and up
+    (inferior-ess-start-file       . nil) ;"~/.ess-S+6")
+    (inferior-ess-start-args       . (concat
+				      inferior-S+6-multipleinstances
+				      " "
+				      inferior-S+6-start-args
+				      " "
+				      inferior-S+6-print-command
+				      " S_PROJ="
+				      (directory-file-name default-directory))
+				   )
+    (ess-STERM  . "ddeESS")
+    (ess-editor . S-editor)
+    (ess-pager  . S-pager)
+    (inferior-ess-language-start . (eval inferior-S-language-start))
+    )
+ "Variables to customize for S+6")
+
+
+(defvar Sqpe+6-customize-alist
+  '((ess-local-customize-alist     . 'Sqpe+6-customize-alist)
+    (ess-language                  . "S")
+    (ess-dialect                   . S+6-dialect-name)
+    (ess-suffix                    . "S")
+    (ess-mode-editing-alist        . S-editing-alist)
+    (ess-mode-syntax-table         . S-syntax-table)
+    (ess-help-sec-regex            . ess-help-S+-sec-regex)
+    (ess-help-sec-keys-alist       . S+-help-sec-keys-alist)
+    (ess-loop-timeout              . 500000 )
+    (ess-object-name-db-file       . "ess-sp6-namedb.el" )
+    (ess-retr-lastvalue-command
+     . ".Last.value <- get(\".ess.lvsave\",frame=0)\n")
+    (ess-save-lastvalue-command
+     . "assign(\".ess.lvsave\",.Last.value,frame=0)\n")
+    (inferior-ess-program          . inferior-Sqpe+6-program-name)
+    (inferior-ess-objects-command  . "objects(%d)\n")
+    (inferior-ess-help-command     . "help(\"%s\")\n")
+    (inferior-ess-exit-command     . "q()\n")
+    (inferior-ess-primary-prompt   . "[a-zA-Z0-9() ]*> ?")
+    (inferior-ess-secondary-prompt . "+ ?")
+    (comint-use-prompt-regexp-instead-of-fields . t) ;; emacs 21 and up
+    (inferior-ess-start-file       . nil) ;"~/.ess-S+6")
+    (inferior-ess-start-args       . (concat
+				      "ALWAYS_PROMPT=X"  ;;workaround for bug in S-Plus 6 for Windows
+				      " "
+				      inferior-Sqpe-start-args ;; license manager for example
+				      ))
+    (ess-STERM  . "iESS")
+    (ess-editor . S-editor)
+    (ess-pager  . S-pager)
+    (inferior-ess-language-start . (eval inferior-S-language-start))
+)
+ "Variables to customize for Sqpe+6.")
+
+
+
+;;; There are extra complications in S+6 (compared to S+3) because
+;;;
+;;; (1) The StatSci supplied Splus.exe doesn't work in an emacs
+;;;     buffer.  It works as as a GUI window and we must send commands
+;;;     to it through ddeclient.  Nonetheless, we need to give it a
+;;;     process name and be sure that that there is a valid running
+;;;     process in the '(ddeESS [S+6])' buffer.  Therefore we create an
+;;;     ESS process in the buffer as a placeholder and start a shell
+;;;     in the ESS buffer.  From the shell we start Splus.  Once Splus
+;;;     finishes initializing and kills the original shell, we start
+;;;     another shell.  We have a buffer-local variable
+;;;     inferior-ess-ddeclient, initialized to nil.  When there is a
+;;;     non-nil value of inferior-ess-ddeclient we send lines to
+;;;     inferior-ess-ddeclient rather than to the Splus process.
+;;; (2) There is no Splus process running in the '(ddeESS [S+6])'
+;;;     buffer.  Therefore inferior-ess will never see a prompt,
+;;;     unless we first change it to the null prompt "^".  Then once
+;;;     the process has started, we change it back.
+;;; (3) When M-x S+6 starts Splus by a shell command, then Splus is an
+;;;     independent process and will be survive if the '(ddeESS [S+6])'
+;;;     buffer is killed (or emacs is quit).  The '(ddeESS [S+6])' is
+;;;     made read-only and a warning is placed in it saying that "You
+;;;     can't type anything here."  Actually, if thestandalone Splus
+;;;     is killed and the '(ddeESS [S+6])' is made writable (C-x C-q),
+;;;     then '(ddeESS [S+6])' becomes a shell buffer.
+;;;
+(defun S+6 (&optional proc-name)
+  "Verify that `inferior-S+6-program-name' points to S-Plus 6.
+Start normally for S-Plus 6.1.  Inform the user to start S-Plus 6.0
+from the icon and then connect to it with `S+6-existing'.  Give an error
+message if `inferior-S+6-program-name' doesn't point to S-Plus 6."
+  (interactive)
+  (save-excursion
+    (set-buffer (find-file-noselect
+		 (concat (executable-find inferior-S+6-program-name)
+			 "/../../versions") t))
+    (toggle-read-only 1)
+    (forward-line)
+    (if (not (search-backward-regexp "6.[1-9]" (point-min) t))
+	(if (search-backward "6.0" (point-min) t)
+	    (error "S-Plus 6.0 for Microsoft Windows has a bug that
+prevents it from being started by emacs.  Instead, you must start it
+by double-clicking an icon.  Then you can connect to it with
+`S+6-existing'.  You should consider upgrading to S-Plus 6.1 or higher.")
+	  (error "The emacs variable `inferior-S+6-program-name' does
+not point to S-Plus 6.  Please add `splus6?/cmd'
+(expand the `?' to match your setup) to your `exec-path' or
+specify the complete path to `Splus.exe' in the variable
+`inferior-S+6-program-name' in your `.emacs' file."))))
+  (S+6-initiate proc-name)) ;; normal start
+
+(defun S+6-initiate (&optional proc-name)
+  "Call 'S-PLUS 6.x for Windows', the 'GUI Thing' from StatSci.  Put
+S-Plus in an independent MS-Window (Splus persists even if the
+'(ddeESS [S+6])' window is killed in emacs).  Do this by creating a
+comint process that calls sh.  Send a shell command in that sh buffer
+to call Splus.  When it completes set up a shell as a placeholder in
+the '(ddeESS [S+6])' buffer.  The S-Plus options are correctly set.
+In particular, the S-Plus Commands window is opened if the
+Options/General Settings/Startup menu says it should be.  There is a
+startup delay of `ess-S+6-startup-delay' seconds during which the
+screen will not be refreshed.  This delay is here to allow slow disks
+to start the Splus program."
+  (interactive)
+  (save-excursion
+    (setq ess-customize-alist S+6-customize-alist)
+    (ess-write-to-dribble-buffer
+     (format "\n(S+6): ess-dialect=%s, buf=%s\n" ess-dialect
+	     (current-buffer)))
+    (setq ess-customize-alist		; change inferior-ess-program
+	  (append ess-customize-alist '((inferior-ess-program   . "sh"))))
+    (setq ess-customize-alist		; change inferior-ess-primary-prompt
+	  (append ess-customize-alist '((inferior-ess-primary-prompt   . "^"))))
+    (setq ess-customize-alist		; change inferior-ess-start-args
+	  (append ess-customize-alist '((inferior-ess-start-args   . "-i"))))
+    (let ((s-proj (getenv "S_PROJ")))
+      (cd (w32-short-file-name (directory-file-name default-directory)))
+      (setenv "S_PROJ" default-directory)
+      (inferior-ess)
+      (sleep-for 2) ; need to wait, else working too fast!  The Splus
+		    ; command in '(ddeESS [S+6])' should follow the "$"
+		    ; prompt.  If not, then increase the sleep-for time!
+      (setenv "S_PROJ" s-proj))
+    (setq ess-customize-alist S+6-customize-alist)
+    (ess-setq-vars-local ess-customize-alist)
+;;; the next three lines belong in customize-alist, but can't be there
+;;; because of the broken ess-setq-vars-default usage in ess-inf.el
+    (setq inferior-ess-ddeclient         "ddeclient")
+    (setq inferior-ess-client-name       "S-PLUS")
+    (setq inferior-ess-client-command    "SCommand")
+;;; end of what belongs in customize-alist
+    (setq comint-process-echoes nil)
+    (setq comint-input-sender 'comint-simple-send)
+    (goto-char (point-max))
+    (insert (concat inferior-S+6-program-name " "
+		    inferior-ess-start-args)) ; Note: there is no final "&".
+    ;; Without the "&", the results of  !system.command  come to '(ddeESS [S+6])'
+    ;; With the "&", the results of  !system.command  in S get lost.
+    (inferior-ess-send-input)
+    (sleep-for ess-S+6-startup-delay) ; Need to wait, else working too fast!
+                   ; If the ess-current-process-name doesn't appear in the
+       		   ; Splus Commands window increase the sleep-for time!
+    (setq ess-local-process-name ess-current-process-name)
+    (ess-eval-linewise (concat "#" ess-current-process-name))
+    (beginning-of-buffer)
+    (insert
+     "This is a placeholder buffer.  You can't type anything here.
+Use `C-x b RET' to return to your file.\n
+Anything sent to this process from an S-mode buffer goes
+directly to the associated Splus Commands window.\n
+The S-Plus Commands window must be visible.
+You may need to open the S-Plus Commands window manually (by clicking on
+Splus/Window/Commands Window).\n
+Any results of the   !system.command   typed at the S prompt in the
+Splus Commands window appear in this buffer.\n\n")
+    (goto-char (point-max))		; comint-mode-map makes '(ddeESS [S+6])'
+;;  (use-local-map comint-mode-map)     ;a shell buffer after Splus is finished.
+    (set-buffer-process-coding-system 'raw-text-dos 'raw-text-unix)
+    (toggle-read-only t)		; force buffer to be read-only
+    (setq mode-name "ddeESS")
+;;  (ess-eval-linewise inferior-S+6-editor-pager-command)
+    (if inferior-ess-language-start
+	(ess-eval-linewise inferior-ess-language-start))
+    ))
+
+
+
+
+(defun S+6-existing (&optional proc-name)
+  "Call 'S-PLUS 6.x for Windows', the 'GUI Thing' from StatSci.  Do so by
+finding an existing S-Plus in an independent MS-Window (if there is one) and
+set up a '(ddeESS [S+6])' buffer in emacs.  If there is no existing
+S-Plus, then a new one will be opened in the default directory,
+usually something like c:/Program Files/spls45se/users/yourname.
+If you have a HOME environment variable, it will open it there."
+  (interactive)
+  (let* ((inferior-S+6-multipleinstances " & # ") ; Note: there is a final "&".
+	 (ess-S+6-startup-delay 0)) ;; No delay for existing S-Plus
+    ;; Without the "&", there is a core dump.
+    ;; With the "&", the results of  !system.command  in S get lost.
+    ;; We are picking up an existing S-Plus process for sending to.
+    ;; It doesn't know about us, so nothing comes back.
+    (S+6-initiate proc-name))
+  (save-excursion
+    (set-buffer (car (buffer-list)))    ; get the ESS buffer just created
+    (toggle-read-only nil)		; permit writing in ESS buffer
+    (goto-char (point-max))
+    (beginning-of-line)
+    (forward-line -1)
+    (insert
+     "This is S+6-existing.
+Results of the   !system.command   typed at the S prompt in the
+Splus Commands window blink a DOS window and you won't see them.\n\n")
+    (toggle-read-only t)		; restore ESS buffer to be read-only
+    ))
+
+
+;;; There are extra complications in Sqpe+6 (compared to S+3) because
+;;; (1) The StatSci supplied Sqpe.exe won't work without SHOME as an
+;;;     environment variable and Sqpe does not take command line
+;;;     arguments and
+;;; (2) Sqpe.exe comes up with options(interactive=F), which means it
+;;;     doesn't provide prompts by default, and we must change it to T so
+;;;     it will provide prompts.
+;;;
+(defun Sqpe+6 (&optional proc-name)
+  "Call 'Sqpe' from 'S-PLUS 6.x for Windows', the 'Real Thing'  from StatSci."
+  (interactive)
+  (setq ess-customize-alist Sqpe+6-customize-alist)
+  (let* ((shome-nil-p (equal (getenv "SHOME") nil)))
+    (if shome-nil-p (setenv "SHOME" inferior-Sqpe+6-SHOME-name))
+    (ess-write-to-dribble-buffer
+     (format "\n(Sqpe+6): ess-dialect=%s, buf=%s\n" ess-dialect
+	     (current-buffer)))
+    (setq ess-customize-alist		; change inferior-ess-primary-prompt
+	  (append ess-customize-alist '((inferior-ess-primary-prompt   . "^"))))
+    (inferior-ess)
+    (setq ess-customize-alist Sqpe+6-customize-alist) ; restore i-e-p-p in alist
+    (ess-setq-vars-local ess-customize-alist)    ; restore i-e-p-p in buffer
+    (setq inferior-ess-prompt                    ; define with correct i-e-p-p
+	  ;; Do not anchor to bol with `^'       ; (copied from ess-inf.el)
+	  (concat "\\("
+		  inferior-ess-primary-prompt
+		  "\\|"
+		  inferior-ess-secondary-prompt
+		  "\\)"))
+    (setq comint-prompt-regexp (concat "^" inferior-ess-prompt))
+                                                ; define with correct i-e-p-p
+    (setq comint-input-sender 'inferior-ess-input-sender)
+    (add-hook 'comint-output-filter-functions 'shell-strip-ctrl-m nil t)
+    (goto-char (point-max))
+    (insert "options(interactive=T)")
+    (inferior-ess-send-input)
+    (setq mode-name "iESS(Sqpe)")
+;;  (ess-eval-linewise inferior-S+6-editor-pager-command)
+    (if inferior-ess-language-start
+	(ess-eval-linewise inferior-ess-language-start))
+    (if shome-nil-p (setenv "SHOME" nil))))
+
+
+
+(defun S+6-mode (&optional proc-name)
+  "Major mode for editing S+6 source.  See `ess-mode' for more help."
+  (interactive)
+  (setq ess-customize-alist S+6-customize-alist)
+  (ess-mode S+6-customize-alist proc-name)
+  (if ess-imenu-use-S (ess-imenu-R)))
+
+
+(defun S+6-transcript-mode ()
+  "S-PLUS 6.x transcript mode."
+  (interactive)
+  (ess-transcript-mode S+6-customize-alist))
+
+
+(defun S+6-msdos (&optional proc-name)
+  "Verify that `inferior-S+6-program-name' points to S-Plus 6.
+Start normally for S-Plus 6.1.  Inform the user to start S-Plus 6.0
+from the icon and then connect to it with `S+6-msdos-existing'.  Give an error
+message if `inferior-S+6-program-name' doesn't point to S-Plus 6."
+  (interactive)
+  (save-excursion
+    (set-buffer (find-file-noselect
+		 (concat (executable-find inferior-S+6-program-name)
+			 "/../../versions") t))
+    (toggle-read-only 1)
+    (forward-line)
+    (if (not (search-backward "6.1" (point-min) t))
+	(if (search-backward "6.0" (point-min) t)
+	    (error "S-Plus 6.0 for Microsoft Windows has a bug that
+prevents it from being started by emacs.  Instead, you must start it
+by double-clicking an icon.  Then you can connect to it with
+`S+6-msdos-existing'.  You should consider upgrading to S-Plus 6.1.")
+	  (error "The emacs variable `inferior-S+6-program-name' does
+not point to S-Plus 6.  Please add `splus61/cmd' to your `exec-path' or
+specify the complete path to `Splus.exe' in the variable
+`inferior-S+6-program-name' in your `.emacs' file."))))
+  (S+6-msdos-initiate proc-name)) ;; normal start
+
+
+(defun S+6-msdos-initiate (&optional proc-name)
+  "Call 'S-PLUS 6.x for Windows', the 'GUI Thing' from StatSci.  Put
+S-Plus in an independent MS-Window (Splus persists even if the
+'(ddeESS [S+6])' window is killed in emacs).  Do this by creating a
+comint process that calls sh.  Send a shell command in that sh buffer
+to call Splus.  When it completes set up a shell as a placeholder in
+the '(ddeESS [S+6])' buffer.  The S-Plus options are correctly set.
+In particular, the S-Plus Commands window is opened if the
+Options/General Settings/Startup menu says it should be.  There is a
+startup delay of `ess-S+6-startup-delay' seconds during which the
+screen will not be refreshed.  This delay is here to allow slow disks
+to start the Splus program."
+  (interactive)
+  (save-excursion
+    (setq ess-customize-alist S+6-customize-alist)
+    (ess-write-to-dribble-buffer
+     (format "\n(S+6): ess-dialect=%s, buf=%s\n" ess-dialect
+	     (current-buffer)))
+    (setq ess-customize-alist		; change inferior-ess-program
+	  (append ess-customize-alist '((inferior-ess-program
+					 . (getenv "COMSPEC")))))
+    (setq ess-customize-alist		; change inferior-ess-primary-prompt
+	  (append ess-customize-alist '((inferior-ess-primary-prompt   . "^"))))
+    (setq ess-customize-alist		; change inferior-ess-start-args
+	  (append ess-customize-alist '((inferior-ess-start-args   . ""))))
+    (let ((s-proj (getenv "S_PROJ")))
+      (cd (w32-short-file-name (directory-file-name default-directory)))
+      (setenv "S_PROJ" default-directory)
+      (inferior-ess)
+      (sleep-for 2) ; need to wait, else working too fast!  The Splus
+		    ; command in '(ddeESS [S+6])' should follow the "$"
+		    ; prompt.  If not, then increase the sleep-for time!
+      (setenv "S_PROJ" s-proj))
+    (setq ess-customize-alist S+6-customize-alist)
+    (ess-setq-vars-local ess-customize-alist)
+;;; the next three lines belong in customize-alist, but can't be there
+;;; because of the broken ess-setq-vars-default usage in ess-inf.el
+    (setq inferior-ess-ddeclient         "ddeclient")
+    (setq inferior-ess-client-name       "S-PLUS")
+    (setq inferior-ess-client-command    "SCommand")
+;;; end of what belongs in customize-alist
+    (setq comint-input-sender 'comint-simple-send)
+    (setq comint-process-echoes nil)
+    (set-buffer-process-coding-system 'raw-text-dos 'raw-text-dos)
+    (goto-char (point-max))
+    (insert (concat inferior-S+6-program-name " "
+		    inferior-ess-start-args)) ; Note: there is no final "&".
+    ;; Without the "&", the results of  !system.command  come to '(ddeESS [S+6])'
+    ;; With the "&", the results of  !system.command  in S get lost.
+    (inferior-ess-send-input)
+    (sleep-for ess-S+6-startup-delay) ; Need to wait, else working too fast!
+                   ; If the ess-current-process-name doesn't appear in the
+       		   ; Splus Commands window increase the sleep-for time!
+;;; from msdos-minor-mode
+  (setq comint-process-echoes t)
+  (add-hook 'comint-output-filter-functions 'shell-strip-ctrl-m nil t)
+;;; end from msdos-minor-mode
+    (setq ess-local-process-name ess-current-process-name)
+    (ess-eval-linewise (concat "#" ess-current-process-name))
+    (beginning-of-buffer)
+    (insert
+     "This is a placeholder buffer.  You can't type anything here.
+Use `C-x b RET' to return to your file.\n
+Anything sent to this process from an S-mode buffer goes
+directly to the associated Splus Commands window.\n
+The S-Plus Commands window must be visible.
+You may need to open the S-Plus Commands window manually
+(by clicking on Splus/Window/Commands Window).\n
+There is a `ess-S+6-startup-delay' second delay when this program starts
+during which the emacs screen will be partially blank.\n
+Remember to 'q()' from S-Plus and
+then C-x C-q exit from the '(ddeESS [S+6])' buffer,
+or take the risk of not being able to shut down your computer
+and suffering through scandisk.\n
+Any results of the   !system.command   typed at the S prompt in the
+Splus Commands window (are supposed to) appear in this buffer.\n\n")
+    (goto-char (point-max))	       ; comint-mode-map makes '(ddeESS [S+6])'
+    (use-local-map comint-mode-map)    ; a shell buffer after Splus is finished.
+    (toggle-read-only t)	       ; force buffer to be read-only
+    (setq mode-name "ddeESS")
+;;  (ess-eval-linewise inferior-S+6-editor-pager-command)
+    (if inferior-ess-language-start
+      (ess-eval-linewise inferior-ess-language-start))
+    ))
+
+(defun S+6-msdos-existing (&optional proc-name)
+  "Call 'S-PLUS 6.x for Windows', the 'GUI Thing' from StatSci.  Do so by
+finding an existing S-Plus in an independent MS-Window (if there is one) and
+set up a '(ddeESS [S+6])' buffer in emacs.  If there is no existing
+S-Plus, then a new one will be opened in the default directory,
+usually something like c:/Program Files/spls45se/users/yourname.
+If you have a HOME environment variable, it will open it there."
+  (interactive)
+  (let* ((inferior-S+6-multipleinstances "")
+	 (ess-S+6-startup-delay 0)) ;; No delay for existing S-Plus
+    (S+6-msdos-initiate proc-name))
+  (save-excursion
+    (set-buffer (car (buffer-list)))    ; get the ESS buffer just created
+    (toggle-read-only nil)		; permit writing in ESS buffer
+    (goto-char (point-max))
+    (beginning-of-line)
+    (forward-line -1)
+    (insert
+     "This is S+6-msdos-existing.
+Results of the   !system.command   typed at the S prompt in the
+Splus Commands window blink a DOS window and you won't see them.\n\n")
+    (toggle-read-only t)		; restore ESS buffer to be read-only
+    ))
+
+(defun ess-sqpe-versions-create ()
+  "Generate the `M-x splusxy' functions for starting other versions of
+Sqpe.  See `ess-sqpe-versions' for strings that determine which
+functions are created.  This works by creating a temp buffer where the
+template function `Sqpe+template' is edited by replacing the string
+'Sqpe+template' by the version name.  The list of functions actually
+created appears in the *ESS* buffer.
+
+The result `ess-sqpe-versions-created' will store a list of the new
+Sqpe defuns, if any, that were created.  The defuns will normally be
+placed on the menubar upon ESS initialisation."
+  (let ((beg)
+	(versions)
+	(version)
+	(eval-buf (get-buffer-create "*ess-temp-sqpe-evals*"))
+	(ess-sqpe-versions-created)
+	)
+    ;;
+    (save-excursion
+      (set-buffer eval-buf)
+      ;; clear the buffer.
+      (delete-region (point-min) (point-max))
+
+      ;; Find which versions of Sqpe we want.
+      (setq versions (ess-uniq-list ess-SHOME-versions))
+      ;; Iterate over each string in VERSIONS, creating a new defun each time.
+      (while versions
+	(setq version (car versions)
+	      versions (cdr versions))
+	(if (file-executable-p version)
+	    (progn
+	      (setq beg (point))
+	      (prin1 (symbol-function 'Sqpe+template) eval-buf)
+	      (insert "\n\n")
+	      (goto-char beg)
+	      (while (search-forward "lambda" nil t 1)
+		(replace-match
+		 (concat "defun " (file-name-nondirectory version))
+		 t t))
+	      (while (search-forward "ess-SHOME" nil t)
+		(replace-match version t t))
+	      (goto-char (point-max))
+	      (setq ess-sqpe-versions-created
+		    (cons (file-name-nondirectory version)
+			  ess-sqpe-versions-created))
+	      (ess-write-to-dribble-buffer
+	       (format
+		"(Sqpe): ess-sqpe-versions-create making M-x defun %s for %s \n"
+		(file-name-nondirectory version) version))
+	      )))
+      ;; buffer has now been created with defuns, so eval them!
+      (eval-buffer)
+      (kill-buffer eval-buf))
+    ess-sqpe-versions-created))
+
+;; template function used by ess-sqpe-versions-create
+(defun Sqpe+template (&optional proc-name)
+  "Call 'Sqpe' from 'S-PLUS for Windows ess-SHOME',
+the 'Real Thing'  from StatSci.
+This function was generated by `ess-sqpe-versions-create'."
+  (interactive)
+  (setq ess-customize-alist Sqpe+6-customize-alist)
+  (let* ((shome-old (getenv "SHOME"))
+	 (inferior-Sqpe+6-SHOME-name "ess-SHOME")
+	 (inferior-Sqpe+6-program-name (concat "ess-SHOME" "/cmd/sqpe.exe")))
+    (setenv "SHOME" "ess-SHOME")
+    (ess-write-to-dribble-buffer
+     (format "\n(Sqpe+template): ess-dialect=%s, buf=%s\n" ess-dialect
+	     (current-buffer)))
+    (setq ess-customize-alist	 ; change inferior-ess-primary-prompt
+	  (append ess-customize-alist
+		  '((inferior-ess-primary-prompt   . "^"))))
+    (inferior-ess)
+    (setq ess-customize-alist Sqpe+6-customize-alist) ; restore i-e-p-p in alist
+    (ess-setq-vars-local ess-customize-alist) ; restore i-e-p-p in buffer
+    (setq inferior-ess-prompt		; define with correct i-e-p-p
+	  ;; Do not anchor to bol with `^'       ; (copied from ess-inf.el)
+	  (concat "\\("
+		  inferior-ess-primary-prompt
+		  "\\|"
+		  inferior-ess-secondary-prompt
+		  "\\)"))
+    (setq comint-prompt-regexp (concat "^" inferior-ess-prompt))
+					; define with correct i-e-p-p
+    (setq comint-input-sender 'inferior-ess-input-sender)
+    (add-hook 'comint-output-filter-functions 'shell-strip-ctrl-m nil t)
+    (goto-char (point-max))
+    (insert "options(interactive=T)")
+    (inferior-ess-send-input)
+    (setq mode-name "iESS(Sqpe)")
+    ;;  (ess-eval-linewise inferior-S+6-editor-pager-command)
+    (if inferior-ess-language-start
+	(ess-eval-linewise inferior-ess-language-start))
+    (setenv "SHOME" shome-old)))
+
+
+
 ; Provide package
+
+(provide 'essdsp6w)
+
+
 ; Local variables section
+
+;;; This file is automatically placed in Outline minor mode.
+;;; The file is structured as follows:
+;;; Chapters:     ^L ;
+;;; Sections:    ;;*;;
+;;; Subsections: ;;;*;;;
+;;; Components:  defuns, defvars, defconsts
+;;;              Random code beginning with a ;;;;* comment
+
+;;; Local variables:
+;;; mode: emacs-lisp
+;;; outline-minor-mode: nil
+;;; mode: outline-minor
+;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*"
+;;; End:
+
+;;; essdsp6w.el ends here

File lisp/essl-py.el

+;;; essl-py.el --- Support for editing Python source code
+
+;; Copyright (C) 2002  A.J. Rossini
+;; R.M. Heiberger, M. Maechler, and A.J. Rossini.