SystemCrafters / crafted-emacs

A sensible base Emacs configuration.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

User is trapped in INSERT state when using `evil` and `completion` modules (pkgs+config) because corfu cannot handle rejection.

bryce-carson opened this issue · comments

Operating System

Linux/BSD

Additional Operating System information

Fedora 38 Workstation

Emacs Version

28

Emacs Configuration Details

  • Native Compilation
  • pGTK
  • alternative package manager (use-package, straight.el, ...)

Anything else that may be related to the issue you're having?

I am unsure if I am running a pGTK build of Emacs. I am using the default build of Emacs available on Fedora 38 Workstation.

GNU Emacs 28.3 (build 1, x86_64-redhat-linux-gnu, GTK+ Version 3.24.38, cairo version 1.17.8) of 2023-09-23

What happened?

  1. Bootstrap a new Emacs configuration with Crafted Emacs with the two given files.
early-init.el
(load "~/crafted-emacs/modules/crafted-early-init-config")

(defun crafted-emacs-load-modules (modules)
  "Initialize crafted-emacs modules.

MODULES is a list of module names without the -packages or
-config suffixes.  Note that any user-provided packages should be
added to `package-install-selected-packages' before invoking this
function."
  (dolist (m modules)
    (require (intern (format "crafted-%s-packages" m)) nil :noerror))
  (package-install-selected-packages :noconfirm)
  (dolist (m modules)
    (require (intern (format "crafted-%s-config" m)) nil :noerror)))
init.el
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(when (and custom-file
           (file-exists-p custom-file))
  (load custom-file nil :nomessage))

(load "~/crafted-emacs/modules/crafted-init-config")

;;                  .
;;
;;                   .
;;         /^\     .
;;    /\   "V"
;;   /__\   I      O  o
;;  //..\\  I     .
;;  \].`[/  I
;;  /l\/j\  (]    .  O
;; /. ~~ ,\/I          .
;; \\L__j^\/I       o
;;  \/--v}  I     o   .
;;  |    |  I   _________
;;  |    |  I c(`       ')o
;;  |    l  I   \.     ,/
;;_/j  L l\_!  _//^---^\\_    -Row


(package-install-selected-packages :noconfirm)
(crafted-emacs-load-modules '(evil completion ui))
  1. Because the symbol mods was included in the helper function crafted-emacs-load-modules, you'll need to correct it (I already corrected it in early-init.el included in this issue, so there are no errors when the function is called in init.el).

See my recent comment on #405: 516699d#r138250346. That doesn't deserve a full issue.

  1. When in evil INSERT state while correcting mods to modules a completion candidate will appear, but if you complete typing module quickly the current config of corfu will break and you'll be stuck in INSERT state until you call evil-collection-corfu-quit-and-escape interactively. ESC does not work to exit INSERT state, nor does C-g; calling the mentioned function interactively did work for me, however.

There are the following messages from corfu in my *Messages* buffer.

Error in post-command-hook (corfu--post-command): (setting-constant nil)
Error running timer ‘corfu--auto-complete-deferred’: (wrong-number-of-arguments #<subr evil-normalize-keymaps> 4)
apply: Attempt to set a constant symbol: nil
ESC C-M-x C-b is undefined

What should have happened?

The connection between ESC, C-g, and other methods of returning to NORMAL state should not have been broken by corfu because of a rejected/unused completion candidate.

Hi, thank you for your contribution.

The mods vs. modules is probably a typo that was missed, thank you for catching that.

However, it seems somewhat unrelated to the other issue described as I could reproduce the same behavior without the loading function (the "manual" way of requiring the three packages/config modules).

A few tests later, it seems that it's related to corfu 1.2 and/or it's interactions with evil/evil-collection.
My local non-crafted-emacs setup was running corfu 1.1 (+ evil/evil-collection), but after updating I found the same issue there too.

This part needs further investigation, not sure what the solution is yet as it seems (from these initial tests) unrelated to configuration.

The mods vs. modules is probably a typo that was missed, thank you for catching that.

However, it seems somewhat unrelated to the other issue described as I could reproduce the same behavior without the loading function (the "manual" way of requiring the three packages/config modules).

Yes, that typo is unrelated to this bugged behaviour.

I have merged a PR related to the mods vs modules typo. However, the rest seems to not be a Crafted Emacs bug, and more likely should be reported to the Corfu maintainers. This issue can be linked there if needed. If we can confirm this is a Crafted Emacs specific bug, a PR would be appreciated. I'm not an evil user, so I'll defer to @jvdydev for guidance.

I'll also point out, if you choose to use the crafted-emacs-load-modules function, you don't need to call the package-install-selected-packages form as it is done for you in the crafted-emacs-load-modules defun. Not related to the bug in this case, but maybe helpful otherwise.

Any updates on this? I'm considering closing it since it doesn't appear to be a Crafted Emacs issue, but one related to evil.

@bryce-carson @jvdydev

Any updates on this? I'm considering closing it since it doesn't appear to be a Crafted Emacs issue, but one related to evil.

@bryce-carson @jvdydev

Ah. No, I don't have any updates.

It probably is limited to the evil package, given the information the other commentator provided re. updates to evil and similar observed behaviour (IIRC).

Ok, I'll close this then. Thanks @bryce-carson