;; Don't complete existing candidates, fetch new ones.
(setq company-candidates-cache nil))
(let ((new-prefix (company-call-backend 'prefix)))
- (unless (and (= (- (point) (length new-prefix))
- (- company-point (length company-prefix)))
- (or (equal company-prefix new-prefix)
- (let ((c (company-calculate-candidates new-prefix)))
- ;; t means complete/unique.
- (if (eq c t)
- (progn (company-cancel new-prefix) t)
- (when (consp c)
- (setq company-prefix new-prefix)
- (company-update-candidates c)
- t)))))
- (if (company-auto-complete-p company-point (point))
- (save-excursion
- (goto-char company-point)
- (company-complete-selection)
- (setq company-candidates nil))
- (if (not (and (company-incremental-p company-prefix new-prefix)
- (company-require-match-p)))
- (progn
- (when (equal company-prefix (car company-candidates))
- ;; cancel, but last input was actually success
- (company-cancel company-prefix))
- (setq company-candidates nil))
- (backward-delete-char (length new-prefix))
- (insert company-prefix)
- (ding)
- (message "Matching input is required")))
- company-candidates)))
+ (if (= (- (point) (length new-prefix))
+ (- company-point (length company-prefix)))
+ (unless (or (equal company-prefix new-prefix)
+ (let ((c (company-calculate-candidates new-prefix)))
+ ;; t means complete/unique.
+ (if (eq c t)
+ (progn (company-cancel new-prefix) t)
+ (when (consp c)
+ (setq company-prefix new-prefix)
+ (company-update-candidates c)
+ t))))
+ (if (not (and (company-incremental-p company-prefix new-prefix)
+ (company-require-match-p)))
+ (progn
+ (when (equal company-prefix (car company-candidates))
+ ;; cancel, but last input was actually success
+ (company-cancel company-prefix))
+ (setq company-candidates nil))
+ (backward-delete-char (length new-prefix))
+ (insert company-prefix)
+ (ding)
+ (message "Matching input is required")))
+ (when (company-auto-complete-p company-point (point))
+ (save-excursion
+ (goto-char company-point)
+ (company-complete-selection)))
+ (setq company-candidates nil))
+ company-candidates))
(defun company-begin ()
(when (and (not (and company-candidates (company-continue)))