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

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

[elpa] master d39b956 059/173: Introduce company-indent-or-complete-comm


From: Dmitry Gutov
Subject: [elpa] master d39b956 059/173: Introduce company-indent-or-complete-common
Date: Thu, 23 Jun 2016 00:28:38 +0000 (UTC)

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

    Introduce company-indent-or-complete-common
    
    As requested in https://github.com/clojure-emacs/cider/pull/1185/
---
 NEWS.md    |    1 +
 company.el |   14 ++++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/NEWS.md b/NEWS.md
index 319e959..b452544 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -2,6 +2,7 @@
 
 ## Next
 
+* New command `company-indent-or-complete-common`.
 * Backend command `doc-buffer` now can also return a cons of buffer and window
   start position.
 * Backend command `ignore-case` has been documented.
diff --git a/company.el b/company.el
index 5c00dbb..169882e 100644
--- a/company.el
+++ b/company.el
@@ -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



reply via email to

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