       (forward-line (1- line))
       (move-to-column col))))
 
-(defun merlin-goto-file-and-point (data &optional same-buffer-force)
-  "Go to the file and position indicated by DATA which is an assoc list containing fields file, line and col.
-If SAME-BUFFER-FORCE is non-nil, create a new window even if it is the same buffer."
-  (if (> (length (cdr (assoc 'file data))) 0)
-      (find-file-other-window (cdr (assoc 'file data)))
-    (when same-buffer-force
-        (find-file-other-window buffer-file-name)))
-  (merlin-goto-point (cdr (assoc 'pos data))))
+(defun merlin-goto-file-and-point (data)
+  "Go to the file and position indicated by DATA which is an assoc list containing fields file, line and col."
+  (let* ((file (assoc 'file data))
+         (open-window (cond ((equal merlin-locate-in-new-window 'never) nil)
+                            ((equal merlin-locate-in-new-window 'always))
+                            (file)))
+         (filename (if file (cdr file) (buffer-file-name)))
+         (focus-window (or (not open-window) merlin-locate-focus-new-window))
+         (do-open (lambda () 
+                    (if open-window
+                      (find-file-other-window filename)
+                      (find-file filename))
+                    (merlin-goto-point (cdr (assoc 'pos data))))))
+    (if focus-window
+      (progn
+        (push (cons (buffer-name) (point)) merlin-position-stack)
+        (funcall do-open)
+        (message "Use %s to go back."
+          (substitute-command-keys "\\[merlin-pop-stack]")))
+      (save-excursion (save-selected-window (funcall do-open))))))
 
 (defun merlin-make-point (data)
   "Transform DATA (a couple line / col) into a point."

(defun merlin-type-expression (exp callback-if-success &optional callback-if-exn)
  "Get the type of EXP inside the local context."
  (if exp (merlin-send-command-async
           (list 'type 'expression exp 'at (merlin-unmake-point (point)))
           callback-if-success callback-if-exn)))

(defun merlin-type-display (bounds type &optional quiet)


(defun merlin-buffer-substring (start end)
   "Return content of buffer between two-point or empty string if points are not valid"
   (if (< start end) (buffer-substring-no-properties start end) ""))

(defun merlin-drop ()
  "Drop the knowledge of merlin of the buffer after the current position."
