Commits

camlspotter committed c8b99a9

bugfix import from custom

  • Participants
  • Parent commits 5b9272b
  • Branches ocamlspot

Comments (0)

Files changed (1)

File ocamlspot/ocamlspot.el

 ;; Parse ocamlspot region string
 ;; Acceptable forms: all | lxxxcxxxbxxx:lyyycyyybyyy | xxx:yyy
 (defun ocamlspot-convert-region (buffer position)
-  (save-current-buffer
-    (set-buffer buffer)
-    (if (or (string-equal "all" position) (string-equal "-1:-1" position))
-	(list (point-min) (point-max))
-      (if (string-match "^\\(l[\-0-9]+c[\-0-9]+b[\-0-9]+\\|[0-9]+\\):\\(l[\-0-9]+c[\-0-9]+b[\-0-9]+\\|[0-9]+\\)$" position)
-	  (let ((start (match-string 1 position))
-		(end   (match-string 2 position)))
-	    (let ((start (ocamlspot-pos-of-location buffer start))
-		  (end   (ocamlspot-pos-of-location buffer end)))
-	      (list start end)))
-	nil))))
+  (if (not buffer) (error "ocamlspot-convert-region: buffer is nill")
+    (save-current-buffer
+      (set-buffer buffer)
+      (if (or (string-equal "all" position) (string-equal "-1:-1" position))
+	  (list (point-min) (point-max))
+	(if (string-match "^\\(l[\-0-9]+c[\-0-9]+b[\-0-9]+\\|[0-9]+\\):\\(l[\-0-9]+c[\-0-9]+b[\-0-9]+\\|[0-9]+\\)$" position)
+	    (let ((start (match-string 1 position))
+		  (end   (match-string 2 position)))
+	      (let ((start (ocamlspot-pos-of-location buffer start))
+		    (end   (ocamlspot-pos-of-location buffer end)))
+		(list start end)))
+	  nil)))))
 
 (defun ocamlspot-display-overlay (buffer emacs-start-end overlay)
   (if start-end
 (defun ocamlspot-find-file-existing (path)
   (if (file-exists-p path)
       (find-file-other-window path)
-    (ocamlspot-message-add (format "ERROR: source file %s was not found" path))))
+    (ocamlspot-message-add (format "ERROR: source file %s was not found" path))
+    nil))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Queries
 
 	;; search the found tree element
 	(let ((tree (ocamlspot-find-query-result "Tree")))
 	  (if tree 
-	      (let ((start-end (ocamlspot-convert-region source-buffer tree)))
-		(if start-end
-		    (save-current-buffer
-		      (ocamlspot-display-overlay source-buffer start-end ocamlspot-tree-overlay)))
-		(let ((err (ocamlspot-find-query-result "Error")))
-		  (if err
-		      (ocamlspot-message-add (concat "Error: " err))))
-		start-end)
+	      (progn
+		(let ((start-end (ocamlspot-convert-region source-buffer tree)))
+		  (if start-end
+		      (save-current-buffer
+			(ocamlspot-display-overlay source-buffer start-end ocamlspot-tree-overlay)))
+		  (let ((err (ocamlspot-find-query-result "Error")))
+		    (if err
+			(ocamlspot-message-add (concat "Error: " err))))
+		  start-end))
 	    (ocamlspot-message-add "Error: no tree node found there")
 	    nil))))))
 
       ;; It is not an .ml or .mli. Packed module.
       ;; CR jfuruse: opening a binary file is not good
       (ocamlspot-message-add "Packed module: %s" filename)
-    (let ((buffer (ocamlspot-find-file-existing filename))
-	  (start-end (ocamlspot-convert-region buffer position)))
+    (let* ((buffer (ocamlspot-find-file-existing filename))
+	   (start-end (ocamlspot-convert-region buffer position)))
       (if start-end
 	  (ocamlspot-display-overlay start-end buffer ocamlspot-spot-overlay)
 	  (ocamlspot-message-add "Error: strange position")))))
 
 ;; Jump to given path-range.
 (defun ocamlspot-jump-to-path-range (path-range)
-  (if (string-match "^<?\\(.*\\):\\(.*\\)>?$" path-range)
+  (if (string-match "^<?\\(.*\\):\\(all\\|[\-0-9lcb]+:[\-0-9lcb]+.*\\)>?$" path-range)
       (let ((filename (match-string 1 path-range))
 	    (position (match-string 2 path-range)))
-
 	;; preserve current buffer and pos ;; CR jfuruse: history preserving should take occur only when the jump is successful.
 	(setq ocamlspot-jump-stack (cons (list (current-buffer)
 					       (point))