Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bug#990346: customization of ispell-dictionary in emacs: variable is void: default-dictionary

43 views
Skip to first unread message

Maxim Nikulin

unread,
Jun 26, 2021, 8:40:03 AM6/26/21
to
Package: dictionaries-common
Version: 1.28.4
Severity: normal

Debian stuff dealing with list of dictionaries available for Emacs
sometimes causes problems.

1. Some spell checker and dictionary should be installed,
e.g. aspell and aspell-en

2. Initial state: user has no customization related to ispell.
It can be simulated using

mkdir /tmp/emacs-bug
HOME=/tmp/emacs-bug emacs

Do not forget to remove /tmp/emacs/bug/.emacs before retries.

3. Try to customize ispell-dictionary when ispell package is not loaded
yet, e.g. (add HOME=... if necessary)

emacs --eval "(customize-option 'ispell-dictionary)"

4. Set some string value, e.g "en_US" and try to save for future
sessions.

*Actual result*:

custom-push-theme: Symbol’s value as variable is void:
default-dictionary

Expected result: customization is saved to ~/.emacs
(or ~/.emacs.d/init.el, etc.)

Workaround for this case:

M-: (require 'ispell) RET

and save for future sessions again.

I do not mind that such steps could be considered as contrived.
Originally I faced it in a different scenario. Hunspell allows
to combine dictionaries to check mixed-language texts
(it has some problems with suggested correction just after
language is changed in the document however), e.g.

hunspell -d en_US,ru_RU

Emacs does not allow to specify such configuration directly,
e.g. using M-x ispell-change-dictionary. At first, it is necessary
to properly add such pair as multidictionary. I tried to debug
configuration without touching of main init file using

emacs -q -l spell-init.el

and got the same error "variable is void: default-dictionary".
At the same time if site-lisp is ignored, no such error appears

emacs -Q -l spell-init.el

Before I have realized that initialization has some specific when
"-q -l ..." options are used, I suspected something related to
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=655113
"libreoffice-dictionaries: Please make use of existing Debian
infrastructure to make these appear under emacs, jed and mutt"

I think, the issue is caused by line 442 in
/usr/share/dictionaries-common/site-elisp/debian-ispell.el

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

where default-dictionary is local to let*. Unsure if defvar will
be better for this purpose.

Agustin Martin

unread,
Jun 26, 2021, 4:40:03 PM6/26/21
to
El sáb, 26 jun 2021 a las 14:39, Maxim Nikulin (<mani...@gmail.com>) escribió:
>
> Package: dictionaries-common
> Version: 1.28.4
> Severity: normal

Hi, Maxim, thanks for the info

> Debian stuff dealing with list of dictionaries available for Emacs
> sometimes causes problems.
>
> 3. Try to customize ispell-dictionary when ispell package is not loaded
> yet, e.g. (add HOME=... if necessary)
>
> emacs --eval "(customize-option 'ispell-dictionary)"
>
> 4. Set some string value, e.g "en_US" and try to save for future
> sessions.
>
> *Actual result*:
>
> custom-push-theme: Symbol’s value as variable is void:
> default-dictionary

Confirmed

> Expected result: customization is saved to ~/.emacs
> (or ~/.emacs.d/init.el, etc.)
>
> Workaround for this case:
>
> M-: (require 'ispell) RET
>
> and save for future sessions again.

ispell.el is loaded only after a spellchecking command is issued or
after request. This means that there is no problen once ispell.el is
loaded. However, in Debian we would expect ispell-dictionary to be
customizable before that, and use standard defaults if not, so this
is strange.

> I think, the issue is caused by line 442 in
> /usr/share/dictionaries-common/site-elisp/debian-ispell.el
>
> (or (boundp 'ispell-dictionary)
> (defcustom ispell-dictionary default-dictionary
...
> where default-dictionary is local to let*. Unsure if defvar will
> be better for this purpose.

The funny thing is that if I change default-dictionary to nil in that
line problem seems to still be present. Unless I am missing some side
effect assignation, seems that the problem is related to have that
defcustom inside a function, but I do not really know why that
happens.

The good thing is that moving that defcustom out of the function and
leaving inside just the code to assign a value if not previously set
seems to work. At least it seems so with attached patch. I will test
this a bit more, but even if everything works, do not expect an upload
until new Debian bullseye is released.

Thanks for your contribution to Debian.

Regards,

--
Agust
debian-ispell.el.diff

Maxim Nikulin

unread,
Jun 27, 2021, 8:10:03 AM6/27/21
to
Hi Agustin,

I have no plan to extensively test your patch, I just quickly tried it.
I do not see "variable is void" in both scenarios any more. I do not
know if the following is an intended change. On attempt of customization
before loading of ispell, with original version I get "CHANGED outside
Customize" and "STANDARD" with the modified one.

I am a relatively inexperienced Emacs user, so I am unfamiliar with
themes. I am quite surprised that it is necessary to redefine defcustom
to change its default value (ispell.el already has defcustom
ispell-dictionary).

I am unsure concerning value of emacs stuff in dictionaries-common,
especially since e.g. libreoffice-dictionaries do not provide helper
files. Original ispell.el is able to obtain list of installed
dictionaries directly from aspell and hunspell, so additional files are
not required for `ispell-change-dictionary'. Maybe even menu can be
built from the list of detected dictionaries. I do not expect a detailed
explanation, maybe I just missed some feature and it is described in
some docs.
0 new messages