branch: externals/company
commit 8eda64605b0dd72308176d247d0b47707f0586cd
Author: Dmitry Gutov <[email protected]>
Commit: Dmitry Gutov <[email protected]>
Plug into tab-always-indent=complete
---
company-capf.el | 3 ++-
company.el | 25 ++++++++++++++++++++++++-
2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/company-capf.el b/company-capf.el
index 8d159608c9..5c7b8486b3 100644
--- a/company-capf.el
+++ b/company-capf.el
@@ -36,7 +36,8 @@
:group 'company)
(defcustom company-capf-disabled-functions '(tags-completion-at-point-function
- ispell-completion-at-point)
+ ispell-completion-at-point
+
company--fake-capf-complete-common)
"List of completion functions which should be ignored in this backend.
By default it contains the functions that duplicate the built-in backends
diff --git a/company.el b/company.el
index 73e8fe9a9d..4f76945173 100644
--- a/company.el
+++ b/company.el
@@ -886,7 +886,11 @@ asynchronous call into synchronous.")
;;; mode
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(defvar company-mode-map (make-sparse-keymap)
+(defvar company-mode-map
+ (let ((keymap (make-sparse-keymap)))
+ (define-key keymap [remap indent-for-tab-command]
'company-indent-for-tab-command)
+ (define-key keymap [remap c-indent-line-or-region]
'company-indent-for-tab-command)
+ keymap)
"Keymap used by `company-mode'.")
(defvar company-active-map
@@ -3531,6 +3535,25 @@ from the candidates list.")
(let ((win (display-buffer doc-buffer t)))
(set-window-start win (if start start (point-min)))))))
+(defun company--fake-capf-complete-common (&rest _)
+ (company-complete-common)
+ (list (point) (point) nil))
+
+(defun company-indent-for-tab-command (&optional arg)
+ "Like `indent-for-tab-command' which see but calls `company-complete-common'
+instead of `completion-at-point' as the fallback. That only happens when
+`tab-always-indent' is `complete', and only when reindentation was a no-op."
+ (interactive)
+ (unwind-protect
+ (progn
+ (add-hook 'completion-at-point-functions
+ #'company--fake-capf-complete-common
+ nil t)
+ (funcall-interactively #'indent-for-tab-command arg))
+ (remove-hook 'completion-at-point-functions
+ #'company--fake-capf-complete-common
+ t)))
+
(defun company-show-doc-buffer (&optional toggle-auto-update)
"Show the documentation buffer for the selection.
With a prefix argument TOGGLE-AUTO-UPDATE, toggle the value of