Commits

camlspotter  committed f7e5fce

imported the diff from custom: added ocamlspot-pop-jump-stack

  • Participants
  • Parent commits 41fa54a
  • Branches ocamlspot

Comments (0)

Files changed (2)

File ocamlspot/Changes

+1.3.1
+--------------
+
+- (ocamlspot-pop-jump-stack) is added to recover query points.
+
 1.3.0
 --------------
 

File ocamlspot/ocamlspot.el

 
 ;;; Search ocamlspot-process-buffer and return the first line which matches with ^<pattern>: "
 (defun ocamlspot-find-query-result (pattern &optional to-kill)
-  (set-buffer (get-buffer-create ocamlspot-process-buffer))
-  (goto-char (point-min))
-  (if (re-search-forward (concat "^" pattern ": \\(.*\\(\n +.*\\)*\\)") nil t)
-      (let ((the-match (match-string 1)))
-        (if to-kill (kill-new the-match))
-        the-match)))
+  (save-current-buffer
+    (set-buffer (get-buffer-create ocamlspot-process-buffer))
+    (goto-char (point-min))
+    (if (re-search-forward (concat "^" pattern ": \\(.*\\(\n +.*\\)*\\)") nil t)
+	(let ((the-match (match-string 1)))
+	  (if to-kill (kill-new the-match))
+	  the-match))))
 
 ;; Scan the ocamlspot process output and search Tree.
 ;; If there is a Tree result, highlight it and returns t
      (ocamlspot-find-file-existing filename)
      position ocamlspot-spot-overlay)))
 
+(setq ocamlspot-jump-stack nil)
+
+(defun ocamlspot-pop-jump-stack ()
+  (interactive)
+  (if ocamlspot-jump-stack
+      (progn
+	(destructuring-bind (buffer pos) (car ocamlspot-jump-stack)
+	  (setq ocamlspot-jump-stack (cdr ocamlspot-jump-stack))
+	  (if (buffer-live-p buffer)
+	      (progn
+		(display-buffer buffer)
+		(switch-to-buffer buffer)
+		(goto-char pos))
+	    (ocamlspot-pop-jump-stack))))
+    (message "OCamlSpot jump stack is empty")))
+
 (defun ocamlspot-jump-to-path-range (path-range)
   (if (string-match "^<?\\(.*\\):\\(l[\-0-9]+c[\-0-9]+b[\-0-9]+:l[\-0-9]+c[\-0-9]+b[\-0-9]+\\|[0-9]+:[0-9]+\\|all\\|-1:-1\\)>?$" path-range)
       (let ((filename (match-string 1 path-range))
 	    (position (match-string 2 path-range)))
+
+	;; preserve current buffer and pos
+	(if backto 
+	    (setq ocamlspot-jump-stack (cons backto ocamlspot-jump-stack)))
+
 	;; display the result
 	(ocamlspot-jump-to-spot filename position)
 	(let ((type (ocamlspot-find-val-or-type)))