(buffer-substring (nth 1 res) (nth 2 res))
(nth 3 res) (plist-get (nthcdr 4 res) :predicate))))
(cdr (assq 'display-sort-function meta))))))
+ (`common-part
+ ;; Can't just use 0 when base-size (see above) is non-zero.
+ (let ((start (if (get-text-property 0 'face arg)
+ 0
+ (next-single-property-change 0 'face arg))))
+ (when start
+ ;; completions-common-part comes first, but we can't just look for this
+ ;; value because it can be in a list.
+ (or
+ (let ((value (get-text-property start 'face arg)))
+ (text-property-not-all start (length arg)
+ 'face value arg))
+ (length arg)))))
(`duplicates nil) ;Don't bother.
(`no-cache t) ;FIXME: Improve!
(`meta
(pop copy))
(apply 'concat pieces)))
+(defun company--highlight-common (line properties)
+ ;; XXX: Subject to change.
+ (let ((common (or (company-call-backend 'common-part line)
+ (length company-common))))
+ (add-text-properties 0 common properties line)))
+
(defun company-fill-propertize (line width selected)
- (setq line (company-safe-substring line 0 width))
- (add-text-properties 0 width '(face company-tooltip
- mouse-face company-tooltip-mouse)
- line)
- (add-text-properties 0 (length company-common)
- '(face company-tooltip-common
- mouse-face company-tooltip-mouse)
- line)
- (when selected
- (if (and company-search-string
- (string-match (regexp-quote company-search-string) line
- (length company-prefix)))
- (progn
- (add-text-properties (match-beginning 0) (match-end 0)
- '(face company-tooltip-selection)
- line)
- (when (< (match-beginning 0) (length company-common))
- (add-text-properties (match-beginning 0) (length company-common)
- '(face company-tooltip-common-selection)
- line)))
- (add-text-properties 0 width '(face company-tooltip-selection
- mouse-face company-tooltip-selection)
- line)
- (add-text-properties 0 (length company-common)
- '(face company-tooltip-common-selection
- mouse-face company-tooltip-selection)
- line)))
+ (let ((common (or (company-call-backend 'common-part line)
+ (length company-common))))
+ (setq line (company-safe-substring line 0 width))
+ (add-text-properties 0 width '(face company-tooltip
+ mouse-face company-tooltip-mouse)
+ line)
+ (add-text-properties 0 common '(face company-tooltip-common
+ mouse-face company-tooltip-mouse)
+ line)
+ (when selected
+ (if (and company-search-string
+ (string-match (regexp-quote company-search-string) line
+ (length company-prefix)))
+ (progn
+ (add-text-properties (match-beginning 0) (match-end 0)
+ '(face company-tooltip-selection)
+ line)
+ (when (< (match-beginning 0) common)
+ (add-text-properties (match-beginning 0) common
+ '(face company-tooltip-common-selection)
+ line)))
+ (add-text-properties 0 width '(face company-tooltip-selection
+ mouse-face company-tooltip-selection)
+ line)
+ (add-text-properties 0 common '(face company-tooltip-common-selection
+ mouse-face company-tooltip-selection)
+ line))))
line)
;;; replace