+(defun company--search-chunks ()
+ (let ((md (match-data t))
+ res)
+ (if (<= (length md) 2)
+ (push (cons (nth 0 md) (nth 1 md)) res)
+ (while (setq md (nthcdr 2 md))
+ (when (car md)
+ (push (cons (car md) (cadr md)) res))))
+ res))
+
+(defun company--apply-company-face (str)
+ (let ((start (if (get-text-property 0 'company-face str)
+ 0
+ (next-single-property-change 0 'company-face str)))
+ end value)
+ (while start
+ (setq end (or (next-single-property-change start 'company-face str)
+ (length str)))
+ (setq value (get-text-property start 'company-face str))
+ (font-lock-prepend-text-property start end 'face value str)
+ (font-lock-prepend-text-property start end 'mouse-face value str)
+ (setq start (next-single-property-change end 'company-face str)))
+ (when end
+ (remove-text-properties 0 end '(company-face) str))))
+