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

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

[elpa] master d3032e2 06/23: company-next-page: Wrap only when at the la


From: Dmitry Gutov
Subject: [elpa] master d3032e2 06/23: company-next-page: Wrap only when at the last item
Date: Fri, 11 Nov 2016 22:21:41 +0000 (UTC)

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

    company-next-page: Wrap only when at the last item
    
    Ditto company-previous-page.
    
    Fixes #533.
---
 NEWS.md    |    3 +++
 company.el |   16 ++++++++++++----
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/NEWS.md b/NEWS.md
index c9aacb0..fe8df0b 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -2,6 +2,9 @@
 
 ## Next
 
+* `company-next-page` and `company-previous-page` adhere to
+  `company-selection-wrap-around` docstring more closely and only wrap around
+  when the selection is at the start of the end of the list.
 * `company-pseudo-tooltip-unless-just-one-frontend-with-delay` handles custom
   frontends derived from `company-preview-frontend` better.
 * `company-idle-delay` is automatically converted to a non-zero value.
diff --git a/company.el b/company.el
index 2b59a2a..70bd5b4 100644
--- a/company.el
+++ b/company.el
@@ -1981,15 +1981,23 @@ With ARG, move by that many elements."
   "Select the candidate one page further."
   (interactive)
   (when (company-manual-begin)
-    (company-set-selection (+ company-selection
-                              company-tooltip-limit))))
+    (if (and company-selection-wrap-around
+             (= company-selection (1- company-candidates-length)))
+        (company-set-selection 0)
+      (let (company-selection-wrap-around)
+        (company-set-selection (+ company-selection
+                                  company-tooltip-limit))))))
 
 (defun company-previous-page ()
   "Select the candidate one page earlier."
   (interactive)
   (when (company-manual-begin)
-    (company-set-selection (- company-selection
-                              company-tooltip-limit))))
+    (if (and company-selection-wrap-around
+             (zerop company-selection))
+        (company-set-selection (1- company-candidates-length))
+      (let (company-selection-wrap-around)
+        (company-set-selection (- company-selection
+                                  company-tooltip-limit))))))
 
 (defvar company-pseudo-tooltip-overlay)
 



reply via email to

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