reddit / emacs

Changes of ispell.el of emacs v27.2 from v26.3?

BVPs · 2022-06-01 19:53
Hello. Recently, I updated my GNU emacs from v26.3 to v27.2. Now, ispell does not work anymore under Windows 10 (on my Macs, it still works). On my Windows machine, I use hunspell, which has been the same v1.7.0. I am wondering what should be changed in my setup \~/.emacs.d/init.el for the ispell in v27.2 to work. Just as an experiment, if I replace /usr/share/emacs/27.2/lisp/textmodes/ispell.\[el,elc\] by those of 26.3, the ispell system works under v27.2. That means that some setting in the new ispell.el has changed. My current setup in \~/.emacs.d/init.el is the following, which I copied from the posting [Tutorial: spellchecking with hunspell (1.7.0) for emacs (26.2) on Windows (10) : emacs (reddit.com)](https://www.reddit.com/r/emacs/comments/dgj0ae/tutorial_spellchecking_with_hunspell_170_for/) (autoload 'ispell-message "ispell" "Check spelling of mail message or news post.") (setq ispell-program-name "hunspell") (setq ispell-library-directory "C:/ProgramData/dict-en") (setq ispell-hunspell-dict-paths-alist '(("en_US" "C:/ProgramData/dict-en/en_US.aff"))) (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))) ;; the following line won't make flyspell-mode enabled by default as you might think (setq ispell-personal-dictionary "C:/Users/me/.hunspell_en_US") (flyspell-mode 1) ;; ispell-word for showing correcting options of the current misspelled word ;(global-set-key (kbd "M-\\") 'ispell-word If I use the ispell.el of v27.2, I got the error message: `ispell: Can’t find Hunspell dictionary with a .aff affix file` Thanks a lot for your help!
eli-zaretskii · 2022-06-02 11:07
Does it work if you invoke the spell-checking commands from `emacs -Q` after customizing *only* the variable `ispell-program-name` to point to the Hunspell executable file?
BVPs · 2022-06-02 19:37
Unfortunately, I still got exactly the same error: `ispell: Can't find Hunspell dictionary with a .aff affix file.`
eli-zaretskii · 2022-06-03 13:48
What does the following command produce if you invoke it from the Command Prompt window: hunspell -D -a nul < nul (If Hunspell is not on Path, prepend to it the necessary leading directories.)
BVPs · 2022-06-04 01:21
I got the following output from that command: $ hunspell -D -a nul < nul bash: nul: No such file or directory Thanks!
eli-zaretskii · 2022-06-04 07:49
I asked to invoke it from the Windows Command Prompt window, which runs `cmd.exe`, not Bash. If you must use Bash, try this instead: hunspell -D -a /dev/null < /dev/null
BVPs · 2022-06-04 16:41
Sorry, I misunderstood what you suggested. Here is the output of the command on cmd.exe: C:\Users\me> hunspell -D -a nul < nul SEARCH PATH: .;;C:\ProgramData\dict-en;C:\Hunspell;%USERPROFILE%\Application Data\OpenOffice.org 2\user\wordbook;C:\Program files\OpenOffice.org 2.4\share\dict\ooo;C:\Program files\OpenOffice.org 2.3\share\dict\ooo;C:\Program files\OpenOffice.org 2.2\share\dict\ooo;C:\Program files\OpenOffice.org 2.1\share\dict\ooo;C:\Program files\OpenOffice.org 2.0\share\dict\ooo AVAILABLE DICTIONARIES (path is not mandatory for -d option): Can't open affix or dictionary files for dictionary named "default". By the way, on my windows machine, I do not have any OpenOffice folders or apps in the above search path list.
eli-zaretskii · 2022-06-04 16:52
So I think there's your problem: you don't have default.aff and default.dic files. I suggest to copy the .dic file you use the most and the corresponding .aff file into default.*, and then try again.
BVPs · 2022-06-04 17:15
I just made symbolic links of default.aff <-> en\_US.aff and default.dic <-> en\_US.dic within C:\\ProgramData\\dict\_en. The hunspell command you suggested still generates the same error. Also, I didn't have to copy or make symbolic links of default.\* at all under ispell.el of v26.3. So, I don't think this is a problem of my dictionary setup.
eli-zaretskii · 2022-06-04 17:44
I don't have any way of knowing how this worked for you in Emacs 26.3. All I can say is that as long as that command doesn't produce a list of available dictionaries and the loaded dictionary, `ispell.el` will not work for you. Can you describe your Hunspell installation? In what directory do you have hunspell.exe and in what directory do you have the dictionary files? And also, please show the full contents of the directory where you keep the dictionaries.
BVPs · 2022-06-04 21:18
As far as I remember, I just installed Hunspell in the standard way. It's installed at C:\\Program Files\\hunspell, i.e., drwxr-xr-x 1 me 0 Oct 31 2020 ./ drwxr-xr-x 1 me 0 May 31 17:08 ../ -rwxr-xr-x 1 me 523776 Oct 31 2020 hunspell.exe* -rw-r--r-- 1 me 782336 Oct 31 2020 hunspell.pdb -rw-r--r-- 1 me 17478182 Oct 31 2020 libhunspell.lib -rwxr-xr-x 1 me 181760 Oct 31 2020 testparser.exe* -rw-r--r-- 1 me 544768 Oct 31 2020 testparser.pdb And the dictionaries are located at C:\\ProgramData\\dict-en, i.e., English.png affDescription.txt en_US.aff META-INF/ changelog.txt en_US.dic README.txt default.aff@ en_ZA.aff README_en_AU.txt default.dic@ en_ZA.dic README_en_CA.txt description.xml hyph_en_GB.dic README_en_GB.txt dictionaries.xcu hyph_en_US.dic README_en_GB_thes.txt en_AU.aff lgpl-3.0.txt README_en_US.txt en_AU.dic license.txt README_en_ZA.txt en_CA.aff package-description.txt README_hyph_en_GB.txt en_CA.dic th_en_US_v2.dat README_hyph_en_US.txt en_GB.aff th_en_US_v2.idx WordNet_license.txt en_GB.dic And, there is one more file on my home directory: -rw-r--r-- 1 me 1093 Jan 6 06:57 .hunspell_en_US I think that's all I have related to hunspell.
eli-zaretskii · 2022-06-05 06:11
I see nothing obviously wrong here, so I don't understand why `hunspell -D` fails, sorry. I'm grasping at straws here, but here are the last two things I'd try: * Try actually *copying* `en_US.dic` and `en_US.aff` to the corresponding `default.*` files, not symlinking. I'm not sure Hunspell can handle symlinks in this case. * Try this command instead: `hunspell -D -a < nul`, and see if that produces the list of available dictionaries including a loaded dictionary. If none of this works, I suggest to find a different port of Hunspell. Yours seems to be compiled by MSVC, not MinGW, so it might be some port with problems. Also, if possible, look for a version of Hunspell later than 1.7.0, as the initial release of that version had some bugs. Once again, if this very version of Hunspell worked with stock Emacs 26.3, I have no idea why, since the way we discover dictionaries didn't change between Emacs 26.3 and Emacs 27.1, and it requires `hunspell -D` to produce a valid list. Sorry.
BVPs · 2022-06-05 18:21
Now, it's very interesting. When I replace the symbolic links by the actual file copies, at least `hunspell -D -a nul < nul` works as expected: C:\Users\saito>hunspell -D -a nul < nul SEARCH PATH: .;;C:\ProgramData\dict-en;C:\Hunspell;%USERPROFILE%\Application Data\OpenOffice.org 2\user\wordbook;C:\Program files\OpenOffice.org 2.4\share\dict\ooo;C:\Program files\OpenOffice.org 2.3\share\dict\ooo;C:\Program files\OpenOffice.org 2.2\share\dict\ooo;C:\Program files\OpenOffice.org 2.1\share\dict\ooo;C:\Program files\OpenOffice.org 2.0\share\dict\oooAVAILABLE DICTIONARIES (path is not mandatory for -d option): LOADED DICTIONARY: C:\ProgramData\dict-en\default.aff C:\ProgramData\dict-en\default.dic @(#) International Ispell Version 3.2.06 (but really Hunspell 1.7.0) Also, here is the output of `hunspell -D -a < nul`: C:\Users\me>hunspell -D -a < nul SEARCH PATH: .;;C:\ProgramData\dict-en;C:\Hunspell;%USERPROFILE%\Application Data\OpenOffice.org 2\user\wordbook;C:\Program files\OpenOffice.org 2.4\share\dict\ooo;C:\Program files\OpenOffice.org 2.3\share\dict\ooo;C:\Program files\OpenOffice.org 2.2\share\dict\ooo;C:\Program files\OpenOffice.org 2.1\share\dict\ooo;C:\Program files\OpenOffice.org 2.0\share\dict\oooAVAILABLE DICTIONARIES (path is not mandatory for -d option): Finally, when I invoke ispell on GNU emacs 27.2, it still give the following error message: ispell-phaf: No matching entries for default in `ispell-hunspell-dict-paths-alist'. Now, currently, ispell-hunspell-dict-paths-alist is set as follows in my \~/.emacs.d/init.el (setq ispell-hunspell-dict-paths-alist '(("en_US" "C:/ProgramData/dict-en/en_US.aff"))) Even if I comment out the above line, I still get that same error message by `ispell-phaf`.
BVPs · 2022-06-05 19:14
>Hunspell Well, finally it started working after I inserted the following line in my \~/.emacs.d/init.el after I set up ispell-local-dictionary-alist: (setq ispell-hunspell-dictionary-alist ispell-local-dictionary-alist) This is the only change I needed for the GNU emacs v27.2's ispell to work. I even deleted default.\* , and it still works!
eli-zaretskii · 2022-06-06 12:17
Please only use `emacs -Q` for these experiments, as your customizations could get in the way. If you use `emacs -Q`, after copying (not symlinking) the dictionary to `default.*`, does invoking `ispell` signals the error about "No matching entries for default"? If it does, please show the full value of `ispell-hunspell-dict-paths-alist` in that `emacs -Q` session after you get this error. (And please, try to format the long strings so that they have line breaks, before you post them, since it is otherwise very hard to read them.)
eli-zaretskii · 2022-06-06 12:25
And one more thing: are you sure you are using `ispell.el` from Emacs 27.21, not some other version you have installed?
BVPs · 2022-06-06 17:29
OK, when I use `emacs -Q` and then I invoke `ispell`, then I got the error: ispell-phaf: No matching entries for default in `ispell-hunspell-dict-paths-alist'. This happens even after copying en\_US.\* as default.\*. Now, the full value of `ispell-hunspell-dict-paths-alist` (within `emacs -Q` session) is `nil`. I also want to mention that this `ispell.el` from Emacs 27.2.
BVPs · 2022-06-06 17:43
BTW, I am not the only one having this problem. The following thread on [emacs.stackexchange.com](https://emacs.stackexchange.com) has exactly the same case as I have. https://emacs.stackexchange.com/questions/14952/how-do-i-set-up-hunspell-on-a-windows-pc The last post of that thread talks about his/her fix: replace ispell.\[el,elc\] of 27.2 by those of 26.3; then it started working.
[deleted] · 2022-06-06 17:51
[deleted]
eli-zaretskii · 2022-06-06 19:38
Are you familiar with debugging Lisp with Edebug? If I ask you to step through a function in `ispell.el` and report some values, would you know how to do that?
BVPs · 2022-06-06 21:11
I'm afraid that I cannot do such debugging now because of my inexperience of Edebug and my time constraint. Sorry. At any rate, with my current \~/.emacs.d/init.el setup, it's working anyways. Moreover, I only use hunspell under ispell/emacs. I do not use Openoffice on my windows machine.