]> code.delx.au - gnu-emacs-elpa/blobdiff - company.el
Bumped version to 0.3.
[gnu-emacs-elpa] / company.el
index 086c021c749c25080b7ca33fa031be8f1306acb5..c064b3d83595d6add60360d624344f4c3a895674 100644 (file)
@@ -3,7 +3,7 @@
 ;; Copyright (C) 2009 Nikolaj Schumacher
 ;;
 ;; Author: Nikolaj Schumacher <bugs * nschum de>
-;; Version: 0.2.1
+;; Version: 0.3
 ;; Keywords: abbrev, convenience, matchis
 ;; URL: http://nschum.de/src/emacs/company/
 ;; Compatibility: GNU Emacs 22.x, GNU Emacs 23.x
@@ -69,6 +69,8 @@
 ;;
 ;;; Change Log:
 ;;
+;; 2009-04-12 (0.3)
+;;    Added `company-begin-commands' option.
 ;;    Added abbrev, tempo and Xcode back-ends.
 ;;    Back-ends are now interactive.  You can start them with M-x backend-name.
 ;;    Added `company-begin-with' for starting company from elisp-code.
@@ -369,6 +371,17 @@ immediately when a prefix of `company-minimum-prefix-length' is reached."
                  (const :tag "immediate (t)" t)
                  (number :tag "seconds")))
 
+(defcustom company-begin-commands t
+  "*A list of commands following which company will start completing.
+If this is t, it will complete after any command.  See `company-idle-delay'.
+
+Alternatively any command with a non-nil 'company-begin property is treated as
+if it was on this list."
+  :group 'company
+  :type '(choice (const :tag "Any command" t)
+                 (const :tag "Self insert command" '(self-insert-command))
+                 (repeat :tag "Commands" function)))
+
 (defcustom company-show-numbers nil
   "*If enabled, show quick-access numbers for the first ten candidates."
   :group 'company
@@ -563,6 +576,9 @@ keymap during active completions (`company-active-map'):
 
 (defsubst company-should-complete (prefix)
   (and (eq company-idle-delay t)
+       (or (eq t company-begin-commands)
+           (memq this-command company-begin-commands)
+           (and (symbolp this-command) (get this-command 'company-begin)))
        (not (and transient-mark-mode mark-active))
        (>= (length prefix) company-minimum-prefix-length)))
 
@@ -657,7 +673,8 @@ keymap during active completions (`company-active-map'):
   (and company-mode
        (not company-candidates)
        (let ((company-idle-delay t)
-             (company-minimum-prefix-length 0))
+             (company-minimum-prefix-length 0)
+             (company-begin-commands t))
          (setq company--explicit-action t)
          (company-begin)))
   ;; Return non-nil if active.
@@ -1064,8 +1081,8 @@ followed by `company-search-kill-others' after each input."
   "Complete the common part of all candidates."
   (interactive)
   (when (company-manual-begin)
-    (if (equal company-common (car company-candidates))
-        ;; for success message
+    (if (and (not (cdr company-candidates))
+             (equal company-common (car company-candidates)))
         (company-complete-selection)
       (insert (company-strip-prefix company-common)))))