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

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

[elpa] externals/company 7c5b5a9a91 1/4: Use company-complete-common-or-


From: ELPA Syncer
Subject: [elpa] externals/company 7c5b5a9a91 1/4: Use company-complete-common-or-cycle in the default bindings
Date: Tue, 5 Nov 2024 21:57:38 -0500 (EST)

branch: externals/company
commit 7c5b5a9a914a1d8a01666b569b4838c1677aa6c9
Author: Dmitry Gutov <dmitry@gutov.dev>
Commit: Dmitry Gutov <dmitry@gutov.dev>

    Use company-complete-common-or-cycle in the default bindings
---
 NEWS.md          |  4 +++-
 company.el       | 10 ++++++++--
 doc/company.texi | 19 ++++---------------
 3 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/NEWS.md b/NEWS.md
index e19eebbb5d..84a95426e1 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -2,13 +2,15 @@
 
 # Next
 
+* `TAB` binding changed to `company-complete-common-or-cycle`, and `backtab`
+  binding changed to `company-cycle-backward
+  (#[1499](https://github.com/company-mode/company-mode/pull/1499)).
 * Completion is restarted if it enters a new "field" at the end, as indicated 
by
   the `adjust-boundaries` backend action
   (#[1497](https://github.com/company-mode/company-mode/pull/1497)). This
   benefits file name (and directory) completion.  The user option
   `company-files-chop-trailing-slash` has been removed, and the
   `post-completion` handler in `company-files` has been removed as well.
-
 * Handle the case when the current c-a-p-f function changes mid-session
   (#[1494](https://github.com/company-mode/company-mode/pull/1494)).
 
diff --git a/company.el b/company.el
index 3023da6068..569320236d 100644
--- a/company.el
+++ b/company.el
@@ -903,8 +903,9 @@ asynchronous call into synchronous.")
     (define-key keymap [up-mouse-3] 'ignore)
     (define-key keymap [return] 'company-complete-selection)
     (define-key keymap (kbd "RET") 'company-complete-selection)
-    (define-key keymap [tab] 'company-complete-common)
-    (define-key keymap (kbd "TAB") 'company-complete-common)
+    (define-key keymap [tab] 'company-complete-common-or-cycle)
+    (define-key keymap (kbd "TAB") 'company-complete-common-or-cycle)
+    (define-key keymap [backtab] 'company-cycle-backward)
     (define-key keymap (kbd "<f1>") 'company-show-doc-buffer)
     (define-key keymap (kbd "C-h") 'company-show-doc-buffer)
     (define-key keymap "\C-w" 'company-show-location)
@@ -3172,6 +3173,11 @@ With ARG, move by that many elements."
               (current-prefix-arg arg))
           (call-interactively 'company-select-next))))))
 
+(defun company-cycle-backward (&optional arg)
+  (interactive "p")
+  (let ((company-selection-wrap-around t))
+    (company-select-previous arg)))
+
 (defun company-complete-common-or-show-delayed-tooltip ()
   "Insert the common part of all candidates, or show a tooltip."
   (interactive)
diff --git a/doc/company.texi b/doc/company.texi
index 9b9eb02397..ca9ed5c327 100644
--- a/doc/company.texi
+++ b/doc/company.texi
@@ -338,9 +338,10 @@ Restart completion if a new field is entered.
 @itemx <tab>
 @kindex TAB
 @cindex common part
-@findex company-complete-common
-Insert the @emph{common part} of all completion candidates
-(@code{company-complete-common}).
+@findex company-complete-common-or-cycle
+Insert the @emph{common part} of all completion candidates or if it
+cannot be completed further, select the next candidate (with
+wraparound enabled) (@code{company-complete-common-or-cycle}).
 
 @item C-g
 @itemx <ESC ESC ESC>
@@ -393,18 +394,6 @@ illustrate how to assign key bindings to such commands.
   (define-key company-active-map (kbd "M-/") #'company-complete))
 @end lisp
 
-@lisp
-(with-eval-after-load 'company
-  (define-key company-active-map
-              (kbd "TAB")
-              #'company-complete-common-or-cycle)
-  (define-key company-active-map
-              (kbd "<backtab>")
-              (lambda ()
-                (interactive)
-                (company-complete-common-or-cycle -1))))
-@end lisp
-
 In the same manner, an additional key can be assigned to a command or
 a command can be unbound from a key.  For instance:
 



reply via email to

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