]> code.delx.au - gnu-emacs-elpa/commitdiff
Add company-complete-common-or-cycle
authorDmitry Gutov <dgutov@yandex.ru>
Fri, 9 Jan 2015 12:51:51 +0000 (15:51 +0300)
committerDmitry Gutov <dgutov@yandex.ru>
Fri, 9 Jan 2015 12:51:51 +0000 (15:51 +0300)
NEWS.md
company.el

diff --git a/NEWS.md b/NEWS.md
index b615f481e8b48a90e1a666bdd65cc70d394f0640..9d3c1037b43c2991c42ec7e60b7918174d0bece1 100644 (file)
--- a/NEWS.md
+++ b/NEWS.md
@@ -2,6 +2,8 @@
 
 ## Next
 
+* New command `company-complete-common-or-cycle`. No default binding, so one
+  would have to set it up to use it.
 * `company-search-toggle-filtering` replaced `company-search-kill-others`.
 * Quitting the search mode resets the filtering.
 * Pressing `backspace` in the search mode deletes the character at the end of
index 217f37bb36bf8b9c8554e91f2682e1b700103080..a92f8373191270f7e5e42c692cc5935eaacecc92 100644 (file)
@@ -1870,6 +1870,16 @@ and invoke the normal binding."
       (when company-common
         (company--insert-candidate company-common)))))
 
+(defun company-complete-common-or-cycle ()
+  "Insert the common part of all candidates, or select the next one."
+  (interactive)
+  (when (company-manual-begin)
+    (let ((tick (buffer-chars-modified-tick)))
+      (call-interactively 'company-complete-common)
+      (when (eq tick (buffer-chars-modified-tick))
+        (let ((company-selection-wrap-around t))
+          (call-interactively 'company-select-next))))))
+
 (defun company-complete ()
   "Insert the common part of all candidates or the current selection.
 The first time this is called, the common part is inserted, the second