Prevent company-abort side-effects suppressing echo-area

e.g. some sly commands (like sly-compile-defun) log to the echo area,
but company-abort was being called every time normal mode is
invoked (which happens more often than you'd think). It would be fine if
company-abort noop'ed if company wasn't active, but it doesn't; side
effects ensue.
This commit is contained in:
Henrik Lissner 2020-05-17 20:31:51 -04:00
parent 98d7b97d33
commit bdd4657e23
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -37,7 +37,14 @@
(unless (featurep! +childframe) (unless (featurep! +childframe)
;; Don't persist company popups when switching back to normal mode. ;; Don't persist company popups when switching back to normal mode.
;; `company-box' aborts on mode switch so it doesn't need this. ;; `company-box' aborts on mode switch so it doesn't need this.
(add-hook 'evil-normal-state-entry-hook #'company-abort)) (add-hook! 'evil-normal-state-entry-hook
(defun +company-abort-h ()
;; HACK `company-abort' doesn't no-op if company isn't active; causing
;; unwanted side-effects, like the suppression of messages in the
;; echo-area.
;; REVIEW Revisit this to refactor; shouldn't be necessary!
(when company-candidates
(company-abort)))))
;; Allow users to switch between backends on the fly. E.g. C-x C-s followed ;; Allow users to switch between backends on the fly. E.g. C-x C-s followed
;; by C-x C-n, will switch from `company-yasnippet' to ;; by C-x C-n, will switch from `company-yasnippet' to
;; `company-dabbrev-code'. ;; `company-dabbrev-code'.