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

Wucuo does not work, when I save the buffer. #16

Open
kangdalei opened this issue Oct 25, 2020 · 5 comments
Open

Wucuo does not work, when I save the buffer. #16

kangdalei opened this issue Oct 25, 2020 · 5 comments

Comments

@kangdalei
Copy link

kangdalei commented Oct 25, 2020

The wucuo-mode is already working, but it doesn't show anything when I save the buffer.

My platform is Windows cygwin hunspell 1.7.0 Emacs 26.3 , and installed en dictionary.

On the command line, hunspell works correctly.

for example:

hunspell -d en_US sp.txt

My elisp code about wucuo:

(use-package wucuo
  :hook ((text-mode prog-mode) . wucuo-start)
  )

The ispell-program-name is right.

ispell-program-name is a variable defined in ‘ispell.el’.
Its value is "c:/cygwin64/bin/hunspell.exe"

When I run M-x flyspell-buffer, the minibuffer display: Wrong type argument: stringp, nil

Run M-x flyspell-mode, the minibuffer display:

Error enabling Flyspell mode:
(stringp nil)
Quit [2 times]

Excuse me, where did it go wrong?

@redguardtoo
Copy link
Owner

M-x toggle-debug-on-error and run flyspell-buffer. Send me the full error message.

@kangdalei
Copy link
Author

M-x toggle-debug-on-error and run flyspell-buffer. Send me the full error message.

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
string-match("," nil 0)
split-string(nil "," t)
ispell-parse-hunspell-affix-file(nil)
ispell-find-hunspell-dictionaries()
ispell-set-spellchecker-params()
flyspell-region(1 5542)
flyspell-buffer()
funcall-interactively(flyspell-buffer)
call-interactively(flyspell-buffer record nil)
command-execute(flyspell-buffer record)
counsel-M-x-action("flyspell-buffer")
ivy-call()
ivy-read("M-x " [## evil-forward-WORD-begin ansi-color-apply-overlay-face isearch--state-pop-fun--cmacro 0 0 winring xselect--int-to-cons input-method-verbose-flag counsel-compile-env counsel-alias-expand magit-reflog-commit markdown-xhtml-body-preamble markdown-match-bold evil-replace-alist 0 0 dired-backup-diff template defun-prompt-regexp winnow mixal web-mode-warning-face application cl-print--preprocess which-key-side-window-max-height selinux-context counsel-evil-register-face magpie counsel-switch-buffer-other-window 0 benchmark-init/current-node xref-w-dedicated unicad-latin7-prober Load\ snippets... line-num dired-before-readin-hook ibuffer-update & ' 0 osx-org-clock-menubar * rx-trans-forms evil-echo-area-message unicad-quick-size not-at-beginning-of-line helm evil-replace-state-local-map Inline\ Code ...] :predicate (closure ((externs) (initial-input) smex-ido-cache smex-initialized-p amx-cache amx-initialized info-lookup-mode find-tag-marker-ring t) (sym) (and (commandp sym) (not (get sym (quote byte-obsolete-info))) (not (get sym (quote no-counsel-M-x))))) :require-match t :history counsel-M-x-history :action counsel-M-x-action :keymap (keymap (67108908 . counsel--info-lookup-symbol) (67108910 . counsel-find-symbol)) :initial-input nil :caller counsel-M-x)
(let ((externs (counsel--M-x-externs))) (ivy-read (counsel--M-x-prompt) (or externs obarray) :predicate (if externs (function (lambda (x) (not (get (intern x) (quote no-counsel-M-x))))) (function (lambda (sym) (and (commandp sym) (not (get sym ...)) (not (get sym ...)))))) :require-match t :history (quote counsel-M-x-history) :action (function counsel-M-x-action) :keymap counsel-describe-map :initial-input initial-input :caller (quote counsel-M-x)))
counsel-M-x()
funcall-interactively(counsel-M-x)
call-interactively(counsel-M-x nil nil)
command-execute(counsel-M-x)

@redguardtoo
Copy link
Owner

You should setup flyspell first. In this case, flyspell-bufferdoes not work, with or without wucuo.

Check README for the sample configuration.

@kangdalei
Copy link
Author

kangdalei commented Oct 25, 2020

Now, my code is:

(use-package wucuo
  :hook ((text-mode prog-mode) . wucuo-start)
  :init
  (setq ispell-program-name "c:/cygwin64/bin/hunspell.exe")
  ;; http://gromnitsky.blogspot.com/2016/09/emacs-251-hunspell.html
  (setq ispell-hunspell-dict-paths-alist
        '(("en_US" "C:/cygwin64/usr/share/myspell/en_US.aff")
          ("en_GB" "C:/cygwin64/usr/share/myspell/en_GB.aff")))

  (setq ispell-local-dictionary "en_US")
  (setq ispell-local-dictionary-alist
        '(("en_US" "[[:alpha:]]" "[^[:alpha:]]" "[']" nil ("-d" "en_US") nil utf-8)))
  )

Restart emacs. I saved the buffer, but wucuo doesn't start spell checking.

Run M-x flyspell-mode, minibuffer display:

Error enabling Flyspell mode:
(stringp nil)

Second run M-x flyspell-mode, display:

Starting new Ispell process c:/cygwin64/bin/hunspell.exe with en_US dictionary...

The third time run M-x flyspell-mode, disable the flyspell-mode. This time wucuo is working correctly!

I was very confused. The problem is likely due to my settings of flyspell.

so, I tried apsell that installed from cygwin.

(use-package wucuo
  :hook ((text-mode prog-mode) . wucuo-start)
  :init
(setq ispell-program-name "aspell")
;; You could add extra option "--camel-case" for since Aspell 0.60.8
;; @see https://github.com/redguardtoo/emacs.d/issues/796
(setq ispell-extra-args '("--sug-mode=ultra" "--lang=en_US" "--run-together" "--run-together-limit=16"))
  )

But it's the same thing. I still need to enable and disable flyspell-mode manually, then wucuo can start spell checking.

update:
First run , M-x wucuo-spell-check-visible-region . After that, wucuo can check the spelling when saving the buffer.

@redguardtoo
Copy link
Owner

redguardtoo commented Oct 26, 2020

Just follow my README. I'm the flyspell expert in Emacs community so README should be complete enough. Be patient, wucuo needs a few seconds interval to cool down before next firing up. The interval is for performance.

Please also search emacs stackexhchange hunspell related answer written by me, for example, see https://emacs.stackexchange.com/questions/30008/hunspell-flyspell-and-emacs-on-windows

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