Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

company-capf cannot find aspell dictionaries #1437

Closed
Panadestein opened this issue Dec 5, 2023 · 7 comments
Closed

company-capf cannot find aspell dictionaries #1437

Panadestein opened this issue Dec 5, 2023 · 7 comments

Comments

@Panadestein
Copy link

Hello, as the title mentions, I am not able anymore to use spell checking correctly with company-capf, after my recent Emacs update.

Output of M-x company-diag:

Emacs 30.0.50 (x86_64-pc-linux-gnu) of 2023-12-05 on nil
Company 0.10.2

company-backends: (company-bbdb company-semantic company-cmake company-capf
	      company-clang company-files
	      (company-dabbrev-code company-gtags company-etags
				    company-keywords)
	      company-oddmuse company-dabbrev)

Used backend: company-dabbrev

Major mode: org-mode
Prefix: ""

Completions:
  "title"
  "interpreter"
  "general"
  "comments"
  "will"
  "build"
  "called"
  "that"
  "supports"
  "gates"
  "measurements"
  "quantum"
  "transmuted"
  "into"
  "single"
  "linear"
  "operator"
  "acts"
  "hilbert"
  "space"
  "wave"
  "function"
  "language"
  "have"
  "lisp"
  "like"
  "syntax"
  "common"
  "array"
  "code"
  "programming"
  "model"
  "abstract"
  "machine"
  "qubits"
  "whose"
  "state"
  "given"
  "measurement"
  "register"
  "consider"
  "mathcal"
  "begin"
  "lisp"
  "tangle"
  "defstruct"
  "results"
  "machine"
  "remaining"
  "discussion"
  "assumes"
  "basic"
  "mechanics"
  "background"
  "let's"
  "define"
  "qubit"
  "defun"
  "make"
  "expt"
  "initial"
  "element"
  "setf"
  "aref"
  "make"
  "quantum"
  "state"
  "above"
  "return"
  "ldots"
  "rangle"
  "coefficient"
  "indicating"
  "this"
  "only"
  "contribution"
  "next"
  "retrieve"
  "number"
  "size"
  "this"
  "amounts"
  "compute"
  "binary"
  "logarithm"
  "bits"
  "representation"
  "dimension"
  "integer"
  "length"
  "dimension"
  "qubits"
  "propagation"
  "system"
  "then"
  "implemented"
  "using"
  "algebra"
  "operations"
  "apply"
  "unitary"
  "oper"
  "dotimes"
  "incf"
  "replace"
  "apply"
  "operator"
  "compose"
  "left"
  "right"
  "list"
  "prod"
  "compose"
  "provided"
  "machinery"
  "proceed"
  "implement"
  "again"
  "domain"
  "knowledge"
  "needed"
  "here"
  "particular"
  "regarding"
  "collapse"
  "observe"
  "sample"
  "observe"
  "code"
  "collapsed"
  "saved"
  "automatically"
  "generated"
  "accessor"
  "next"
  "section"
  "more"
  "interesting"
  "deals"
  "with"
  "sampling"
  "process"
  "statistical"
  "terms"
  "want"
  "discrete"
  "random"
  "variable"
  "equation"
  "text"
  "uniform"
  "leverage"
  "equations"
  "follows"
  "decf"
  "when"
  "minusp"
  "sample"
  "implies"
  "realization"
  "fill"
  "collapse"
  "some"
  "start"
  "identity"
  "defparameter"
  "gate"
  "then"
  "generic"
  "assert"
  "%apply"
  "singleq"
  "first"
  "multiq"
  "gate"
  "need"
  "implementation"
  "kronecker"
  "product"
  "generating"
  "multi"
  "kronecker"
  "destructuring"
  "bind"
  "dimensions"
  "kron"
  "pointer"
  "kronecker"
  "product"
  "focus"
  "generate"
  "action"
  "continuous"
  "range"
  "achieved"
  "following"
  "lift"
  "otimes"
  "where"
  "covers"
  "factors"
  "second"
  "cond"
  "expt"
  "with"
  "definition"
  "lift"
  "note"
  "accounts"
  "multiple"
  "adjacent"
  "multiple"
  "gates'"
  "actions"
  "trickier"
  "handle"
  "idea"
  "permutation"
  "matrix"
  "temporarily"
  "restores"
  "order"
  "swap"
  "which"
  "exchanges"
  "states"
  "using"
  "fact"
  "permutations"
  "decomposed"
  "transpositions"
  "form"
  "cons"
  "cells"
  "required"
  "perm"
  "trans"
  "natural"
  "nreverse"
  "permuted"
  "loop"
  "while"
  "push"
  "please"
  "note"
  "indicates"
  "index"
  "rearranged"
  "itself"
  "correspondence"
  "cauchy's"
  "line"
  "notation"
  "tricky"
  "times"
  "here"
  "what"
  "doing"
  "through"
  "each"
  "target"
  "larger"
  "than"
  "case"
  "directly"
  "transposition"
  "smaller"
  "original"
  "tutorial"
  "used"
  "clause"
  "avoid"
  "pushing"
  "swap"
  "streamlined"
  "home"
  "loren"
  "documents"
  "arbeit"
  "interp"
  "drwxr"
  "images"
  "readme"

Describe the issue

I get the error presented below in tdoe every time I press a key in text mode.

Expected behavior

I expect the completion suggestions to appear as before.

tdoe

Debugger entered--Lisp error: (error "ispell-lookup-words: No plain word-list found at systemdefault locations.  Customize ‘ispell-alternate-dictionary’ to set yours.")
  error("ispell-lookup-words: No plain word-list found at systemdefault locations.  Customize `ispell-alternate-dictionary' to set yours.")
  ispell-lookup-words("df")
  ispell-completion-at-point()
  completion--capf-wrapper(ispell-completion-at-point optimist)
  company--capf-wrapper(ispell-completion-at-point optimist)
  company--capf-data-real()
  company--capf-data()
  company-capf(prefix)
  apply(company-capf prefix)
  company-call-backend-raw(prefix)
  company--force-sync(company-call-backend-raw (prefix) company-capf)
  company-call-backend(prefix)
  company--begin-new()
  company--perform()
  company-auto-begin()
  company-idle-begin(#<buffer clq.org> #<window 3 on clq.org> 3713 8350)
  apply(company-idle-begin (#<buffer clq.org> #<window 3 on clq.org> 3713 8350))
  timer-event-handler([t 25967 33415 719988 nil company-idle-begin (#<buffer clq.org> #<window 3 on clq.org> 3713 8350) nil 721000 nil])
  sit-for(3)
  flyspell-check-word-p()
  flyspell-post-command-hook()

Additional context

I am on NixOS unstable.

@dgutov
Copy link
Member

dgutov commented Dec 5, 2023

Hi!

This error is caused by a change in upstream: emacs-mirror/emacs@47e313e9805

That is, text-mode and all modes deriving from it that don't opt out, now have a completion function based on ispell.

Looks like you don't have a dictionary installed, so that's why it errors. Which might be a good cause for a bug report upstream, in case you'd prefer this kind of error to be ignored silently.

Either way, I'm adding a user option that would skip this new completion table, in addition to the already skipped tags-completion-at-point-function, so that the built-in backends for these two sources are still preferred. Those who prefer the completion sources from the Emacs core, can customize this new variable.

@dgutov dgutov closed this as completed in 7bcffac Dec 5, 2023
@Panadestein
Copy link
Author

Panadestein commented Dec 6, 2023

Hey @dgutov thanks for the prompt answer! That fix indeed suppresses the error. But I am a bit confused. I have a bunch of aspell and hunspell dictionaries on my system, and in fact, spell checking works if I write a typo in text-mode. Could it be related to my config that company does not see the dictionaries?

(use-package company
  :straight t
  :init
  (add-hook 'after-init-hook 'global-company-mode)
  (setq company-minimum-prefix-length 3
        company-selection-wrap-around t
        company-tooltip-limit 20
        company-tooltip-minimum-width 15
        company-tooltip-align-annotations t))

It might also be related to the way NixOS manages envs.

P.D: company-mode is awesome.

@dgutov
Copy link
Member

dgutov commented Dec 6, 2023

Thanks for testing!

But I am a bit confused. I have a bunch of aspell and hunspell dictionaries on my system, and in fact, spell checking works if I write a typo in text-mode. Could it be related to my config that company does not see the dictionaries?

There is no setting up of dictionaries on our side in this example. ispell-completion-at-point just errors out: in ispell-lookup-words call. I'm not sure about flyspell -- perhaps you have it separately configured to point to the installed dictionaries? E.g. the variable flyspell-default-dictionary.

You can try ispell completion (in the same buffer) without company just by pressing C-M-i.

@Panadestein
Copy link
Author

My flyspell config is also very simple, I think:

(use-package flyspell
  :straight nil
  :hook
  ((prog-mode . flyspell-prog-mode)
   (text-mode . turn-on-flyspell))
  :config
  (flyspell-mode +1))

When I C-h-v flyspell-default-dictionary I see that the variable is nil.

But C-M-i actually works (meaning it gives suggestions). My full config is here.

@dgutov
Copy link
Member

dgutov commented Dec 6, 2023

But C-M-i actually works (meaning it gives suggestions).

Hmm, but which suggestions? Is it bound to flyspell-auto-correct-word (which apparently flyspell does by default when enabled)? You can also invoke M-x complete-symbol explicitly to try to reproduce the error.

I haven't seen the error myself: the option is for the users to be able to prefer company-ispell more easily. If the above doesn't help, edebug-ing ispell-lookup-words could be a good next step.

@Panadestein
Copy link
Author

Well, that was the right suggestion for debugging. If I type the string examp, and then:

M-x complete-symbol
ispell-lookup-words: ispell-lookup-words: No plain word-list found at systemdefault locations.  Customize ‘ispell-alternate-dictionary’ to set yours.

If I try again with the string examp but this time:

C-M-i
Corrections: exam exam exams ex amp ex-amp example exempt exam's expo examp exam

Some of those suggestions I did not type before in my current session, so I guess they come from a dictionary?

@dgutov
Copy link
Member

dgutov commented Dec 6, 2023

Yes, but these are from flyspell-auto-correct-word, not ispell-completion-at-point:

Corrections: exam exam exams ex amp ex-amp example exempt exam's expo examp exam

Flymake does use ispell under the covers, but in a different way. So it's likely a bug one way or another, but one that can be easily reproduced without company (on your machine, but not mine). If you want to debug this further, this should help: https://www.gnu.org/software/emacs/manual/html_node/elisp/Using-Edebug.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants