branch: master commit ec1e879b4e662ead5699c153e28dc2573169259d Author: Nikita Leshenko <nik...@leshenko.net> Commit: Nikita Leshenko <nik...@leshenko.net>
company-tng: Don't highlight tooltip when unselected This is a visual adjustment to avoid highlighting the first candidate when it wasn't made explicitly. This is an advice and not an internal configuration variable because we would like to keep company-tng a separate package for it's unusual semantics. --- company-tng.el | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/company-tng.el b/company-tng.el index fbb8aa6..f01462c 100644 --- a/company-tng.el +++ b/company-tng.el @@ -54,7 +54,8 @@ confirm the selection and finish the completion." (let ((ov (make-overlay (point) (point)))) (setq company-tng--overlay ov) (overlay-put ov 'priority 2)) - (advice-add 'company-select-next :before-until 'company-tng--allow-unselected)) + (advice-add 'company-select-next :before-until 'company-tng--allow-unselected) + (advice-add 'company-fill-propertize :filter-args 'company-tng--adjust-tooltip-highlight)) (update (let ((ov company-tng--overlay) (selected (nth company-selection company-candidates)) @@ -64,7 +65,8 @@ confirm the selection and finish the completion." (hide (when company-tng--overlay (delete-overlay company-tng--overlay)) - (advice-remove 'company-select-next 'company-tng--allow-unselected)) + (advice-remove 'company-select-next 'company-tng--allow-unselected) + (advice-remove 'company-fill-propertize 'company-tng--adjust-tooltip-highlight)) (pre-command (when (and company-selection-changed (not (company--company-command-p (this-command-keys)))) @@ -103,5 +105,13 @@ There is no need to advice `company-select-previous' because it calls t) ))) +(defun company-tng--adjust-tooltip-highlight (args) + "Prevent the tooltip from highlighting the current selection if it wasn't +made explicitly (i.e. `company-selection-changed' is true)" + (unless company-selection-changed + ;; The 4th arg of `company-fill-propertize' is selected + (setf (nth 3 args) nil)) + args) + (provide 'company-tng) ;;; company-tng.el ends here