"If enabled, cancel a manually started completion when the prefix gets
shorter than both `company-minimum-prefix-length' and the length of the
prefix it was started from."
- :group 'company
- :type '(choice (const :tag "Off" nil)
- (const :tag "On" t)))
+ :type 'boolean)
(defcustom company-require-match 'company-explicit-action-p
"If enabled, disallow non-matching input.
(defvar company-selection-changed nil)
(make-variable-buffer-local 'company-selection-changed)
-(defvar company--explicit-action nil
- "Non-nil, if explicit completion took place.")
-(make-variable-buffer-local 'company--explicit-action)
+(defvar company--manual-action nil
+ "Non-nil, if manual completion took place.")
+(make-variable-buffer-local 'company--manual-action)
(defvar company--manual-prefix nil)
(make-variable-buffer-local 'company--manual-prefix)
(defun company-explicit-action-p ()
"Return whether explicit completion action was taken by the user."
- (or company--explicit-action
+ (or company--manual-action
company-selection-changed))
(defun company-reformat (candidate)
(defun company-manual-begin ()
(interactive)
(company-assert-enabled)
- (setq company--explicit-action t)
+ (setq company--manual-action t)
(unwind-protect
(let ((company-minimum-prefix-length 0))
(company-auto-begin))
(unless company-candidates
- (setq company--explicit-action nil))))
+ (setq company--manual-action nil))))
(defun company-other-backend (&optional backward)
(interactive (list current-prefix-arg))
(defun company--good-prefix-p (prefix)
(and (stringp (or (car-safe prefix) prefix)) ;excludes 'stop
- (or (and company--manual-prefix
- ;; changed selection not enough for valid prefix
- (not (and company-abort-manual-when-too-short
- ;; must not be less than minimum or initial length
- (< (or (cdr-safe prefix) (length prefix))
- (min company-minimum-prefix-length
- (length company--manual-prefix))))))
- (or (eq (cdr-safe prefix) t)
- (>= (or (cdr-safe prefix) (length prefix))
- company-minimum-prefix-length)))))
+ (or (eq (cdr-safe prefix) t)
+ (let ((len (or (cdr-safe prefix) (length prefix))))
+ (if company--manual-prefix
+ (or (not company-abort-manual-when-too-short)
+ ;; Must not be less than minimum or initial length.
+ (>= len (min company-minimum-prefix-length
+ (length company--manual-prefix))))
+ (>= len company-minimum-prefix-length))))))
(defun company--continue ()
(when (company-call-backend 'no-cache company-prefix)
c (company-calculate-candidates prefix))
;; t means complete/unique. We don't start, so no hooks.
(if (not (consp c))
- (when company--explicit-action
+ (when company--manual-action
(message "No completion found"))
(setq company-prefix prefix)
- (when company--explicit-action
+ (when company--manual-action
(setq company--manual-prefix prefix))
(when (symbolp backend)
(setq company-lighter (concat " " (symbol-name backend))))
company-common nil
company-selection 0
company-selection-changed nil
- company--explicit-action nil
+ company--manual-action nil
company--manual-prefix nil
company-lighter company-default-lighter
company--point-max nil