Fix (activate) company-emoji completion

Currently company-emoji does not get activated by the emoji layer.
Also when it is activated, then the emoji short-name does not get completed to
unicode if `company-emoji-insert-unicode` is `t`.

This commit fixes both issues, by activating company-emoji for text-modes and
advising the emoji inert function to optionally do company-emoji completion.
This commit is contained in:
Daniel Nicolai 2021-09-14 13:11:22 +02:00 committed by Maxi Wolff
parent b4db141531
commit 9803b60d64
3 changed files with 24 additions and 1 deletions

View File

@ -8,6 +8,8 @@
- [[#description][Description]]
- [[#features][Features:]]
- [[#install][Install]]
- [[#configuration][Configuration]]
- [[#unicode-or-short-names][Unicode or short-names]]
- [[#key-bindings][Key bindings]]
- [[#emoji-dedicated-buffer][Emoji dedicated buffer]]
@ -31,6 +33,17 @@ Linux user could install [[https://zhm.github.io/symbola/][Symbola]] font to get
apt-get install ttf-ancient-fonts
#+END_SRC
** Configuration
*** Unicode or short-names
By default, company-emoji is configured only for =text-mode= and inserts
unicode. To insert short-names set =company-emoji-insert-unicode= to =nil= as
follows:
#+BEGIN_SRC emacs-lisp
(auto-completion :variables
company-emoji-insert-unicode nil)
#+END_SRC
* Key bindings
| Key binding | Description |

View File

@ -48,3 +48,9 @@ properly."
;; If we directly call the emoji mode at hook runtime then some
;; text properties are not applied correctly.
(run-at-time 0.1 nil 'emoji-cheat-sheet-plus-display-mode))
(defun spacemacs/emoji-insert-and-possibly-complete (_)
"Use company-emoji to complete 'to' unicode."
(when company-emoji-insert-unicode
(delete-char -1)
(company-complete)))

View File

@ -58,4 +58,8 @@
(spacemacs//set-emoji-font nil)
;; Hook for when a frame is created with emacsclient
(spacemacs|do-after-display-system-init
(spacemacs//set-emoji-font-for-current-frame)))))
(spacemacs//set-emoji-font-for-current-frame))
(spacemacs|add-company-backends :backends company-emoji
:modes text-mode))
:config
(advice-add 'emoji-cheat-sheet-plus--insert-selection :after #'spacemacs/emoji-insert-and-possibly-complete)))