]> code.delx.au - gnu-emacs-elpa/commitdiff
Recenter window when showing documentation buffer.
authorNikolaj Schumacher <git@nschum.de>
Mon, 16 Mar 2009 15:29:54 +0000 (16:29 +0100)
committerNikolaj Schumacher <git@nschum.de>
Fri, 20 Mar 2009 11:50:10 +0000 (12:50 +0100)
company.el

index 98b9dcd3ea24225e2f5e7f640218dddda2fb1236..56a57206cd5bf27331773dc4544ec3e258077444 100644 (file)
   (interactive)
   (when company-candidates
     (save-window-excursion
-      (let* ((selected (nth company-selection company-candidates))
+      (let* ((height (window-height))
+             (row (cdr (posn-col-row (posn-at-point))))
+             (selected (nth company-selection company-candidates))
              (buffer (funcall company-backend 'doc-buffer selected)))
         (if (not buffer)
             (error "No documentation available.")
           (display-buffer buffer)
+          (and (< (window-height) height)
+               (< (- (window-height) row 2) company-tooltip-limit)
+               (recenter (- (window-height) row 2)))
           (read-event)
           (when last-input-event
             (clear-this-command-keys t)