 (defun mural-response-complete (result)
   (integerp (string-match "^DONE" result)))
 
-(defun mural-read-tag ()
-  (let ((file-base (buffer-file-name)))
-    (if (not file-base)
-        (error "no file associated with buffer"))
-    (setq mural-current-tagfile (mural-tagfile-for-filename file-base))
+(defun mural-read-tag (file-base)
+  "Run the typeahead in the minibuffer against a tagset
+appropriate for FILE-BASE.  Return a taginfo list which can be
+accessed through the mural-tag-* functions"
+  (if (not file-base)
+      (error "no file associated with buffer"))
+  (let ((mural-current-tagfile (mural-tagfile-for-filename file-base)))
     (if (not mural-current-tagfile)
         (error "no tagfile associated with %s" file-base))
-    (setq ido-dynamic-match-fn 'mural-query-save-tag)
-    (unwind-protect ;; i have no idea what's going on here
-        (ido-completing-read "tag: " '("nope"))
-      (setq ido-dynamic-match-fn nil))))
+    (let ((ido-dynamic-match-fn 'mural-query-save-tag)
+          (mural-last-query-result nil)) ;; set by mural-query-save-tag
+      (assoc
+       (ido-completing-read "tag: " '("nope"))
+       mural-last-query-result))))
 
+;; Tags are lists like '(tag filename row tagfile)
 (defun mural-tag-tagname (tag)
   (elt tag 0))
 (defun mural-tag-filename (tag)
-  (elt tag 1))
+  (file-truename
+   (concat
+    (file-name-directory (elt tag 3))
+    (elt tag 1))))
 (defun mural-tag-row (tag)
   (elt tag 2))
 
-
 (defun mural-open-dwim ()
   (interactive)
-  (let* ((tag (mural-read-tag))
-        (taginfo (assoc tag mural-last-query-result)))
-    (progn
-      (find-file (mural-abspath-for-tag (file-name-directory mural-current-tagfile) taginfo))
-      (goto-line (mural-tag-row taginfo))
-      (setq mural-last-query-result nil)
-      )))
-
-(defun mural-abspath-for-tag (root taginfo)
-  (file-truename (expand-file-name (mural-tag-filename taginfo) root)))
+  (let ((taginfo (mural-read-tag (buffer-file-name))))
+    (find-file (mural-tag-filename taginfo))
+    (goto-line (mural-tag-row taginfo))))
 
 (defvar ido-dynamic-last-query nil)
 

            until (mural-response-complete mural-server-output)
            do (accept-process-output proc .05))
      (if (mural-response-complete mural-server-output)
          (mural-parse-response mural-server-output)
        (progn
          (message "mural-server timeout")
          '())
        ))))

(defun mural-query-save-tag (query)
  (let ((qresult (mural-query query mural-current-tagfile)))


(defvar ido-dynamic-match-fn nil)
(defvar mural-tagfile-to-process '())

(defun mural-add-tagfile (tagfile)
  (mural-get-server (expand-file-name tagfile)))
