flyspell-mode报错

报错

wrong type argument stringp nil

backtrace如下,

    Debugger entered--Lisp error: (wrong-type-argument stringp nil)
      string-match("," nil 0)
      split-string(nil "," t)
      ispell-parse-hunspell-affix-file(nil)
      ispell-hunspell-fill-dictionary-entry(nil)

.emacs中的ispell设置为,

;; find aspell and hunspell automatically
(cond
 ;; try hunspell at first
  ;; if hunspell does NOT exist, use aspell
 ((executable-find "hunspell")
  (setq ispell-program-name "hunspell")
  (setq ispell-local-dictionary "en_AU")
  (setq ispell-local-dictionary-alist
        ;; Please note the list `("-d" "en_AU")` contains ACTUAL parameters passed to hunspell
        ;; You could use `("-d" "en_AU,en_AU-med")` to check with multiple dictionaries
        '(("en_AU" "[[:alpha:]]" "[^[:alpha:]]" "[']" nil ("-d" "en_AU") nil utf-8)
          )))

 ((executable-find "aspell")
  (setq ispell-program-name "aspell")
  ;; Please note ispell-extra-args contains ACTUAL parameters passed to aspell
  (setq ispell-extra-args '("--sug-mode=ultra" "--lang=en_AU"))))

不理解的是明明在 .emacs中设置了 ispell-local-dictionary, 为啥传入 ispell-hunspell-fill-dictionary-entry()的是 nil 呢?

请教各位!多谢!

请不要用图片贴代码和 Backtrace。论坛使用 Markdown,如果你不清楚 Markdown 里怎么贴代码,可参考

后面的函数名中有个笔误(dictionany -> dictionary)。通过调试肯定能找出缘由来,假设跟事实不符说明假设有误。

谢谢提示,原帖已更新。

现在跟踪 backtrace 发现有时候传入的参数为,

ispell-hunspell-fill-dictionary-entry(nil)

而有时候为,

ispell-hunspell-fill-dictionary-entry(‘en_AU’)

越发费解了。

另外,

* assoc("de_DE" (("english" "c:/Users/a/Downloads/emacs-25.2-i686/share/hunspell/en_US.aff") ("en_US" "c:/Users/a/Downloads/emacs-25.2-i686/share/hunspell/en_US.aff") ("en_AU" "c:/Users/a/Downloads/emacs-25.2-i686/share/hunspell/en_AU.aff")))

这句该如何理解?

1 个赞

直接在配置里指定语言环境试试。

看到 ispell.el里面有

(ispell-print-if-debug "++ ispell-fhd: Adding alias %s -> %s.\n"
                                     dict-equiv-key affix-file)

但是 ispell-debug 里什么都没有,需要设置什么开关吗? 目前我执行了

M-x ispell-buffer-with-debug

当前找了两个笨办法,

  1. 继续使用 hunspell, 并直接修改 ispell.el
	      ;; Entry has an associated .aff file and no previous value.
	      (let ((affix-file (expand-file-name affix-file)))
		(ispell-print-if-debug
                 "++ ispell-fhd: dict-entry:%s name:%s basename:%s affix-file:%s\n"
                 dict full-name basename affix-file)
		(add-to-list 'ispell-hunspell-dict-paths-alist
			     (list basename affix-file))
                (setq hunspell-default-dict (list basename affix-file)) ;; add this line
                )

  1. 转而使用 aspell,相对比较简单。 从 GNU Aspell 0.50 (Win32 version) 下载 binary 和 pre-compiled dictionary.
;; Aspell setting
(add-to-list 'exec-path "C:/Program Files (x86)/Aspell/bin/")
(setq ispell-program-name "aspell")
(require 'ispell)

;; find aspell and hunspell automatically
(cond
 ;; try aspell at first
  ;; if aspell does NOT exist, use hunspell 
 ((executable-find "aspell")
  (setq ispell-program-name "aspell")
  ;; Please note ispell-extra-args contains ACTUAL parameters passed to aspell
  (setq ispell-extra-args '("--sug-mode=ultra" "--lang=en_US")))

 ((executable-find "hunspell")
  (setq ispell-program-name "hunspell")
  (setq ispell-local-dictionary "en_US")
  (setq ispell-local-dictionary-alist
        ;; Please note the list `("-d" "en_US")` contains ACTUAL parameters passed to hunspell
        ;; You could use `("-d" "en_US,en_US-med")` to check with multiple dictionaries
        '(("en_US" "[[:alpha:]]" "[^[:alpha:]]" "[']" nil ("-d" "en_US") nil utf-8)
          )))

 )