tmalsburg / guess-language.el

Emacs minor mode that detects the language you're typing in. Automatically switches spell checker. Supports multiple languages per document.
115 stars 14 forks source link

Trigrams searched in wrong directory? #3

Closed joostkremers closed 7 years ago

joostkremers commented 7 years ago

Hi, this looks like it's exactly the thing I've been looking for, but I'm having trouble setting it up. I installed the package and added the following to my init file:

(use-package guess-language
  :ensure t
  :init
  (add-hook 'text-mode-hook #'guess-language-mode)
  :diminish guess-language-mode)

But when I open a text file, flyspell doesn't work (even though I get a message about it starting up). The *Messages* buffer contains a message such as the following:

Error in post-command-hook (flyspell-post-command-hook): (file-error "Opening input file" "No such file or directory" "/home/joost/src/criticmarkup-emacs/trigrams/en")

The directory in the error message is the one containing the file I just opened.

Am I doing something wrong or is this a bug somewhere?

tmalsburg commented 7 years ago

Did you install from MELPA? MELPA changes the directory structure. I pushed a fix in da675df406c2b971b2ad4c8d56ef15ee9920faf1. Let me know whether this fixes it.

manuel-uberti commented 7 years ago

Just installed from MELPA, the issue is still here.

manuel-uberti commented 7 years ago

If it can help debug the issue, it doesn't work when cloning the repo directly either:

Error in post-command-hook (flyspell-post-command-hook): (file-missing "Opening input file" "No such file or directory" "/home/manuel/githubs/guess-language.el/en")
tmalsburg commented 7 years ago

I know it's not working when you just clone the repository but it should work through MELPA and it does on my machine. @manuel-uberti what error message do you get when you install through MELPA? To make sure you're actually using the MELPA version, please restart Emacs after installing.

manuel-uberti commented 7 years ago

Reinstalled through MELPA, restarted Emacs, I get:

Error in post-command-hook (flyspell-post-command-hook): (error "Undefined dictionary: en")

My setup:

(use-package guess-language         ; Automatically detect language for Flyspell
  :ensure t
  :defer t
  :init (add-hook 'text-mode-hook #'guess-language-mode)
  :config
  (validate-setq guess-language-languages '(en it)
                 guess-language-min-paragraph-length 30)
  :diminish guess-language-mode)
tmalsburg commented 7 years ago

@manuel-uberti that's not a problem with my package but with your ispell install. Apparently you don't have the English dictionary. That's at least what the error message is suggesting. You can test by M-x ispell-change-dictionary and then selecting en. Alternatively, you have an English dictionary but it's perhaps named differently, english instead of en.

manuel-uberti commented 7 years ago

Weird, I got this setup for ispell and spell-checking is working just fine:

(validate-setq ispell-program-name (executable-find "hunspell")
               ispell-dictionary "en_GB"
               ispell-choices-win-default-height 5)
tmalsburg commented 7 years ago

See? The dictionary is called en_GB on your system not en. Thing is that guess-language cannot know what dictionary you are using, so you have to configure it. Have a look at the variable guess-language-langcodes. There you can change en to en_GB and then it should work. This needs to be explained in the documentation and guess-language-langcodes needs to be a defcustom.

manuel-uberti commented 7 years ago

Fantastic, thanks, I didn't know about that variable. It works now. Mind if I blog about your package?

tmalsburg commented 7 years ago

Not at all, go ahead. Where is your blog? And let me know if you have other feedback regarding the package.

manuel-uberti commented 7 years ago

https://manuel-uberti.github.io

I already started writing about your package, so I'll update it soon.

tmalsburg commented 7 years ago

@manuel-uberti I added information on changing the default dictionary here: https://github.com/tmalsburg/guess-language.el#configuration

tmalsburg commented 7 years ago

Guess-language-mode should now find the data files irrespectively of whether it was installed through MELPA or not. Fingers crossed. @joostkremers I assume that this is fixed now and will close this issue. Feel free to reopen if necessary.

joostkremers commented 7 years ago

Yes, the issue is solved for me as well now.