Wouldn't it be better to take a more generic approach and supply a hook? I.e., modify the code to read
(defun slime-scratch-buffer () "Return the scratch buffer, create it if necessary." (or (get-buffer "*slime-scratch*") (with-current-buffer (get-buffer-create "*slime-scratch*") (lisp-mode) (use-local-map slime-scratch-mode-map) (slime-mode t) (run-hooks 'slime-scratch-mode-hook) ; <-- new addition (current-buffer))))
Then the user could just say something like
(defun set-slime-scratch-file-name () (when (and (boundp 'slime-scratch-file) slime-scratch-file) (setf buffer-file-name slime-scratch-file))) (add-hook 'slime-scratch-mode-hook 'set-slime-scratch-file-name)
And if that proposal does not meet with approval, you can always add the hook yourself:
(defun maybe-run-slime-scratch-mode-hook () (when (string= (buffer-name) "*slime-scratch*") (run-hooks 'slime-scratch-mode-hook))) (add-hook 'slime-mode-hook 'maybe-run-slime-scratch-mode-hook t)
- Harald