 ;; Help function. 
 
 
-(defun ocaml-goto-help (&optional module entry)
+(defun ocaml-goto-help (&optional module entry same-window)
   "Searches info manual for MODULE and ENTRY in MODULE.
 If unspecified, MODULE and ENTRY are inferred from the position in the
 current buffer using \\[ocaml-qualified-identifier]."

(defun ocaml-link-goto (click)
  (interactive "e")
  (let* ((pos (caml-event-point-start click))
         (buf (window-buffer (caml-event-window click)))
         (window (selected-window))
         (link))
    (setq link
          (with-current-buffer buf
           (buffer-substring (previous-property-change
                              pos buf (- pos 100))
                             (next-property-change
                              pos buf (+ pos 100)))))
    (if (string-match (concat "^" ocaml-longident-regexp "$") link)
        (ocaml-goto-help (match-string 1 link) (match-string 2 link))
      (if (not (equal (window-buffer window) buf))
          (switch-to-buffer-other-window buf))
      (if (setq link (assoc link (cdr ocaml-links)))

             (location (cdr (cadr module-info))))
        (cond
         (location
          (let ((file (concat location (ocaml-uncapitalize module) ".mli")))
            (if (window-live-p same-window)
                (progn (select-window same-window)
                       (view-mode-exit view-return-to-alist view-exit-action))
              ;; (view-buffer (find-file-noselect file) 'view))
              )
            (view-file-other-window file)
            (bury-buffer (current-buffer))))
         (info-section (error "Aborted"))
         (t (error "No help for module %s" module))))
      )
