[Fix recording of file names in SWANK:COMPILE-STRING-FOR-EMACS so that the source file name given to the compiler at least works for package definitions, even if it is not correct.
Taylor Campbell <campbell@mumble.net>**20060710160040
 
 The RPC implementation formerly would construct a complete file name
 from the buffer name and directory supplied, but this would confuse
 Scheme48 if the buffer were named `packages.scm<2>' or something,
 because Scheme48 thinks that `>' is a directory separator and would
 not strip the `packages.scm<2>' part at all when computing the names
 of other files in the same directory as the file in which the package
 was defined.  This is necessary for loading files in packages to work
 at all, since otherwise they would be taken relatively, and changing
 the current working directory would screw up any unloaded packages.
 
 Fortunately, FILE-NAME-DIRECTORY is idempotent, so it is safe, for
 the purposes of the module system, to pass along only the directory.
 This means, though, that (%FILE-NAME%), from the SOURCE-FILE-NAMES
 structure, will evaluate to a directory name, not an actual file
 name, which is incorrect.  Until SLIME passes a file name along with
 the directory path, however, this is the best we can do, and I don't
 *think* there will be much of a problem with %FILE-NAME%, since it is
 seldom used outside the module system, and even more seldom used
 without FILE-NAME-DIRECTORY anyway.
] {
hunk ./loader.scm 42
-  (let ((filename (and buffer (namestring buffer dir #f))))
-    (with-swank-compiler
-      (lambda ()
-        (let* ((package (interaction-environment))
-               (cenv (let ((cenv (package->environment package)))
-                       (if filename
-                           (bind-source-file-name filename cenv)
-                           cenv)))
-               (template (swank-compile-forms
-                          (read-all (make-string-input-port string))
-                          package
-                          cenv
-                          (and buffer (namestring buffer dir #f)))))
-          (swank-run-template template
-                              (package-uid package)))
-        '()))))
+  (with-swank-compiler
+    (lambda ()
+      (let* ((package (interaction-environment))
+             (cenv (let ((cenv (package->environment package)))
+                     (if dir
+                         (bind-source-file-name dir cenv)
+                         cenv)))
+             (template (swank-compile-forms
+                        (read-all (make-string-input-port string))
+                        package
+                        cenv
+                        `(BUFFER ,buffer POSITION ,pos))))
+        (swank-run-template template
+                            (package-uid package)))
+      '())))
}
