emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 35f4178 043/173: Allow including window-start in the doc-b


From: Dmitry Gutov
Subject: [elpa] master 35f4178 043/173: Allow including window-start in the doc-buffer return value
Date: Thu, 23 Jun 2016 00:28:36 +0000 (UTC)

branch: master
commit 35f4178f43317ae6e94525656a7382f066171872
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>

    Allow including window-start in the doc-buffer return value
    
    Closes #357
---
 NEWS.md    |    2 ++
 company.el |   17 +++++++++++------
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/NEWS.md b/NEWS.md
index 012d0bc..319e959 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -2,6 +2,8 @@
 
 ## Next
 
+* Backend command `doc-buffer` now can also return a cons of buffer and window
+  start position.
 * Backend command `ignore-case` has been documented.
 * `company-template-c-like-templatify` does not replace the default argument
   values with `argN` anymore
diff --git a/company.el b/company.el
index af5c040..1481914 100644
--- a/company.el
+++ b/company.el
@@ -375,9 +375,11 @@ them from cache.
 documentation string for it.
 
 `doc-buffer': The second argument is a completion candidate.  Return a
-buffer with documentation for it.  Preferably use `company-doc-buffer',
+buffer with documentation for it.  Preferably use `company-doc-buffer'.  If
+not all buffer contents pertain to this candidate, return a cons of buffer
+and window start position.
 
-`location': The second argument is a completion candidate.  Return the cons
+`location': The second argument is a completion candidate.  Return a cons
 of buffer and buffer location, or of file and line number where the
 completion candidate was defined.
 
@@ -2066,11 +2068,14 @@ character, stripping the modifiers.  That character 
must be a digit."
     (company--electric-do
       (let* ((selected (nth company-selection company-candidates))
              (doc-buffer (or (company-call-backend 'doc-buffer selected)
-                             (error "No documentation available"))))
+                             (error "No documentation available")))
+             start)
+        (when (consp doc-buffer)
+          (setq start (cdr doc-buffer)
+                doc-buffer (car doc-buffer)))
         (setq other-window-scroll-buffer (get-buffer doc-buffer))
-        (with-current-buffer doc-buffer
-          (goto-char (point-min)))
-        (display-buffer doc-buffer t)))))
+        (let ((win (display-buffer doc-buffer t)))
+          (set-window-start win (if start start (point-min))))))))
 (put 'company-show-doc-buffer 'company-keep t)
 
 (defun company-show-location ()



reply via email to

[Prev in Thread] Current Thread [Next in Thread]