From 220341a083d1fd5c29d9e1d7712823d5abdbfe6a Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Thu, 20 Dec 2018 15:52:33 +0000 Subject: [PATCH] Fix company-mode / fci-mode incompatibility bug The original code to fix the incompatibility didn't see to work anymore, so refactored it a bit to so it goes about things a bit more carefully, and that seemed to fix it. --- modules/completion/siren-company.el | 31 ++++++++++++++++------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/modules/completion/siren-company.el b/modules/completion/siren-company.el index 0689744..d5da35c 100644 --- a/modules/completion/siren-company.el +++ b/modules/completion/siren-company.el @@ -6,25 +6,28 @@ ;;; Code: -(require 'siren-fci) +;; (require 'siren-fci) (use-package company - :init - (defun company-turn-off-fci (&rest ignore) - (when (boundp 'fci-mode) - (setq company-fci-mode-on-p fci-mode) - (when fci-mode (fci-mode -1)))) + :hook + (company-completion-started . siren-company--turn-off-fci) + (company-completion-finished . siren-company--maybe-turn-on-fci) + (company-completion-cancelled . siren-company--maybe-turn-on-fci) - (defun company-maybe-turn-on-fci (&rest ignore) - (when company-fci-mode-on-p (fci-mode 1))) + :init + (defun siren-company--turn-off-fci (&rest ignore) + (when (boundp 'fci-mode) + (when fci-mode + (turn-off-fci-mode) + (setq siren-company--fci-mode-on-p t)))) + + (defun siren-company--maybe-turn-on-fci (&rest ignore) + (when siren-company--fci-mode-on-p + (turn-on-fci-mode) + (setq siren-company--fci-mode-on-p nil))) :config - ;; work-around for issues with fci-mode - (defvar-local company-fci-mode-on-p nil) - - (add-hook 'company-completion-started-hook 'company-turn-off-fci) - (add-hook 'company-completion-finished-hook 'company-maybe-turn-on-fci) - (add-hook 'company-completion-cancelled-hook 'company-maybe-turn-on-fci) + (defvar-local siren-company--fci-mode-on-p nil) (setq company-begin-commands '(self-insert-command) company-dabbrev-downcase nil