From e84e5e1cdc6beb304569c45109dfd71558d43924 Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Thu, 6 May 2021 05:39:07 +0200 Subject: [PATCH] Revert "Improve corfu mode setup if Emacs daemon is used (Fix #20)" This reverts commit 3ec66c521f42c9e5aa3e406bf32b7bc112bb1dc0. --- corfu.el | 43 +++++++++++++++++-------------------------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/corfu.el b/corfu.el index 6ddacc4..392877a 100644 --- a/corfu.el +++ b/corfu.el @@ -688,38 +688,29 @@ Set to nil in order to disable confirmation." (defun corfu--completion-in-region (&rest args) "Corfu completion in region function passing ARGS to `completion--in-region'." - (if (corfu--ensure-display-graphic) - (let ((completion-show-inline-help) - (completion-auto-help) - ;; XXX Disable original predicate check, keep completion alive when - ;; popup is shown. Since the predicate is set always, it is ensured - ;; that `completion-in-region-mode' is turned on. - (completion-in-region-mode-predicate (lambda () t))) - ;; Prevent restarting the completion. This can happen for example if C-M-/ - ;; (`dabbrev-completion') is pressed while the Corfu popup is already open. - (when (and completion-in-region-mode (not completion-cycling)) - (user-error "Completion is already in progress")) - (apply #'completion--in-region args)) + ;; Prevent restarting the completion. This can happen for example if C-M-/ + ;; (`dabbrev-completion') is pressed while the Corfu popup is already open. + (when (and completion-in-region-mode (not completion-cycling)) + (user-error "Completion is already in progress")) + (let ((completion-show-inline-help) + (completion-auto-help) + ;; XXX Disable original predicate check, keep completion alive when + ;; popup is shown. Since the predicate is set always, it is ensured + ;; that `completion-in-region-mode' is turned on. + (completion-in-region-mode-predicate (lambda () t))) (apply #'completion--in-region args))) -(defun corfu--ensure-display-graphic () - "Return non-nil if Corfu is running on a graphics display, otherwise self deactivate." - (or (and (not emacs-basic-display) (display-graphic-p)) - (progn - (corfu-mode -1) - (message "Corfu mode is only compatible with the graphics display.") - nil))) - ;;;###autoload (define-minor-mode corfu-mode "Completion Overlay Region FUnction" :global nil - (if corfu-mode - (when (or (daemonp) (corfu--ensure-display-graphic)) - (add-hook 'completion-in-region-mode-hook #'corfu--mode-hook nil 'local) - (setq-local completion-in-region-function #'corfu--completion-in-region)) - (remove-hook 'completion-in-region-mode-hook #'corfu--mode-hook 'local) - (kill-local-variable 'completion-in-region-function))) + (remove-hook 'completion-in-region-mode-hook #'corfu--mode-hook 'local) + (kill-local-variable 'completion-in-region-function) + (when corfu-mode + (if (or emacs-basic-display (not (display-graphic-p))) + (message "Corfu mode is only compatible with the graphics display.") + (add-hook 'completion-in-region-mode-hook #'corfu--mode-hook nil 'local) + (setq-local completion-in-region-function #'corfu--completion-in-region)))) ;;;###autoload (define-globalized-minor-mode corfu-global-mode corfu-mode corfu--on)