 	 tmpvar tmpvar tmpvar2)))))
 
 (defun inferior-erlang-compute-leex-compile-command (module-name opts)
-  (let ((file-name        (buffer-file-name))
+  (let ((file-name        (erlang-local-buffer-file-name))
 	(erl-compile-expr (inferior-erlang-remove-any-trailing-dot
 			   (inferior-erlang-compute-erl-compile-command
 			    module-name opts))))

(defun inferior-erlang-compile-outdir ()
  "Return the directory to compile the current buffer into."
  (let* ((buffer-dir (directory-file-name
		      (file-name-directory (buffer-file-name))))
	 (parent-dir (directory-file-name
		      (file-name-directory buffer-dir)))
         (ebin-dir (concat (file-name-as-directory parent-dir) "ebin"))

  (inferior-erlang-prepare-for-input)
  (let* ((dir (inferior-erlang-compile-outdir))
;;; (file (file-name-nondirectory (buffer-file-name)))
	 (noext (substring (erlang-local-buffer-file-name) 0 -4))
	 (opts (append (list (cons 'outdir dir))
		       (if current-prefix-arg
			   (list 'debug_info 'export_all))
