minad / cape

🦸cape.el - Completion At Point Extensions
GNU General Public License v3.0
573 stars 20 forks source link

Cape with Corfu auto-corrects abbrevs before spaces #95

Closed nameiwillforget closed 9 months ago

nameiwillforget commented 9 months ago

Hello! I recently switched to Corfu with Cape and I think it's great, but I experience some weird behavior of which I'm not sure whether or not it's a bug: Corfu will just auto-correct Abbrevs even before I ended the word with Space. So it would correct fro immediately to for, even before I could go on and write "from". This happens regardless of whether Abbrev-Mode is on but only in some major modes, such as Lisp mode and Text mode, but not in elisp or latex mode, which might have something to do with the order I loaded capes in. It also doesn't happen if I comment out

(add-to-list 'completion-at-point-functions #'cape-abbrev)

Maybe it's something in my config, but I don't know what it could be. Here is my config for reference:

(use-package corfu
  :config
  (setq corfu-cycle t)

  (setq corfu-auto t)
  (setq corfu-auto-delay  0)
  (setq corfu-auto-prefix 2)
  (setq completion-styles '(orderless))
  )

(use-package cape
  :init
  (unbind-key "C-f")
  :bind (("C-f p" . completion-at-point) 
         ("C-f t" . complete-tag)        
         ("C-f d" . cape-dabbrev)        
         ("C-f h" . cape-history)
         ("C-f f" . cape-file)
         ("C-f k" . cape-keyword)
         ("C-f s" . cape-elisp-symbol)
         ("C-f e" . cape-elisp-block)
         ("C-f a" . cape-abbrev)
         ("C-f l" . cape-line)
         ("C-f w" . cape-dict)
         ("C-f :" . cape-emoji)
         ("C-f \\" . cape-tex)
         ("C-f ^" . cape-tex)
         ("C-f &" . cape-sgml)
         ("C-f r" . cape-rfc1345))
  :init
  (add-to-list 'completion-at-point-functions #'cape-dabbrev)
  (add-to-list 'completion-at-point-functions #'cape-tex)
;;  (add-to-list 'completion-at-point-functions #'cape-abbrev)
  (add-to-list 'completion-at-point-functions #'cape-dict)
  (add-to-list 'completion-at-point-functions #'cape-file)
  (add-to-list 'completion-at-point-functions #'cape-elisp-block)
  ;;(add-to-list 'completion-at-point-functions #'cape-history)
  ;;(add-to-list 'completion-at-point-functions #'cape-keyword)
  ;;(add-to-list 'completion-at-point-functions #'cape-sgml)
  ;;(add-to-list 'completion-at-point-functions #'cape-rfc1345)
  ;;(add-to-list 'completion-at-point-functions #'cape-elisp-symbol)
  ;;(add-to-list 'completion-at-point-functions #'cape-line)
)
minad commented 9 months ago

Corfu with cape-abbrev will auto complete and expand if the popup is open and you enter the exact abbreviation name. This is the expected behavior. You can customize corfu-on-exact-match to prevent this from happening. I hope this helps!