Commits

camlspotter committed 612a1d5

enhanced ui

  • Participants
  • Parent commits df7da2e
  • Branches ocamlspot

Comments (0)

Files changed (1)

File ocamlspot/ocamlspot.el

      (ocamlspot-find-file-existing filename)
      position ocamlspot-spot-overlay)))
 
+(defun ocamlspot-find-type-in-buffer (&optional to-kill)
+  (set-buffer (get-buffer-create ocamlspot-buffer))
+  (goto-char (point-min))
+  (if (re-search-forward "^Type: \\(.*\\(\n +.*\\)*\\)" nil t)
+      (let ((type (buffer-substring (match-beginning 1) (match-end 1))))
+	(if to-kill (kill-new type))
+	(message "Type: %s" type)
+	type)
+    (progn 
+      (message "no type found here")
+      nil)))
+
+(defun ocamlspot-find-spot-in-buffer ()
+  (set-buffer (get-buffer-create ocamlspot-buffer))
+  (goto-char (point-min))
+  (if (re-search-forward "^Spot: \\(.*\\):\\(l[\-0-9]+c[\-0-9]+b[\-0-9]+:l[\-0-9]+c[\-0-9]+b[\-0-9]+\\|all\\)$" 
+			 nil t)
+      (let ((filename (buffer-substring (match-beginning 1) 
+					(match-end 1)))
+	    (position (buffer-substring (match-beginning 2)
+					(match-end 2))))
+	;; display the result
+	(let ((type (ocamlspot-find-type-in-buffer)))
+	  (ocamlspot-jump-to-spot filename position)
+	  (message "Type: %s" type)))
+    (progn
+      (if (re-search-forward "^Spot: \\(.*\\)" nil t)
+	  (message (buffer-substring (match-beginning 1) (match-end 1)))
+	(if (re-search-forward "^\\(Error: .*\\)" nil t)
+	    (message (buffer-substring (match-beginning 1) (match-end 1)))
+	  (progn
+	    ;; display debug info
+	    (message "No spot found there") 
+	    (ocamlspot-find-type-in-buffer)
+	    ;; (display-buffer ocamlspot-buffer)
+	    ))))))
+
 (defun ocamlspot-query ()
   (interactive)
   (let ((sel-window (selected-window)))
     (if (ocamlspot-gen-query nil)
         (progn ;save-excursion
           ;; search the result
-          (progn 
-            (set-buffer (get-buffer-create ocamlspot-buffer))
-            (goto-char (point-min))
-            (if (re-search-forward "^Spot: \\(.*\\):\\(l[\-0-9]+c[\-0-9]+b[\-0-9]+:l[\-0-9]+c[\-0-9]+b[\-0-9]+\\|all\\)$" 
-                                   nil t)
-                (let ((filename (buffer-substring (match-beginning 1) 
-                                                  (match-end 1)))
-                      (position (buffer-substring (match-beginning 2)
-                                                  (match-end 2))))
-                  ;; display the result
-                  (ocamlspot-jump-to-spot filename position))
-              (progn
-                (if (re-search-forward "^Spot: \\(.*\\)" nil t)
-                    (message (buffer-substring (match-beginning 1) (match-end 1)))
-                  (if (re-search-forward "^\\(Error: .*\\)" nil t)
-                      (message (buffer-substring (match-beginning 1) (match-end 1)))
-                    (progn
-                      ;; display debug info
-                      (message "No spot found there") 
-                      (display-buffer ocamlspot-buffer))))))))
-        )
+          (ocamlspot-find-spot-in-buffer)))
     (ocamlspot-delete-overlays)) ; CR jfuruse: it depends on one's taste
   ; I dunno why but we need the following line to list-buffers work nicely
   (select-window sel-window)))
   (interactive)
   (if (ocamlspot-gen-query '("-n"))
       (save-current-buffer 
-	(set-buffer (get-buffer-create ocamlspot-buffer))
-	(goto-char (point-min))
-	(if (re-search-forward "^Type: \\(.*\\(\n +.*\\)*\\)" nil t)
-	    (let ((type (buffer-substring (match-beginning 1) (match-end 1))))
-              (if to-kill (kill-new type))
-	      (message type))
-	  (message "no type found here"))))
+	(ocamlspot-find-type-in-buffer to-kill)))
   (ocamlspot-delete-overlays))
 
 (defun ocamlspot-type-and-copy ()