fix(emacs/lean-company): repaint background in the candidate only when required

This commit is contained in:
Soonho Kong 2014-09-11 13:38:29 -07:00
parent 389fe02597
commit 0b507777f9

View file

@ -143,13 +143,19 @@ rep. Then, add text-properties on the replaced region."
(replace-regex-return-position regex rep result m-end))))) (replace-regex-return-position regex rep result m-end)))))
result)) result))
(defadvice company-fill-propertize (eval-after-load 'company
'(defadvice company-fill-propertize
(after lean-company-fill-propertize activate) (after lean-company-fill-propertize activate)
(when (eq major-mode 'lean-mode) (when (eq major-mode 'lean-mode)
(let* ((selected (ad-get-arg 3)) (let* ((selected (ad-get-arg 3))
(properties `(face (:foreground ,(face-foreground 'font-lock-keyword-face) (foreground-color (face-foreground 'font-lock-keyword-face))
:background ,(face-background (if selected 'company-tooltip-selection (background-color (if selected (face-background 'company-tooltip-selection)
'company-tooltip))) (face-background 'company-tooltip)))
(face-attrs
(cond (background-color `(:foreground ,foreground-color
:background ,background-color))
(t `(:foreground ,foreground-color))))
(properties `(face ,face-attrs
mouse-face company-tooltip)) mouse-face company-tooltip))
(old-return ad-return-value) (old-return ad-return-value)
(old-len (length old-return)) (old-len (length old-return))
@ -164,7 +170,8 @@ rep. Then, add text-properties on the replaced region."
(while (< (length new-return) old-len) (while (< (length new-return) old-len)
(setq new-return (setq new-return
(concat new-return " "))) (concat new-return " ")))
(add-text-properties new-len old-len properties new-return) (when background-color
(setq ad-return-value new-return)))) (add-text-properties new-len old-len properties new-return))
(setq ad-return-value new-return)))))
(provide 'lean-company) (provide 'lean-company)