*** orig/lisp/cmuscheme.el
--- mod/lisp/cmuscheme.el
***************
*** 233,243 ****
  
  ;;;###autoload
  (defun run-scheme (cmd)
!   "Run an inferior Scheme process, input and output via buffer *scheme*.
  If there is a process already running in `*scheme*', switch to that buffer.
  With argument, allows you to edit the command line (default is value
! of `scheme-program-name').  Runs the hooks `inferior-scheme-mode-hook'
! \(after the `comint-mode-hook' is run).
  \(Type \\[describe-mode] in the process buffer for a list of commands.)"
  
    (interactive (list (if current-prefix-arg
--- 233,247 ----
  
  ;;;###autoload
  (defun run-scheme (cmd)
!   "Run an inferior Scheme process, input and output via buffer `*scheme*'.
  If there is a process already running in `*scheme*', switch to that buffer.
  With argument, allows you to edit the command line (default is value
! of `scheme-program-name').
! If a file `~/.emacs_SCHEMENAME' exists, it is given as initial input.
! Note that this may lose due to a timing error if the Scheme processor
! discards input when it starts up.
! Runs the hook `inferior-scheme-mode-hook' \(after the `comint-mode-hook'
! is run).
  \(Type \\[describe-mode] in the process buffer for a list of commands.)"
  
    (interactive (list (if current-prefix-arg
***************
*** 246,258 ****
    (if (not (comint-check-proc "*scheme*"))
        (let ((cmdlist (scheme-args-to-list cmd)))
  	(set-buffer (apply 'make-comint "scheme" (car cmdlist)
! 			   nil (cdr cmdlist)))
  	(inferior-scheme-mode)))
    (setq scheme-program-name cmd)
    (setq scheme-buffer "*scheme*")
    (pop-to-buffer "*scheme*"))
  ;;;###autoload (add-hook 'same-window-buffer-names "*scheme*")
  
  (defun scheme-send-region (start end)
    "Send the current region to the inferior Scheme process."
    (interactive "r")
--- 250,273 ----
    (if (not (comint-check-proc "*scheme*"))
        (let ((cmdlist (scheme-args-to-list cmd)))
  	(set-buffer (apply 'make-comint "scheme" (car cmdlist)
! 			   (scheme-start-file (car cmdlist)) (cdr cmdlist)))
  	(inferior-scheme-mode)))
    (setq scheme-program-name cmd)
    (setq scheme-buffer "*scheme*")
    (pop-to-buffer "*scheme*"))
  ;;;###autoload (add-hook 'same-window-buffer-names "*scheme*")
  
+ (defun scheme-start-file (prog)
+   "Return the name of the start file corresponding to PROG.
+ Search in the directories \"~\" and \"~/.emacs.d\", in this
+ order.  Return nil if no start file found."
+   (let* ((name (concat ".emacs_" (file-name-nondirectory prog)))
+          (start-file (concat "~/" name)))
+     (if (file-exists-p start-file)
+         start-file
+       (let ((start-file (concat user-emacs-directory name)))
+         (and (file-exists-p start-file) start-file)))))
+ 
  (defun scheme-send-region (start end)
    "Send the current region to the inferior Scheme process."
    (interactive "r")
