]> code.delx.au - gnu-emacs-elpa/blobdiff - company.el
Introduce company-indent-or-complete-common
[gnu-emacs-elpa] / company.el
index 5c00dbbbf36708bc27e3ea4c83fef3e6d06736d4..169882e8743c40207c5721ac3912c2cde7f79cc4 100644 (file)
@@ -1955,6 +1955,20 @@ With ARG, move by that many elements."
               (current-prefix-arg arg))
           (call-interactively 'company-select-next))))))
 
+(defun company-indent-or-complete-common ()
+  "Indent the current line or region, or complete the common part."
+  (interactive)
+  (cond
+   ((use-region-p)
+    (indent-region (region-beginning) (region-end)))
+   ((let ((old-point (point))
+          (old-tick (buffer-chars-modified-tick))
+          (tab-always-indent t))
+      (call-interactively #'indent-for-tab-command)
+      (when (and (eq old-point (point))
+                 (eq old-tick (buffer-chars-modified-tick)))
+        (company-complete-common))))))
+
 (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