## Next
+* `company-eclim` and `company-clang` only expand the template on explicit user
+ action (such as `company-complete-{selection,number,mouse}`).
* `company-template` has some breaking changes. When point is at one of the
fields, it's displayed at the beginning, not right after it; `<tab>` jumps to
the next field, `forward-word` and `subword-forward` remappings are removed;
when you jump to the next field, if the current one hasn't been edited, the
overlay gets removed but the text remains.
-* `company-eclim` shows method overloads and inserts templates for calls.
-* `company-clang` ObjC arguments template insertion now requires explicit user action.
+* `company-eclim` shows method overloads and expands templates for calls.
* `company-clang-objc-templatify` does not insert spaces after colons anymore.
* `company-clang` is now only initialized in supported buffers.
So, no error messages if you don't have Clang until you open a C file.
"#]" " "
(replace-regexp-in-string "[<{[]#\\|#[>}]" "" meta t)
t))))
- (common (and (derived-mode-p 'objc-mode)
- (string-match ":" arg)
- (substring arg 0 (match-beginning 0))))
+ (safe (and (derived-mode-p 'objc-mode)
+ (string-match ":" arg)
+ (substring arg 0 (match-beginning 0))))
(post-completion (and (derived-mode-p 'objc-mode)
(string-match ":" arg)
(company-clang-objc-templatify arg)))))
(meta (company-eclim--meta arg))
;; because "" doesn't return everything
(no-cache (equal arg ""))
- (common (when (string-match "(" arg)
- (substring arg 0 (match-beginning 0))))
+ (safe (when (string-match "(" arg)
+ (substring arg 0 (match-beginning 0))))
(post-completion (when (string-match "([^)]" arg)
(company-eclim--templatify arg)))))
"Non-nil, if explicit completion took place.")
(make-variable-buffer-local 'company--explicit-action)
+(defvar company--auto-completion nil
+ "Non-nil when current candidate is being completed automatically.
+Controlled by `company-auto-complete'.")
+
(defvar company--point-max nil)
(make-variable-buffer-local 'company--point-max)
(push (cons company-prefix company-candidates) company-candidates-cache)
;; Calculate common.
(let ((completion-ignore-case (company-call-backend 'ignore-case)))
- (let ((common (try-completion company-prefix company-candidates)))
- (setq company-common (or (company-call-backend 'common common)
- common))))
+ (setq company-common (company--safe-candidate
+ (try-completion company-prefix company-candidates))))
(when (eq company-common t)
(setq company-candidates nil)))
+(defun company--safe-candidate (str)
+ (or (company-call-backend 'safe str)
+ str))
+
(defun company-calculate-candidates (prefix)
(let ((candidates (cdr (assoc prefix company-candidates-cache)))
(ignore-case (company-call-backend 'ignore-case)))
;; auto-complete
(save-excursion
(goto-char company-point)
- (company-complete-selection)
+ (let ((company--auto-completion t))
+ (company-complete-selection))
nil))
((and (company--string-incremental-p company-prefix new-prefix)
(company-require-match-p))
"Complete the selected candidate."
(interactive)
(when (company-manual-begin)
- (company-finish (nth company-selection company-candidates))))
+ (let ((result (nth company-selection company-candidates)))
+ (when company--auto-completion
+ (setq result (company--safe-candidate result)))
+ (company-finish result))))
(defun company-complete-common ()
"Complete the common part of all candidates."