GNU logs - #49982, boring messages


Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#49982: 27.2; ispell.el fails to find a Hunspell dictionary to use as default despite ispell-dictionary being set
Resent-From: Kisaragi Hiu <mail@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Tue, 10 Aug 2021 15:13:01 +0000
Resent-Message-ID: <handler.49982.B.162860834729717 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 49982
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 49982 <at> debbugs.gnu.org
X-Debbugs-Original-To: bug-gnu-emacs@HIDDEN
Received: via spool by submit <at> debbugs.gnu.org id=B.162860834729717
          (code B ref -1); Tue, 10 Aug 2021 15:13:01 +0000
Received: (at submit) by debbugs.gnu.org; 10 Aug 2021 15:12:27 +0000
Received: from localhost ([127.0.0.1]:60436 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mDTQV-0007jC-IH
	for submit <at> debbugs.gnu.org; Tue, 10 Aug 2021 11:12:27 -0400
Received: from lists.gnu.org ([209.51.188.17]:34416)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mail@HIDDEN>) id 1mDTQQ-0007j0-U4
 for submit <at> debbugs.gnu.org; Tue, 10 Aug 2021 11:12:22 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:39208)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <mail@HIDDEN>)
 id 1mDTQQ-00048V-NW
 for bug-gnu-emacs@HIDDEN; Tue, 10 Aug 2021 11:12:18 -0400
Received: from out0.migadu.com ([2001:41d0:2:267::]:12859)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <mail@HIDDEN>)
 id 1mDTQM-00059E-V3
 for bug-gnu-emacs@HIDDEN; Tue, 10 Aug 2021 11:12:18 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kisaragi-hiu.com;
 s=key1; t=1628608330;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:mime-version:mime-version:content-type:content-type:
 content-transfer-encoding:content-transfer-encoding;
 bh=jOx8Yxys/V1bAfoGIM+G/tc+H93rU52iMITzwjsNbzg=;
 b=3qhoeRWUhnLuLq4QzPz3Rc1x4hv6Ejh41whoLZDqKtKQS44flBPtqD/Voqik8Elz4GUXAF
 14SXkm7J7txdEwp5Whlz+bbafqK66CEp8MbgqrGhB86cFiEPCa5jM6JrAEsVhGpOCkx7tn
 S8YymQ3FDvGHrtf6qzUE9dbcMu0N/PEezIlAwEcVO9mX8CtL2+VBwrop2Gfi28eAVjWNzn
 TR97STWTACs/+5Uo/GsIfWyC1HnpedYrgRvm3b0HU+P/wb5yrFfvcLlhvR5hhrK8QSsNYM
 PRAfiW0ydaWQlun7M0s3qjtZEd+EZkgGgHhHuE9POyeH1rUNz/58sRXpEbSddA==
X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and
 include these headers.
From: Kisaragi Hiu <mail@HIDDEN>
Message-ID: <59517c95-6568-f646-7097-c601cc9657c9@HIDDEN>
Date: Wed, 11 Aug 2021 00:12:06 +0900
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Migadu-Flow: FLOW_OUT
X-Migadu-Auth-User: mail@HIDDEN
Received-SPF: pass client-ip=2001:41d0:2:267::;
 envelope-from=mail@HIDDEN; helo=out0.migadu.com
X-Spam_score_int: -27
X-Spam_score: -2.8
X-Spam_bar: --
X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.4 (-)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.4 (--)

This configuration should be everything that's needed for ispell.el to
work with Hunspell, regardless of system locale:

     (setq ispell-program-name (executable-find "hunspell")
           ispell-dictionary "en_US"))

However, when system locale (the LANG environment variable) does not 
have a corresponding Hunspell dictionary, 
`ispell-find-hunspell-dictionaries` returns the error "Can't find 
Hunspell dictionary with a .aff affix file", despite ispell-dictionary 
being set.

ispell.el relies on Hunspell to load a default and report it, but
Hunspell just errors out if it can't find a dictionary for the system
locale. And because ispell.el is trying to get Hunspell's default
dictionary, it doesn't pass `ispell-dictionary' onto Hunspell.

This behavior is surprising. If `ispell-dictionary` is non-nil, that
means the user has already specified their preferred dictionary, and it
should not matter that Hunspell cannot find the dictionary it would use
when a preferred dictionary isn't specified.

It's ispell.el that needs to be fixed here because the user specifies
their preference in Emacs, and it is its job to communicate that
preference to Hunspell.

`ispell-find-hunspell-dictionaries` should pass "-d
${ispell-dictionary}" to Hunspell if `ispell-dictionary` is set. This 
invocation:

     hunspell -d "en_US" -D /dev/null

works as expected regardless of the system locale.

* System info

In GNU Emacs 27.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.27,
  cairo version 1.17.4) of 2021-03-27 built on juergen Windowing system
  distributor 'The X.Org Foundation', version 11.0.12013000 System
  Description: Arch Linux

Hunspell 1.7.0; hunspell -D is

     SEARCH PATH:
 
.::/usr/share/hunspell:/usr/share/myspell:/usr/share/myspell/dicts:/Library/Spelling:/home/kisaragi-hiu/.openoffice.org/3/user/wordbook:/home/kisaragi-hiu/.openoffice.org2/user/wordbook:/home/kisaragi-hiu/.openoffice.org2.0/user/wordbook:/home/kisaragi-hiu/Library/Spelling:/opt/openoffice.org/basis3.0/share/dict/ooo:/usr/lib/openoffice.org/basis3.0/share/dict/ooo:/opt/openoffice.org2.4/share/dict/ooo:/usr/lib/openoffice.org2.4/share/dict/ooo:/opt/openoffice.org2.3/share/dict/ooo:/usr/lib/openoffice.org2.3/share/dict/ooo:/opt/openoffice.org2.2/share/dict/ooo:/usr/lib/openoffice.org2.2/share/dict/ooo:/opt/openoffice.org2.1/share/dict/ooo:/usr/lib/openoffice.org2.1/share/dict/ooo:/opt/openoffice.org2.0/share/dict/ooo:/usr/lib/openoffice.org2.0/share/dict/ooo
     AVAILABLE DICTIONARIES (path is not mandatory for -d option):
     ... [truncated]
     /usr/share/hunspell/en_US-large
     ... [truncated]

* Reproduction

- Notice how Hunspell does not return LOADED DICTIONARY under, for 
example, ja_JP:

     export LANG=ja_JP
     hunspell -D /dev/null
     # Output:
     # ... [truncated]
     # Can't open affix or dictionary files for dictionary named "ja_JP".

- Now, in Emacs with LANG set to ja_JP, set ispell up with Hunspell as 
usual.

     (setq ispell-program-name (executable-find "hunspell")
           ispell-dictionary "en_US"))

- Observe the error.

     (ispell-start-process)
     ;; -> ispell-find-hunspell-dictionaries: Can’t find Hunspell 
dictionary with a .aff affix file




Message sent:


Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
Content-Type: text/plain; charset=utf-8
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: Kisaragi Hiu <mail@HIDDEN>
Subject: bug#49982: Acknowledgement (27.2; ispell.el fails to find a
 Hunspell dictionary to use as default despite ispell-dictionary being set)
Message-ID: <handler.49982.B.162860834729717.ack <at> debbugs.gnu.org>
References: <59517c95-6568-f646-7097-c601cc9657c9@HIDDEN>
X-Gnu-PR-Message: ack 49982
X-Gnu-PR-Package: emacs
Reply-To: 49982 <at> debbugs.gnu.org
Date: Tue, 10 Aug 2021 15:13:02 +0000

Thank you for filing a new bug report with debbugs.gnu.org.

This is an automatically generated reply to let you know your message
has been received.

Your message is being forwarded to the package maintainers and other
interested parties for their attention; they will reply in due course.

Your message has been sent to the package maintainer(s):
 bug-gnu-emacs@HIDDEN

If you wish to submit further information on this problem, please
send it to 49982 <at> debbugs.gnu.org.

Please do not send mail to help-debbugs@HIDDEN unless you wish
to report a problem with the Bug-tracking system.

--=20
49982: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D49982
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems


Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#49982: 27.2; ispell.el fails to find a Hunspell dictionary to use as default despite ispell-dictionary being set
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Tue, 10 Aug 2021 16:04:02 +0000
Resent-Message-ID: <handler.49982.B49982.162861139711055 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 49982
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Kisaragi Hiu <mail@HIDDEN>
Cc: 49982 <at> debbugs.gnu.org
Received: via spool by 49982-submit <at> debbugs.gnu.org id=B49982.162861139711055
          (code B ref 49982); Tue, 10 Aug 2021 16:04:02 +0000
Received: (at 49982) by debbugs.gnu.org; 10 Aug 2021 16:03:17 +0000
Received: from localhost ([127.0.0.1]:60548 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mDUDl-0002sE-40
	for submit <at> debbugs.gnu.org; Tue, 10 Aug 2021 12:03:17 -0400
Received: from eggs.gnu.org ([209.51.188.92]:42420)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1mDUDg-0002rx-5Q
 for 49982 <at> debbugs.gnu.org; Tue, 10 Aug 2021 12:03:16 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:55186)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1mDUDZ-0000PN-Ly; Tue, 10 Aug 2021 12:03:05 -0400
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:2122
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1mDUDR-00006t-Sz; Tue, 10 Aug 2021 12:03:05 -0400
Date: Tue, 10 Aug 2021 19:03:07 +0300
Message-Id: <83h7fxfft0.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <59517c95-6568-f646-7097-c601cc9657c9@HIDDEN>
 (bug-gnu-emacs@HIDDEN)
References: <59517c95-6568-f646-7097-c601cc9657c9@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Date: Wed, 11 Aug 2021 00:12:06 +0900
> From:  Kisaragi Hiu via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
> 
> This configuration should be everything that's needed for ispell.el to
> work with Hunspell, regardless of system locale:
> 
>      (setq ispell-program-name (executable-find "hunspell")
>            ispell-dictionary "en_US"))
> 
> However, when system locale (the LANG environment variable) does not 
> have a corresponding Hunspell dictionary, 
> `ispell-find-hunspell-dictionaries` returns the error "Can't find 
> Hunspell dictionary with a .aff affix file", despite ispell-dictionary 
> being set.
> 
> ispell.el relies on Hunspell to load a default and report it, but
> Hunspell just errors out if it can't find a dictionary for the system
> locale. And because ispell.el is trying to get Hunspell's default
> dictionary, it doesn't pass `ispell-dictionary' onto Hunspell.
> 
> This behavior is surprising. If `ispell-dictionary` is non-nil, that
> means the user has already specified their preferred dictionary, and it
> should not matter that Hunspell cannot find the dictionary it would use
> when a preferred dictionary isn't specified.
> 
> It's ispell.el that needs to be fixed here because the user specifies
> their preference in Emacs, and it is its job to communicate that
> preference to Hunspell.
> 
> `ispell-find-hunspell-dictionaries` should pass "-d
> ${ispell-dictionary}" to Hunspell if `ispell-dictionary` is set. This 
> invocation:
> 
>      hunspell -d "en_US" -D /dev/null
> 
> works as expected regardless of the system locale.

Thanks for the report and the analysis.

Frankly, I'm a bit wary of making the proposed change unconditionally.
First, yours is an unusual use case, I think: when Hunspell is
installed, the dictionary that corresponds to the locale is always
installed, because otherwise Hunspell will not work reliably from the
shell command line.  And second, relying on the non-nil value of
ispell-dictionary is fragile: the value could be a remnant from some
previous invocation or from an unsuccessful customization that has
nothing to do with the user's choice or his/her current intent.

Moreover, if you manually set ispell-dictionary, then what would be
the purpose of calling ispell-find-hunspell-dictionaries at all?

So maybe we should add a new user option that would force using the
value of ispell-dictionary right from the start.  That would at least
avoid the risk of breaking somebody else's use case.

I wonder if anyone else has an opinion about this.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#49982: 27.2; ispell.el fails to find a Hunspell dictionary to use as default despite ispell-dictionary being set
Resent-From: Kisaragi Hiu <mail@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Tue, 10 Aug 2021 18:52:01 +0000
Resent-Message-ID: <handler.49982.B49982.162862150020579 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 49982
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eli Zaretskii <eliz@HIDDEN>
Cc: 49982 <at> debbugs.gnu.org
Received: via spool by 49982-submit <at> debbugs.gnu.org id=B49982.162862150020579
          (code B ref 49982); Tue, 10 Aug 2021 18:52:01 +0000
Received: (at 49982) by debbugs.gnu.org; 10 Aug 2021 18:51:40 +0000
Received: from localhost ([127.0.0.1]:60832 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mDWqd-0005Lm-Gd
	for submit <at> debbugs.gnu.org; Tue, 10 Aug 2021 14:51:39 -0400
Received: from out0.migadu.com ([94.23.1.103]:17437)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mail@HIDDEN>) id 1mDWqW-0005LY-9i
 for 49982 <at> debbugs.gnu.org; Tue, 10 Aug 2021 14:51:33 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kisaragi-hiu.com;
 s=key1; t=1628621486;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:content-type:content-type:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=0bxGdJnc1BlDOvK1EN0lIN96qvWiuFn2Pg5V6PNhuaw=;
 b=eNuJlUDfpntYo0/6aOT5i8AA+JKxq0ff3H+L+oehtCeMH93WZdYbcuzsFLL299FbgbbtOK
 BEJqN39PZECJI0WapgCHAAV9Tl5rPlSM6s7gq+aWeaNCIjg5xeI0EvRj9NxJFtfhmOOO7x
 FKE9HnNxJd/VqWjdY4WqU5gLbK/0328nw2BQUMLElLkA/DDaSJz7GsXg7ydzvP6m4m32D/
 alXidj9EvzDKSMQQaAa2Oh19YXf03xzVXfzpJsrSyP5XHQrB8Y8eStnhcLKA6J9NQbAHEV
 8xQBLjrOwvYj/pg33FxVYbhlnUPHnzBnhJOYuADalO/03fC4nkLh+SkHiPaLTA==
References: <59517c95-6568-f646-7097-c601cc9657c9@HIDDEN>
 <83h7fxfft0.fsf@HIDDEN>
X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and
 include these headers.
From: Kisaragi Hiu <mail@HIDDEN>
Message-ID: <54d5e013-aeff-ef7b-ad9e-e4c8dfa72d37@HIDDEN>
Date: Wed, 11 Aug 2021 03:51:22 +0900
MIME-Version: 1.0
In-Reply-To: <83h7fxfft0.fsf@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 8bit
X-Migadu-Flow: FLOW_OUT
X-Migadu-Auth-User: mail@HIDDEN
X-Spam-Score: -0.7 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

Thank you for the response! Let me try to add some clarifications (that 
hopefully don't sound too harsh):

 > First, yours is an unusual use case, I think: when Hunspell is
 > installed, the dictionary that corresponds to the locale is always
 > installed, because otherwise Hunspell will not work reliably from the
 > shell command line.

I'm fairly certain my use case isn't unusual.

There are no easily installable Hunspell dictionaries for, among other 
languages:

- Any variant of Chinese (Mandarin)
- Japanese
- Kazakh
- Khmer
- Malay

Every user of any of these languages who tries to set up Hunspell
along with ispell.el and Flyspell has to find or invent a poorly
documented workaround.

- [[https://texwiki.texjp.org/?Hunspell][TeXJP (Japanese) mentions]] 
"add[ing] the DICTIONARY or WORDLIST environment variables if needed" 
(DICTIONARYWORDLIST)
- [[https://home.hirosaki-u.ac.jp/heroic-2020/1575/][Hirosaki University 
Information Technology Center PC lab's tutorial to spellchecking in 
Emacs]] sets DICTIONARY to en_US
- 200ok.ch (developer of Organice)'s 
[[https://200ok.ch/posts/2020-08-22_setting_up_spell_checking_with_multiple_dictionaries.html][tutorial 
for using multiple dictionaries for Hunspell + ispell.el]] mentions

     ;; Configure `LANG`, otherwise ispell.el cannot find a 'default
     ;; dictionary' even though multiple dictionaries will be configured
     ;; in next line.
     (setenv "LANG" "en_US.UTF-8")

- 
[[http://blog.binchen.org/posts/what-s-the-best-spell-check-set-up-in-emacs/][Chen 
Bin's blog post on setting up spell check]] uses this block:

     ;; 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_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)))

       ;; new variable `ispell-hunspell-dictionary-alist' is defined in 
Emacs
       ;; If it's nil, Emacs tries to automatically set up the dictionaries.
       (when (boundp 'ispell-hunspell-dictionary-alist)
         (setq ispell-hunspell-dictionary-alist 
ispell-local-dictionary-alist)))

   "Emacs tries to automatically set up the dictionaries" refers to
   ispell-set-spellchecker-params running 
ispell-find-hunspell-dictionaries after
   seeing that ispell-hunspell-dictionary-alist is nil.

My use case is not unusual. Fixing this bug would eliminate the need
for these workarounds.

(From the command line you just pass in -d yourself. Setting environment 
variables is also a native way of configuring programs in the CLI; in 
Emacs generally wrapper packages like ispell.el define user options 
instead of asking users to do `setenv` themselves.)

 > And second, relying on the non-nil value of
 > ispell-dictionary is fragile: the value could be a remnant from some
 > previous invocation or from an unsuccessful customization that has
 > nothing to do with the user's choice or his/her current intent.

ispell-dictionary is a user option, not an internal variable. Nothing
in ispell.el changes ispell-dictionary besides the command to help the
user change the preferred dictionary, `ispell-change-dictionary`, so
the value cannot be a remnant from a previous invocation.

Without doing anything, ispell-dictionary being nil signals to ispell.el to
use the spell checker's default, as evident from its Custom type:

     (defcustom ispell-dictionary nil
       "Default dictionary to use if `ispell-local-dictionary' is nil."
       :type '(choice string
                      (const :tag "default" nil))
       :group 'ispell)

In fact, the user can set ispell-dictionary in their init.el when 
they're using aspell and have it work as expected. That's why I consider 
this a bug.

 > Moreover, if you manually set ispell-dictionary, then what would be
 > the purpose of calling ispell-find-hunspell-dictionaries at all?

I don't call ispell-find-hunspell-dictionaries myself --- turning on 
flyspell eventually calls it.

The error actually occurs when flyspell-mode-on calls
ispell-set-spellchecker-params, which in turn calls
ispell-find-hunspell-dictionaries to set up internal variables.

This is how Chen Bin's workaround works: it sets
ispell-local-dictionary-alist first, then sets
ispell-hunspell-dictionary-alist to it, preventing
ispell-set-spellchecker-params from triggering the error.

ispell-find-hunspell-dictionaries in fact always returns nil, and is 
only usedfor side effects: setting up
- ispell-hunspell-dictionary-alist,
- ispell-hunspell-dict-paths-alist,
- and ispell-dicts-name2locale-equivs-alist.

I'd like to hear more perspectives on this as well.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#49982: 27.2; ispell.el fails to find a Hunspell dictionary to use as default despite ispell-dictionary being set
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Tue, 10 Aug 2021 19:30:02 +0000
Resent-Message-ID: <handler.49982.B49982.162862378923917 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 49982
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Kisaragi Hiu <mail@HIDDEN>
Cc: 49982 <at> debbugs.gnu.org
Received: via spool by 49982-submit <at> debbugs.gnu.org id=B49982.162862378923917
          (code B ref 49982); Tue, 10 Aug 2021 19:30:02 +0000
Received: (at 49982) by debbugs.gnu.org; 10 Aug 2021 19:29:49 +0000
Received: from localhost ([127.0.0.1]:60846 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mDXRY-0006Db-Us
	for submit <at> debbugs.gnu.org; Tue, 10 Aug 2021 15:29:49 -0400
Received: from eggs.gnu.org ([209.51.188.92]:56966)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1mDXRT-0006DH-QS
 for 49982 <at> debbugs.gnu.org; Tue, 10 Aug 2021 15:29:44 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:33674)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1mDXRO-0004kd-7x; Tue, 10 Aug 2021 15:29:34 -0400
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:2958
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1mDXRN-00015q-QV; Tue, 10 Aug 2021 15:29:34 -0400
Date: Tue, 10 Aug 2021 22:29:43 +0300
Message-Id: <834kbxf68o.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <54d5e013-aeff-ef7b-ad9e-e4c8dfa72d37@HIDDEN> (message
 from Kisaragi Hiu on Wed, 11 Aug 2021 03:51:22 +0900)
References: <59517c95-6568-f646-7097-c601cc9657c9@HIDDEN>
 <83h7fxfft0.fsf@HIDDEN>
 <54d5e013-aeff-ef7b-ad9e-e4c8dfa72d37@HIDDEN>
MIME-version: 1.0
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Kisaragi Hiu <mail@HIDDEN>
> Cc: 49982 <at> debbugs.gnu.org
> Date: Wed, 11 Aug 2021 03:51:22 +0900
> 
> Thank you for the response! Let me try to add some clarifications (that 
> hopefully don't sound too harsh):
> 
>  > First, yours is an unusual use case, I think: when Hunspell is
>  > installed, the dictionary that corresponds to the locale is always
>  > installed, because otherwise Hunspell will not work reliably from the
>  > shell command line.
> 
> I'm fairly certain my use case isn't unusual.
> 
> There are no easily installable Hunspell dictionaries for, among other 
> languages:
> 
> - Any variant of Chinese (Mandarin)
> - Japanese
> - Kazakh
> - Khmer
> - Malay
> 
> Every user of any of these languages who tries to set up Hunspell
> along with ispell.el and Flyspell has to find or invent a poorly
> documented workaround.
> 
> - [[https://texwiki.texjp.org/?Hunspell][TeXJP (Japanese) mentions]] 
> "add[ing] the DICTIONARY or WORDLIST environment variables if needed" 
> (DICTIONARYWORDLIST)
> - [[https://home.hirosaki-u.ac.jp/heroic-2020/1575/][Hirosaki University 
> Information Technology Center PC lab's tutorial to spellchecking in 
> Emacs]] sets DICTIONARY to en_US
> - 200ok.ch (developer of Organice)'s 
> [[https://200ok.ch/posts/2020-08-22_setting_up_spell_checking_with_multiple_dictionaries.html][tutorial 
> for using multiple dictionaries for Hunspell + ispell.el]] mentions

Indeed, defining DICTIONARY in the environment is the way to control
the default dictionary.  It is documented in the Hunspell's man page.
Why cannot it be the solution for when no Hunspell dictionary could be
found that matches the locale?  Using $DICTIONARY should solve your
problem both inside Emacs and outside it.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#49982: 27.2; ispell.el fails to find a Hunspell dictionary to use as default despite ispell-dictionary being set
Resent-From: Kisaragi Hiu <mail@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Wed, 11 Aug 2021 11:18:01 +0000
Resent-Message-ID: <handler.49982.B49982.16286806569988 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 49982
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eli Zaretskii <eliz@HIDDEN>
Cc: 49982 <at> debbugs.gnu.org
Received: via spool by 49982-submit <at> debbugs.gnu.org id=B49982.16286806569988
          (code B ref 49982); Wed, 11 Aug 2021 11:18:01 +0000
Received: (at 49982) by debbugs.gnu.org; 11 Aug 2021 11:17:36 +0000
Received: from localhost ([127.0.0.1]:33586 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mDmEm-0002Yt-IF
	for submit <at> debbugs.gnu.org; Wed, 11 Aug 2021 07:17:36 -0400
Received: from out2.migadu.com ([188.165.223.204]:29353)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mail@HIDDEN>) id 1mDmEg-0002UR-G6
 for 49982 <at> debbugs.gnu.org; Wed, 11 Aug 2021 07:17:31 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kisaragi-hiu.com;
 s=key1; t=1628680644;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:content-type:content-type:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=7WKkXF4wZ1bop/67Rq+6Mn/BzyLRSXavXpS3WWlLguI=;
 b=ZTBhry0T//IclLIdNqLS2VJUbJrfRWTrMkT0/i8jYr26Aw6GhWLQEBvr+lQR3vB53il1Hw
 zjQjfLevaDXLG4aX7NyaTVuU6I2mzK1ibyN/92CC1rx0NjaAragH0vZrqvv/ADKUvYCDSX
 AK7jmcGgvcAyy0wLukEhwo/lRANBvyXPsqxAO3Ptk+Zj5EBRTxRaCtvNZLf2Y8ffvcVMTw
 m4oLBZoskdWZEZ6vjbQ/6Zdtvur7Rz/zA1H+QrmFBLbWfgLdQu8m2MXKKDnvbnvDIWUv4j
 HeubxnGWQSd0JuNUuLBqaP00AZL5+C3heft6Qc5QG/tQFZHMKjjtM8LLpvbqiA==
References: <59517c95-6568-f646-7097-c601cc9657c9@HIDDEN>
 <83h7fxfft0.fsf@HIDDEN>
 <54d5e013-aeff-ef7b-ad9e-e4c8dfa72d37@HIDDEN>
 <834kbxf68o.fsf@HIDDEN>
X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and
 include these headers.
From: Kisaragi Hiu <mail@HIDDEN>
Message-ID: <da9be239-c0d9-0f1c-0a19-6f4d91a23e4b@HIDDEN>
Date: Wed, 11 Aug 2021 20:17:20 +0900
MIME-Version: 1.0
In-Reply-To: <834kbxf68o.fsf@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 8bit
X-Migadu-Flow: FLOW_OUT
X-Migadu-Auth-User: mail@HIDDEN
X-Spam-Score: -0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

 > Indeed, defining DICTIONARY in the environment is the way to control
the default dictionary.  It is documented in the Hunspell's man page.
Why cannot it be the solution for when no Hunspell dictionary could be
found that matches the locale?  Using $DICTIONARY should solve your
problem both inside Emacs and outside it.

I don't know, maybe I'm biased here. Hunspell has its quirks, but isn't 
it ispell.el's job to work around quirks in spellcheckers, and not the 
end user's? ispell.el worked around Hunspell 1.7's new output quirk. Why 
can't it work around this quirk?

*My* problem is already solved by using the workaround. The bug is that 
nobody should have to use the workaround.

Using environment variables to configure subprocesses is always 
something that a user can do, but, as you know, there's a reason why 
ispell.el exposes spellchecker options through Emacs user options.

Besides, which dictionary one specifies in `DICTIONARY` doesn't actually 
matter, it just needs to be one that exists, as it will be overridden by 
ispell-dictionary when ispell.el actually starts spellchecking. You can 
do (in emacs -Q):

     (setenv "LANG" "ja_JP") ; trigger the quirk
     (setenv "DICTIONARY" "en_US") ; tame ispell-find-hunspell-dictionaries
     (setq ispell-program (executable-find "hunspell")
           ispell-dictionary "en_GB")
     (flyspell-mode)

and see that it's spellchecking color to colour. (Try typing "color" 
then running M-x flyspell-auto-correct-previous-word)

---

ispell-dictionary is ispell.el's way of specifying the main dictionary. 
The manual:

 > Spell-checkers look up spelling in two dictionaries: the standard
dictionary and your personal dictionary.  The standard dictionary is
specified by the variable ispell-local-dictionary or, if that is
nil, by the variable ispell-dictionary.  If both are nil, the
spelling programs default dictionary is used.

The spelling program's default should only ever have an effect when both 
ispell-local-dictionary and ispell-dictionary is nil.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#49982: 27.2; ispell.el fails to find a Hunspell dictionary to use as default despite ispell-dictionary being set
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Wed, 11 Aug 2021 12:13:02 +0000
Resent-Message-ID: <handler.49982.B49982.16286839551018 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 49982
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Kisaragi Hiu <mail@HIDDEN>
Cc: 49982 <at> debbugs.gnu.org
Received: via spool by 49982-submit <at> debbugs.gnu.org id=B49982.16286839551018
          (code B ref 49982); Wed, 11 Aug 2021 12:13:02 +0000
Received: (at 49982) by debbugs.gnu.org; 11 Aug 2021 12:12:35 +0000
Received: from localhost ([127.0.0.1]:33722 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mDn63-0000GK-AT
	for submit <at> debbugs.gnu.org; Wed, 11 Aug 2021 08:12:35 -0400
Received: from eggs.gnu.org ([209.51.188.92]:46880)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1mDn62-0000G9-1a
 for 49982 <at> debbugs.gnu.org; Wed, 11 Aug 2021 08:12:34 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:56362)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1mDn5w-00073i-2a; Wed, 11 Aug 2021 08:12:28 -0400
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:4834
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1mDn5v-0005Ko-Lv; Wed, 11 Aug 2021 08:12:27 -0400
Date: Wed, 11 Aug 2021 15:12:40 +0300
Message-Id: <83r1f0dvt3.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <da9be239-c0d9-0f1c-0a19-6f4d91a23e4b@HIDDEN> (message
 from Kisaragi Hiu on Wed, 11 Aug 2021 20:17:20 +0900)
References: <59517c95-6568-f646-7097-c601cc9657c9@HIDDEN>
 <83h7fxfft0.fsf@HIDDEN>
 <54d5e013-aeff-ef7b-ad9e-e4c8dfa72d37@HIDDEN>
 <834kbxf68o.fsf@HIDDEN>
 <da9be239-c0d9-0f1c-0a19-6f4d91a23e4b@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Kisaragi Hiu <mail@HIDDEN>
> Cc: 49982 <at> debbugs.gnu.org
> Date: Wed, 11 Aug 2021 20:17:20 +0900
> 
>  > Indeed, defining DICTIONARY in the environment is the way to control
> the default dictionary.  It is documented in the Hunspell's man page.
> Why cannot it be the solution for when no Hunspell dictionary could be
> found that matches the locale?  Using $DICTIONARY should solve your
> problem both inside Emacs and outside it.
> 
> I don't know, maybe I'm biased here. Hunspell has its quirks, but isn't 
> it ispell.el's job to work around quirks in spellcheckers, and not the 
> end user's?

Not when the spell-checker is basically not configured correctly.

> ispell.el worked around Hunspell 1.7's new output quirk.

That was something users could do nothing on their end to solve.

> Using environment variables to configure subprocesses is always 
> something that a user can do, but, as you know, there's a reason why 
> ispell.el exposes spellchecker options through Emacs user options.

That's not what I meant.  I meant to suggest that you set DICTIONARY
in the init files of your interactive shell, so that it would allow
you to use Hunspell both inside Emacs (because Emacs inherits the
environment variables of its parent shell) and outside Emacs.  I
didn't mean to suggest that you (or others) should inject DICTIONARY
into the environment of the Hunspell sub-process by doing something in
Emacs, like setenv etc.

> Besides, which dictionary one specifies in `DICTIONARY` doesn't actually 
> matter, it just needs to be one that exists, as it will be overridden by 
> ispell-dictionary when ispell.el actually starts spellchecking.

It should be the dictionary you want to use by default.  In your case,
I assume it's en_US.





Last modified: Wed, 11 Aug 2021 12:15:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.