minad / jinx

🪄 Enchanted Spell Checker
GNU General Public License v3.0
426 stars 20 forks source link

jinx-correct is not replacing the misspelled word if I use a digit #112

Closed nils-schween closed 11 months ago

nils-schween commented 11 months ago

Hi,

and thanks for developing jinx. I just started using it and I directly encountered a problem. I bound jinx correct to M-$ to get the list of possible corrections for a misspelled word and I am offered a digits to choose between the options. If type one of digits the misspelled word is not replaced with the proposed correction. If I choose the correction with C-n and Return it gets replaced.

I do not know how to debug this. Any help is appreciated. Thanks. Nils

minad commented 11 months ago

Hi, thanks for the report. I suspect that this issue is caused by some specific settings in your init.el. Which completion UI do you use, e.g., Vertico, Helm or Ivy? Can you please try to reproduce the issue in a minimal configuration starting from emacs -Q and load only a minimal set of packages? Then I can help debugging this or maybe add a fix here.

nils-schween commented 11 months ago

Thanks for the quick answer. I deactivated ivy-mode and it worked. Here is my ivy-config. Maybe you can spot the culprit, which breaks it.

(use-package ivy
  :ensure t
  :commands (ivy-mode)
  :bind ("C-c C-r" . ivy-resume)
  :diminish ivy-mode
  :init
  ;; If I had put ivy-mode 1 into the config part, ivy was not loaded completely. Only after I used it once.
  (ivy-mode 1)
  :config
  (setq ivy-use-virtual-buffers t)
  ;; Show #/total when scrolling buffers
  (setq ivy-count-format "(%d/%d) ")
  (setq enable-recursive-minibuffers t)
  (setq ivy-wrap t)
  )

(use-package swiper
  :ensure t
  :bind (("C-s" . swiper)
     ("C-r" . swiper))
  )

(use-package counsel
  :ensure t
  :bind (("M-x" . counsel-M-x)
     ("M-y" . counsel-yank-pop)
     ("C-x C-f" . counsel-find-file)
     ("<f1> f" . counsel-describe-function)
     ("<f1> v" . counsel-describe-variable)
     ("<f1> l" . counsel-find-library)
     ("<f2> i" . counsel-info-lookup-symbol)
     ("<f2> u" . counsel-unicode-char)
     ("<f2> j" . counsel-set-variable)
     ("C-c g" . counsel-git-grep)
     ("C-c j" . counsel-git)
     ("C-c k" . counsel-ag)
     ("C-c r" . counsel-rg)
     ("C-x l" . counsel-locate)
     :map minibuffer-local-map
     ("C-r" . counsel-minibuffer-add)
     :map ivy-minibuffer-map
     ("M-y" . ivy-next-line-and-call)
     )
  :config
  (if (executable-find "rg")
      ;; use ripgrep instead of grep because it's way faster
      (setq counsel-grep-base-command
        "rg -i -M 120 --no-heading --line-number --color never %s %s"
        counsel-rg-base-command
        "rg -i -M 120 --no-heading --line-number --color never %s .")
    (warn "\nWARNING: Could not find the ripgrep executable. It "
      "is recommended you install ripgrep."))
  )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;  company-mode (Autocompletion framework)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(use-package company               
  :ensure t
  :defer t
  ;; Use Company for completion ;; the same as the first line after config
  ;; :bind (:map company-mode-map
  ;;          ([remap completion-at-point] . company-complete))
  :init
  (add-hook 'after-init-hook 'global-company-mode)
  :config  
  ;; (bind-key [remap completion-at-point] #'company-complete company-mode-map) ;; doesn not seem necessary

  (setq company-idle-delay .1                ;; Zero delay when pressing tab
    company-minimum-prefix-length 1      ;; The minimum prefix length for idle completion.
    company-show-numbers t           ;; Easy navigation to candidates with M-<n>
    company-tooltip-align-annotations t  ;; When non-nil, align annotations to the right tooltip border
    company-tooltip-limit 10         ;; The maximum number of candidates in the tooltip
    ;; company-dabbrev-downcase nil      ;; Whether to downcase the returned candidates of the dabbrev backend: The value of nil means keep them as-is.
    company-global-modes '(not gud-mode) ; deactivate company mode in gdb debugging sessions (because looking for completetions takes forever when working with dealii)
    )  
  )
minad commented 11 months ago

Thanks. I had assumed that the Jinx keymap is properly setup for all completion UIs. Unfortunately this is not the case. I hope some Ivy user can provide a patch which adjusts the keymap setup appropriately.

minad commented 11 months ago

@nils-schween I've pushed a potential fix. Can you please give it a try?

nils-schween commented 11 months ago

I just cloned the repository and replaced my installation of jinx with it. I checked, but unfortunately the fix does not seem to work for me. I am sorry. I will further investigate it to more.

minad commented 11 months ago

On 10/19/23 17:41, nils-schween wrote:

I just cloned the repository and replaced my installation of jinx with it. I checked, but unfortunately the fix does not seem to work for me. I am sorry. I will further investigate it to more.

Okay. I reverted the commit. Please let me know if you come up with something.

nils-schween commented 10 months ago

Today, I took the time to create a minimum setup to reproduce the problem. In Emacs v29.1 you can load the following .emacs file and edit any text file with jinx-mode enabled. Here is the .emacs

(package-initialize)

(use-package ivy
  :load-path "/path/to/.config/emacs/elpa/ivy-20231025.2311"
  :commands (ivy-mode)
  :bind ("C-c C-r" . ivy-resume)
  :diminish ivy-mode
  :init
  ;; If I had put ivy-mode 1 into the config part, ivy was not loaded completely. Only after I used it once.
  (ivy-mode 1)
  :config
  (setq ivy-use-virtual-buffers t)
  ;; Show #/total when scrolling buffers
  (setq ivy-count-format "(%d/%d) ")
  (setq enable-recursive-minibuffers t)
  (setq ivy-wrap t)
  )

(use-package jinx
  :load-path "/path/to/.config/emacs/elpa/jinx-20231104.1427"
  :hook((LaTeX-mode . jinx-mode))
  :bind (("M-$" . jinx-correct)
         ("C-M-$" . jinx-languages)
     )
  )

I hope this helps with debugging

minad commented 10 months ago

Thanks. For now I suggest to use one of the alternative completion UIs, Vertico, Mct, Helm, Icomplete, ... These all work with Jinx in its current form as far as I know.