From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Kisaragi Hiu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#49982: 27.2; ispell.el fails to find a Hunspell dictionary to use as default despite ispell-dictionary being set Date: Wed, 11 Aug 2021 03:51:22 +0900 Message-ID: <54d5e013-aeff-ef7b-ad9e-e4c8dfa72d37@kisaragi-hiu.com> References: <59517c95-6568-f646-7097-c601cc9657c9@kisaragi-hiu.com> <83h7fxfft0.fsf@gnu.org> Reply-To: Kisaragi Hiu Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31627"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 49982@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Aug 10 20:52:20 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mDWrK-0007wC-Ru for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 10 Aug 2021 20:52:19 +0200 Original-Received: from localhost ([::1]:39316 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mDWrJ-00025Q-1J for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 10 Aug 2021 14:52:17 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60896) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mDWr4-00025E-7w for bug-gnu-emacs@gnu.org; Tue, 10 Aug 2021 14:52:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49286) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mDWr3-00048t-SG for bug-gnu-emacs@gnu.org; Tue, 10 Aug 2021 14:52:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mDWr3-0005MR-Lm for bug-gnu-emacs@gnu.org; Tue, 10 Aug 2021 14:52:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Kisaragi Hiu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 10 Aug 2021 18:52:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49982 X-GNU-PR-Package: emacs Original-Received: via spool by 49982-submit@debbugs.gnu.org id=B49982.162862150020579 (code B ref 49982); Tue, 10 Aug 2021 18:52:01 +0000 Original-Received: (at 49982) by debbugs.gnu.org; 10 Aug 2021 18:51:40 +0000 Original-Received: from localhost ([127.0.0.1]:60832 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mDWqd-0005Lm-Gd for submit@debbugs.gnu.org; Tue, 10 Aug 2021 14:51:39 -0400 Original-Received: from out0.migadu.com ([94.23.1.103]:17437) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mDWqW-0005LY-9i for 49982@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== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. In-Reply-To: <83h7fxfft0.fsf@gnu.org> Content-Language: en-US X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: mail@kisaragi-hiu.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:211536 Archived-At: 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" (「また、必要に応じて環境変数DICTIONARYやWORDLISTを指定しておきます。」) - [[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.