     (simulate-input-expression (concat ":sw " filename))))
 
 (defun sw::file-to-specware-unit-id (filename)
-  (when (eq (elt filename 1) ?:)
-    (setq filename (substring filename 2)))
   (let ((len (length filename)))
     (when (equal ".sw" (substring filename (- len 3)))
       (setq filename (substring filename 0 (- len 3))))
     (setq filename (sw::normalize-filename filename))
-    (name-relative-to-swpath filename)))
+    (setq filename (name-relative-to-swpath filename))
+    (when (eq (elt filename 1) ?:)
+      (setq filename (substring filename 2)))
+    filename))
 
 (defun sw::normalize-filename (filename)
   (setq filename (replace-in-string filename "\\\\" "/"))

  (interactive "r")
  (let ((filename (sw::file-to-specware-unit-id buffer-file-name))
	(text (buffer-substring beg end)))
    (simulate-input-expression (concat ":swe-spec " filename))
    (sleep-for 0.1)
    (simulate-input-expression (concat ":swe " text))))

(defun sw:set-swe-spec ()

    (when compile-and-load?
      (simulate-input-expression (concat ":cl " dir "lisp/" unitname)))))

(defun sw:gcl-current-file ()
  (interactive)
  (save-buffer)
  (let ((filename (sw::file-to-specware-unit-id buffer-file-name)))
