## Next
+* `company-backends`: `prefix` command can return `t` in the cdr.
+* `company-clang-begin-after-member-access`: New option.
* Mouse click outside the tooltip aborts completion.
* `company-clang` uses standard input to pass the contents of current buffer to
Clang 2.9+, otherwise saves the buffer and passes the path to the file.
"Location of clang executable."
:type 'file)
+(defcustom company-clang-begin-after-member-access t
+ "When non-nil, automatic completion will start whenever the current symbol
+is preceded by \".\" or \"->\", ignoring `company-minimum-prefix-length'.
+
+If `company-begin-commands' is a list, it should include `c-electric-lt-gt'.")
+
(defcustom company-clang-arguments nil
"Additional arguments to pass to clang when completing.
Prefix files (-include ...) can be selected with
prefix
(company-clang--build-complete-args (- (point) (length prefix)))))
+(defun company-clang--prefix ()
+ (let ((symbol (company-grab-symbol)))
+ (if symbol
+ (if (and company-clang-begin-after-member-access
+ (save-excursion
+ (forward-char (- (length symbol)))
+ (looking-back "\\.\\|->" (- (point) 3))))
+ (cons symbol t)
+ symbol)
+ 'stop)))
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defconst company-clang-required-version 1.1)
buffer-file-name
company-clang-executable
(not (company-in-string-or-comment))
- (or (company-grab-symbol) 'stop)))
+ (company-clang--prefix)))
(candidates (company-clang--candidates arg))
(meta (gethash arg company-clang--meta-cache))
(crop (and (string-match ":\\|(" arg)
The first argument is the command requested from the back-end. It is one
of the following:
-`prefix': The back-end should return the text to be completed. It must be
-text immediately before `point'. Returning nil passes control to the next
-back-end. The function should return 'stop if it should complete but cannot
-\(e.g. if it is in the middle of a string\). If the returned value is only
-part of the prefix (e.g. the part after \"->\" in C), the back-end may return a
-cons of prefix and prefix length, which is then used in the
-`company-minimum-prefix-length' test.
+`prefix': The back-end should return the text to be completed. It must be text
+immediately before `point'. Returning nil passes control to the next back-end.
+The function should return 'stop if it should complete but cannot \(e.g. if it
+is in the middle of a string\). Instead of a string, the back-end may return a
+cons where car is the prefix and cdr is used in `company-minimum-prefix-length'
+test. It's either number or t, in which case the test automatically succeeds.
`candidates': The second argument is the prefix to be completed. The
return value should be a list of candidates that start with the prefix.
(defun company--good-prefix-p (prefix)
(and (or (company-explicit-action-p)
(unless (eq prefix 'stop)
- (>= (or (cdr-safe prefix) (length prefix))
- company-minimum-prefix-length)))
+ (or (eq (cdr-safe prefix) t)
+ (>= (or (cdr-safe prefix) (length prefix))
+ company-minimum-prefix-length))))
(stringp (or (car-safe prefix) prefix))))
(defun company--continue ()