all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Vladimir Lomov <lomov.vl@gmail.com>
To: 15903@debbugs.gnu.org
Subject: bug#15903: 24.3.50; Fix small issue with ispell-hunspell when dictionary is set to default (nil)
Date: Mon, 18 Nov 2013 15:33:00 +0900	[thread overview]
Message-ID: <20131118063300.GB889@smoon> (raw)
In-Reply-To: <CAKy3oZq2HLboWBTf6tQfXZ7r1N1qi+Kn9hynBuzqn9AMypQuaA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 4627 bytes --]

Hello,
** Agustin Martin [2013-11-16 12:43:02 +0100]:

> 2013/11/15 Vladimir Lomov <lomov.vl@gmail.com>

>> Hello,
>> according to variable 'ispell-dictionary-base-alist' defined in
>> 'ispell.el' if 'ispell-dictionary' is nil then it is considered as
>> default value for dictionary. Unfortunately, when hunspell is used as
>> ispell program function 'ispell-parse-hunspell-affix-file' fails because
>> it doesn't expect nil as argument.

>> I propose small and simple patch. I checked it starting emacs as:
>>   emacs -Q
>> and evaluating in *scratch*:
>>   (setq ispell-program-name "hunspell")
>>   (setq ispell-really-hunspell t)
>> after that I run 'M-$' while point is on first 's' of
>>   (message)

>> In minibuffer I see
>>   MESSAGE is correct

>> Without this patch the same steps lead to message
>>   ispell-phaf: No matching entry for nil.

> Hi,

> Cannot reproduce it here. By the way, once initialized for hunspell
> ispell.el provides a match for default (nil) value, here

> (nil [[:alpha:]] [^[:alpha:]] ['] nil (-B) nil utf-8)

Wouldn't you mind to share how you get this?

I tried hard to prepare minimal example to catch when the problem
appears but I know a very little of Emacs Lisp.

This is my investigation and results.

My system:
OS: Archlinux x86_64,
Emacs: compiled from trunk (rev. 115132), with original ispell.el
env. variables:
  DICTIONARY=russian
  LANG=ru_RU.UTF-8
  LC_CTYPE="ru_RU.UTF-8"
  LC_NUMERIC="ru_RU.UTF-8"
  LC_TIME="ru_RU.UTF-8"
  LC_COLLATE=C
  LC_MONETARY="ru_RU.UTF-8"
  LC_MESSAGES="ru_RU.UTF-8"
  LC_PAPER="ru_RU.UTF-8"
  LC_NAME="ru_RU.UTF-8"
  LC_ADDRESS="ru_RU.UTF-8"
  LC_TELEPHONE="ru_RU.UTF-8"
  LC_MEASUREMENT="ru_RU.UTF-8"
  LC_IDENTIFICATION="ru_RU.UTF-8"
  LC_ALL=
aspell: @(#) International Ispell Version 3.1.20 (but really Aspell 0.60.6.1)
hunspell: @(#) International Ispell Version 3.2.06 (but really Hunspell 1.3.2)

System has both Russian and English dictionaries.

I tested both aspell and hunspell variants. Emacs is started from rxvt
terminal as
  emacs -Q -l min-VARIANT.el
both min-VARIANT.el, VARIANT={a,hun}spell are attached (and also can be
found in repository https://bitbucket.org/vp1981/issues,
https://bitbucket.org/vp1981/issues/src/452f8c393983a875cb46e96d9c9b5d42cb5e1dc7/emacs/ispell/?at=default)

Then I open one of three test files VARIANT-exN.el, (N=,2,3) and
evaluate commands. The only difference between test files is that
- VARIANT-ex.el:  dictionary is not set explicitly,
- VARIANT-ex2.el: dictionary is set to string 'english',
- VARIANT-ex3.el: dictionary is set to nil,

The rest of test files are the same:
1. output values of several variables: ispell-VARIANT-dictionary-alist,
   ispell-dictionary and ispell-{local,current}-dictionary;
2. run 'ispell-word';
3. output values of the same variables;
4. run 'ispell-word' again;
5. output values of the same variables.

Results are shown in table

         \  |      aspell       |     hunspell
Test file \ | 1 | 2 | 3 | 4 | 5 | 1 | 2 | 3 | 4 | 5 |
------------+---+---+---+---+---+---+---+---+---+---+
   ex.el    | n | - | + | - | + | n |e11| + |e12| + |
  ex2.el    | n |+n | + |+n | + | n |e11| + |e2 | + |
  ex3.el    | n | - | + | - | + | n |e11| + |e12| + |

Here:
n:   means 'nil' (return value);
+n:  means successful run and nil is returned;
+:   means successful run;
-:   means 'ispell-word' was run but seems can't find word "message" in
     a dictionary (may be it didn't use any);
e1*: 'ispell-phaf' error (No matching entry for nil);
     difference between e11 and e12 is that first calls 'find-dictionaries'
     while second one calls 'fill-dictionary-entry';
e2:  Lisp error, (No data for dictionary \"english\"...)

Reports (backtrace) from Debugger are attached.

What I expect in all cases:
if either dictionary set to a valid string, to nil or doesn't set at
all, call of 'ispell-word' (or M-$) should give result, may be zero
one but not an error.

These test files show (on my system) some problem with ispell. Of course
I could be wrong and do something unusual but I tried to minimize any
side-effects of my /real/ Emacs configuration.

If I apply patch proposed in first message and run tests again (only
hunspell part) then all three test files would give positive results
(evaluating 'ispell-word' function gives nil, M-$ gives message in
minibuffer "MESSAGE is correct").

P.S. Seems there might be a problem with aspell but here I want to clarify
issue with hunspell.

---
WBR, Vladimir Lomov

-- 
Churchill's Commentary on Man:
	Man will occasionally stumble over the truth,
	but most of the time he will pick himself up and continue on.

[-- Attachment #2: hunspell-ex.el --]
[-- Type: text/plain, Size: 1370 bytes --]

;;;
;; Show default values for several variables, even if they are not defined before first call to 'ispell-word'
;;;
(when (boundp 'ispell-hunspell-dictionary-alist)
  (progn
    (message "Default dictionary [%s]" ispell-dictionary)
    (message "Local dictionary [%s]" ispell-local-dictionary)
    (message "Current dictionary [%s]" ispell-current-dictionary)
    (prin1 "ispell-hunspell-dictionary-alist:")
    (prin1 ispell-hunspell-dictionary-alist)
  )
)

;;;
;; The call of 'ispell-word' runs several routines that populate several variables, especially '-dictionary-alist'.
;;;
(ispell-word "message")

;;;
;; Now output the same variables as above. They must have values.
;;;
(progn
  (message "Default dictionary [%s]" ispell-dictionary)
  (message "Local dictionary [%s]" ispell-local-dictionary)
  (message "Current dictionary [%s]" ispell-current-dictionary)
  (prin1 "ispell-hunspell-dictionary-alist:")
  (prin1 ispell-hunspell-dictionary-alist)
)

;;;
;; Second run of 'ispell-word'.
;;;
(ispell-word "message")

;;;
;; After second run variables might have other values.
;;;
(progn
  (message "Default dictionary [%s]" ispell-dictionary)
  (message "Local dictionary [%s]" ispell-local-dictionary)
  (message "Current dictionary [%s]" ispell-current-dictionary)
  (prin1 "ispell-hunspell-dictionary-alist:")
  (prin1 ispell-hunspell-dictionary-alist)
)

[-- Attachment #3: hunspell-ex2.el --]
[-- Type: text/plain, Size: 1442 bytes --]

;;;
;; Set (default) dictionary
;;;
(setq ispell-dictionary "english")

;;;
;; Show default values for several variables, even if they are not defined before first call to 'ispell-word'
;;;
(when (boundp 'ispell-hunspell-dictionary-alist)
  (progn
    (message "Default dictionary [%s]" ispell-dictionary)
    (message "Local dictionary [%s]" ispell-local-dictionary)
    (message "Current dictionary [%s]" ispell-current-dictionary)
    (prin1 "ispell-hunspell-dictionary-alist:")
    (prin1 ispell-hunspell-dictionary-alist)
  )
)

;;;
;; The call of 'ispell-word' runs several routines that populate several variables, especially '-dictionary-alist'.
;;;
(ispell-word "message")

;;;
;; Now output the same variables as above. They must have values.
;;;
(progn
  (message "Default dictionary [%s]" ispell-dictionary)
  (message "Local dictionary [%s]" ispell-local-dictionary)
  (message "Current dictionary [%s]" ispell-current-dictionary)
  (prin1 "ispell-hunspell-dictionary-alist:")
  (prin1 ispell-hunspell-dictionary-alist)
)

;;;
;; Second run of 'ispell-word'.
;;;
(ispell-word "message")

;;;
;; After second run variables might have other values.
;;;
(progn
  (message "Default dictionary [%s]" ispell-dictionary)
  (message "Local dictionary [%s]" ispell-local-dictionary)
  (message "Current dictionary [%s]" ispell-current-dictionary)
  (prin1 "ispell-hunspell-dictionary-alist:")
  (prin1 ispell-hunspell-dictionary-alist)
)

[-- Attachment #4: hunspell-ex3.el --]
[-- Type: text/plain, Size: 1436 bytes --]

;;;
;; Set (default) dictionary
;;;
(setq ispell-dictionary nil)

;;;
;; Show default values for several variables, even if they are not defined before first call to 'ispell-word'
;;;
(when (boundp 'ispell-hunspell-dictionary-alist)
  (progn
    (message "Default dictionary [%s]" ispell-dictionary)
    (message "Local dictionary [%s]" ispell-local-dictionary)
    (message "Current dictionary [%s]" ispell-current-dictionary)
    (prin1 "ispell-hunspell-dictionary-alist:")
    (prin1 ispell-hunspell-dictionary-alist)
  )
)

;;;
;; The call of 'ispell-word' runs several routines that populate several variables, especially '-dictionary-alist'.
;;;
(ispell-word "message")

;;;
;; Now output the same variables as above. They must have values.
;;;
(progn
  (message "Default dictionary [%s]" ispell-dictionary)
  (message "Local dictionary [%s]" ispell-local-dictionary)
  (message "Current dictionary [%s]" ispell-current-dictionary)
  (prin1 "ispell-hunspell-dictionary-alist:")
  (prin1 ispell-hunspell-dictionary-alist)
)

;;;
;; Second run of 'ispell-word'.
;;;
(ispell-word "message")

;;;
;; After second run variables might have other values.
;;;
(progn
  (message "Default dictionary [%s]" ispell-dictionary)
  (message "Local dictionary [%s]" ispell-local-dictionary)
  (message "Current dictionary [%s]" ispell-current-dictionary)
  (prin1 "ispell-hunspell-dictionary-alist:")
  (prin1 ispell-hunspell-dictionary-alist)
)

[-- Attachment #5: aspell-ex3.el --]
[-- Type: text/plain, Size: 1401 bytes --]

;;;
;; Set (default) dictionary
;;;
(setq ispell-dictionary nil)

;;;
;; Show default values for several variables, even if they are not defined before first call to 'ispell-word'
;;;
(when (boundp 'ispell-aspell-dictionary-alist)
  (progn
    (message "Default dictionary [%s]" ispell-dictionary)
    (message "Local dictionary [%s]" ispell-local-dictionary)
    (message "Current dictionary [%s]" ispell-current-dictionary)
    (prin1 "aspell-dictionary-alist:")
    (prin1 ispell-aspell-dictionary-alist)
  )
)

;;;
;; The call of 'ispell-word' runs several routines that populate several variables, especially '-dictionary-alist'.
;;;
(ispell-word "message")

;;;
;; Now output the same variables as above. They must have values.
;;;
(progn
  (message "Default dictionary [%s]" ispell-dictionary)
  (message "Local dictionary [%s]" ispell-local-dictionary)
  (message "Current dictionary [%s]" ispell-current-dictionary)
  (prin1 "aspell-dictionary-alist:")
  (prin1 ispell-aspell-dictionary-alist)
)

;;;
;; Second run of 'ispell-word'.
;;;
(ispell-word "message")

;;;
;; After second run variables might have other values.
;;;
(progn
  (message "Default dictionary [%s]" ispell-dictionary)
  (message "Local dictionary [%s]" ispell-local-dictionary)
  (message "Current dictionary [%s]" ispell-current-dictionary)
  (prin1 "aspell-dictionary-alist:")
  (prin1 ispell-aspell-dictionary-alist)
)

[-- Attachment #6: aspell-ex2.el --]
[-- Type: text/plain, Size: 1407 bytes --]

;;;
;; Set (default) dictionary
;;;
(setq ispell-dictionary "english")

;;;
;; Show default values for several variables, even if they are not defined before first call to 'ispell-word'
;;;
(when (boundp 'ispell-aspell-dictionary-alist)
  (progn
    (message "Default dictionary [%s]" ispell-dictionary)
    (message "Local dictionary [%s]" ispell-local-dictionary)
    (message "Current dictionary [%s]" ispell-current-dictionary)
    (prin1 "aspell-dictionary-alist:")
    (prin1 ispell-aspell-dictionary-alist)
  )
)

;;;
;; The call of 'ispell-word' runs several routines that populate several variables, especially '-dictionary-alist'.
;;;
(ispell-word "message")

;;;
;; Now output the same variables as above. They must have values.
;;;
(progn
  (message "Default dictionary [%s]" ispell-dictionary)
  (message "Local dictionary [%s]" ispell-local-dictionary)
  (message "Current dictionary [%s]" ispell-current-dictionary)
  (prin1 "aspell-dictionary-alist:")
  (prin1 ispell-aspell-dictionary-alist)
)

;;;
;; Second run of 'ispell-word'.
;;;
(ispell-word "message")

;;;
;; After second run variables might have other values.
;;;
(progn
  (message "Default dictionary [%s]" ispell-dictionary)
  (message "Local dictionary [%s]" ispell-local-dictionary)
  (message "Current dictionary [%s]" ispell-current-dictionary)
  (prin1 "aspell-dictionary-alist:")
  (prin1 ispell-aspell-dictionary-alist)
)

[-- Attachment #7: aspell-ex3.el --]
[-- Type: text/plain, Size: 1401 bytes --]

;;;
;; Set (default) dictionary
;;;
(setq ispell-dictionary nil)

;;;
;; Show default values for several variables, even if they are not defined before first call to 'ispell-word'
;;;
(when (boundp 'ispell-aspell-dictionary-alist)
  (progn
    (message "Default dictionary [%s]" ispell-dictionary)
    (message "Local dictionary [%s]" ispell-local-dictionary)
    (message "Current dictionary [%s]" ispell-current-dictionary)
    (prin1 "aspell-dictionary-alist:")
    (prin1 ispell-aspell-dictionary-alist)
  )
)

;;;
;; The call of 'ispell-word' runs several routines that populate several variables, especially '-dictionary-alist'.
;;;
(ispell-word "message")

;;;
;; Now output the same variables as above. They must have values.
;;;
(progn
  (message "Default dictionary [%s]" ispell-dictionary)
  (message "Local dictionary [%s]" ispell-local-dictionary)
  (message "Current dictionary [%s]" ispell-current-dictionary)
  (prin1 "aspell-dictionary-alist:")
  (prin1 ispell-aspell-dictionary-alist)
)

;;;
;; Second run of 'ispell-word'.
;;;
(ispell-word "message")

;;;
;; After second run variables might have other values.
;;;
(progn
  (message "Default dictionary [%s]" ispell-dictionary)
  (message "Local dictionary [%s]" ispell-local-dictionary)
  (message "Current dictionary [%s]" ispell-current-dictionary)
  (prin1 "aspell-dictionary-alist:")
  (prin1 ispell-aspell-dictionary-alist)
)

[-- Attachment #8: min-hunspell.el --]
[-- Type: text/plain, Size: 176 bytes --]

(setq ispell-program-name "hunspell")
(setq ispell-really-hunspell t)
;; (setq ispell-dictionary "english")
;; (setq ispell-local-dictionary "english")
(setq debug-on-error t)

[-- Attachment #9: min-aspell.el --]
[-- Type: text/plain, Size: 172 bytes --]

(setq ispell-program-name "aspell")
(setq ispell-really-aspell t)
;; (setq ispell-dictionary "english")
;; (setq ispell-local-dictionary "english")
(setq debug-on-error t)

[-- Attachment #10: hunspell-ex-step2.txt --]
[-- Type: text/plain, Size: 498 bytes --]

Debugger entered--Lisp error: (error "ispell-phaf: No matching entry for nil.
")
  signal(error ("ispell-phaf: No matching entry for nil.\n"))
  error("ispell-phaf: No matching entry for %s.\n" nil)
  ispell-parse-hunspell-affix-file(nil)
  ispell-find-hunspell-dictionaries()
  ispell-set-spellchecker-params()
  ispell-word("message")
  eval((ispell-word "message") nil)
  eval-last-sexp-1(nil)
  eval-last-sexp(nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)

[-- Attachment #11: hunspell-ex-step4.txt --]
[-- Type: text/plain, Size: 585 bytes --]

Debugger entered--Lisp error: (error "ispell-phaf: No matching entry for nil.
")
  signal(error ("ispell-phaf: No matching entry for nil.\n"))
  error("ispell-phaf: No matching entry for %s.\n" nil)
  ispell-parse-hunspell-affix-file(nil)
  ispell-hunspell-fill-dictionary-entry(nil)
  ispell-start-process()
  ispell-init-process()
  ispell-buffer-local-words()
  ispell-accept-buffer-local-defs()
  ispell-word("message")
  eval((ispell-word "message") nil)
  eval-last-sexp-1(nil)
  eval-last-sexp(nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)

[-- Attachment #12: hunspell-ex2-step2.txt --]
[-- Type: text/plain, Size: 498 bytes --]

Debugger entered--Lisp error: (error "ispell-phaf: No matching entry for nil.
")
  signal(error ("ispell-phaf: No matching entry for nil.\n"))
  error("ispell-phaf: No matching entry for %s.\n" nil)
  ispell-parse-hunspell-affix-file(nil)
  ispell-find-hunspell-dictionaries()
  ispell-set-spellchecker-params()
  ispell-word("message")
  eval((ispell-word "message") nil)
  eval-last-sexp-1(nil)
  eval-last-sexp(nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)

[-- Attachment #13: hunspell-ex2-step4.txt --]
[-- Type: text/plain, Size: 683 bytes --]

Debugger entered--Lisp error: (error "No data for dictionary \"english\", neither in `ispell-local-dictionary-alist' nor in `ispell-dictionary-alist'")
  signal(error ("No data for dictionary \"english\", neither in `ispell-local-dictionary-alist' nor in `ispell-dictionary-alist'"))
  error("No data for dictionary \"%s\", neither in `ispell-local-dictionary-alist' nor in `ispell-dictionary-alist'" "english")
  ispell-get-decoded-string(1)
  ispell-get-casechars()
  ispell-get-word("message")
  ispell-word("message")
  eval((ispell-word "message") nil)
  eval-last-sexp-1(nil)
  eval-last-sexp(nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)

[-- Attachment #14: hunspell-ex3-step2.txt --]
[-- Type: text/plain, Size: 498 bytes --]

Debugger entered--Lisp error: (error "ispell-phaf: No matching entry for nil.
")
  signal(error ("ispell-phaf: No matching entry for nil.\n"))
  error("ispell-phaf: No matching entry for %s.\n" nil)
  ispell-parse-hunspell-affix-file(nil)
  ispell-find-hunspell-dictionaries()
  ispell-set-spellchecker-params()
  ispell-word("message")
  eval((ispell-word "message") nil)
  eval-last-sexp-1(nil)
  eval-last-sexp(nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)

[-- Attachment #15: hunspell-ex3-step4.txt --]
[-- Type: text/plain, Size: 585 bytes --]

Debugger entered--Lisp error: (error "ispell-phaf: No matching entry for nil.
")
  signal(error ("ispell-phaf: No matching entry for nil.\n"))
  error("ispell-phaf: No matching entry for %s.\n" nil)
  ispell-parse-hunspell-affix-file(nil)
  ispell-hunspell-fill-dictionary-entry(nil)
  ispell-start-process()
  ispell-init-process()
  ispell-buffer-local-words()
  ispell-accept-buffer-local-defs()
  ispell-word("message")
  eval((ispell-word "message") nil)
  eval-last-sexp-1(nil)
  eval-last-sexp(nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)

  reply	other threads:[~2013-11-18  6:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-15 15:16 bug#15903: 24.3.50; Fix small issue with ispell-hunspell when dictionary is set to default (nil) Vladimir Lomov
2013-11-15 17:00 ` bug#15904: " Glenn Morris
2013-11-16 11:43 ` bug#15903: " Agustin Martin
2013-11-18  6:33   ` Vladimir Lomov [this message]
2013-11-18 12:11     ` Agustin Martin
2013-11-18 12:48       ` Vladimir Lomov
2013-11-19 10:29         ` Agustin Martin
2013-11-19 12:08           ` Vladimir Lomov
2013-11-19 13:43             ` Agustin Martin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131118063300.GB889@smoon \
    --to=lomov.vl@gmail.com \
    --cc=15903@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.