GNU bug report logs - #50241
flyspell doesn't work with multiple dictionaries

Previous Next

Package: emacs;

Reported by: Konstantin Kharlamov <hi-angel <at> yandex.ru>

Date: Sat, 28 Aug 2021 18:35:02 UTC

Severity: normal

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 50241 in the body.
You can then email your comments to 50241 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#50241; Package emacs. (Sat, 28 Aug 2021 18:35:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Konstantin Kharlamov <hi-angel <at> yandex.ru>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 28 Aug 2021 18:35:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Konstantin Kharlamov <hi-angel <at> yandex.ru>
To: bug-gnu-emacs <at> gnu.org
Subject: flyspell doesn't work with multiple dictionaries
Date: Sat, 28 Aug 2021 21:33:50 +0300
I spent a few hours today trying to make it work, and as far I can see multiple dictionaries support is just broken.

# Steps to reproduce

Note: for 2nd step here not to throw exception you need to make sure you have both hunspell dictionaries used in (ispell-hunspell-add-multi-dic …) call installed in the system.

1. Start `emacs -Q`
2. Evaluate:
    (progn
      (require 'ispell)
      (setq ispell-program-name "hunspell")
      (ispell-hunspell-add-multi-dic "ru_RU,en_US")
      (flyspell-mode 1)
      )
3. Execute in a shell `ps aux | grep hunspell`

## Expected

The `hunspell` process has argument `-d ru_RU,en_US`

## Actual

The `hunspell` process has argument `-d en_US`

## Additional information

M-x report-emacs-bug output goes below:

In GNU Emacs 28.0.50 (build 6, x86_64-pc-linux-gnu, GTK+ Version 3.24.30, cairo version 1.17.4)
 of 2021-08-05 built on constantine-N61Ja
Repository revision: 3dbbcc9a255ce2703d42792e6967797b78e8720b
Repository branch: makepkg
Windowing system distributor 'The X.Org Foundation', version 11.0.12013000
System Description: Arch Linux

Configured using:
 'configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
 --localstatedir=/var --mandir=/usr/share/man --with-gameuser=:games
 --with-sound=alsa --with-modules --without-gconf --without-gsettings
 --enable-link-time-optimization --with-x-toolkit=gtk3 --without-xaw3d
 --without-compress-install
 '--program-transform-name=s/\([ec]tags\)/\1.emacs/' 'CFLAGS=-flto=2
 -march=native -O3 -pipe -fno-stack-protector -fweb
 -fmerge-all-constants -fno-plt -fcommon -flto -fuse-linker-plugin -flto
 -fuse-linker-plugin' 'LDFLAGS=-flto=2 -O3 -march=native -fweb
 -fmerge-all-constants -floop-nest-optimize -Wl,--sort-common,-z,relro
 -fno-plt -fcommon''

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM HARFBUZZ JPEG JSON LCMS2
LIBOTF LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY INOTIFY PDUMPER PNG
RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM
GTK3 ZLIB

Important settings:
  value of $LC_TIME: ru_RU.UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: ELisp/l

Minor modes in effect:
  yas-global-mode: t
  yas-minor-mode: t
  global-color-identifiers-mode: t
  color-identifiers-mode: t
  delete-selection-mode: t
  winum-mode: t
  symbol-overlay-mode: t
  global-symbol-overlay-mode: t
  global-highlight-parentheses-mode: t
  highlight-parentheses-mode: t
  show-smartparens-global-mode: t
  show-smartparens-mode: t
  smartparens-global-mode: t
  smartparens-mode: t
  highlight-numbers-mode: t
  evil-goggles-mode: t
  global-evil-surround-mode: t
  evil-surround-mode: t
  shell-dirtrack-mode: t
  evil-mode: t
  evil-local-mode: t
  windmove-mode: t
  global-auto-revert-mode: t
  global-company-mode: t
  company-mode: t
  override-global-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
/home/constantine/.emacs.d/lisp/idomenu hides /home/constantine/.emacs.d/elpa/idomenu-20141123.2120/idomenu
/home/constantine/.emacs.d/lisp/popup hides /home/constantine/.emacs.d/elpa/popup-20210625.400/popup
/home/constantine/.emacs.d/elpa/cmake-mode-20210104.1831/cmake-mode hides /usr/share/emacs/site-lisp/cmake-mode
/home/constantine/.emacs.d/elpa/transient-20210723.1601/transient hides /usr/share/emacs/28.0.50/lisp/transient

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
rfc822 mml mml-sec epa derived epg epg-config gnus-util rmail
rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils dabbrev server undo-fu imenu pp eieio-opt
speedbar ezimage dframe shortdoc text-property-search flycheck debug
backtrace quail smartparens-markdown markdown-mode noutline outline smex
find-func cl-print help-fns radix-tree tabify yasnippet-snippets
yasnippet face-remap color-identifiers-mode smartparens-python python
tramp-sh tramp tramp-loaddefs trampver tramp-integration tramp-compat
parse-time iso8601 time-date ls-lisp format-spec misearch multi-isearch
vc-git diff-mode vc-dispatcher delsel winum symbol-overlay
highlight-parentheses sp-sublimetext-like smartparens-config
smartparens-text smartparens dash highlight-numbers parent-mode ido
evil-goggles pulse color evil-surround emvil evil evil-keybindings
evil-integration evil-maps evil-commands reveal flyspell ispell
evil-jumps evil-command-window evil-types evil-search evil-ex shell
pcomplete comint ansi-color evil-macros evil-repeat evil-states
evil-core advice evil-common windmove calc calc-loaddefs calc-macs
thingatpt rect evil-digraphs evil-vars avy autorevert filenotify
company-oddmuse company-keywords company-etags etags fileloop generator
xref project ring company-gtags files-x company-dabbrev-code
company-dabbrev company-files company-clang company-capf company-cmake
company-semantic company-template company-bbdb company pcase cl-extra
help-mode use-package-bind-key use-package-core edmacro kmacro bind-key
easy-mmode rx cc-styles cc-align cc-engine cc-vars cc-defs info package
browse-url url url-proxy url-privacy url-expand url-methods url-history
url-cookie url-domsuf url-util mailcap url-handlers url-parse
auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs
password-cache json subr-x map url-vars seq byte-opt gv bytecomp
byte-compile cconv cl-loaddefs cl-lib iso-transl tooltip eldoc electric
uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu
timer select scroll-bar mouse jit-lock font-lock syntax font-core
term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite charscript charprop case-table epa-hook
jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button
loaddefs faces cus-face macroexp files window text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote threads dbusbind inotify lcms2
dynamic-setting font-render-setting cairo move-toolbar gtk x-toolkit x
multi-tty make-network-process emacs)

Memory information:
((conses 16 353438 136088)
 (symbols 48 24458 1)
 (strings 32 87321 23690)
 (string-bytes 1 2859020)
 (vectors 16 53736)
 (vector-slots 8 1417151 443852)
 (floats 8 276 1005)
 (intervals 56 13087 471)
 (buffers 992 21))






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50241; Package emacs. (Sat, 28 Aug 2021 18:58:02 GMT) Full text and rfc822 format available.

Message #8 received at 50241 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Konstantin Kharlamov <hi-angel <at> yandex.ru>
Cc: 50241 <at> debbugs.gnu.org
Subject: Re: bug#50241: flyspell doesn't work with multiple dictionaries
Date: Sat, 28 Aug 2021 21:56:43 +0300
> From: Konstantin Kharlamov <hi-angel <at> yandex.ru>
> Date: Sat, 28 Aug 2021 21:33:50 +0300
> 
> # Steps to reproduce
> 
> Note: for 2nd step here not to throw exception you need to make sure you have both hunspell dictionaries used in (ispell-hunspell-add-multi-dic …) call installed in the system.
> 
> 1. Start `emacs -Q`
> 2. Evaluate:
>     (progn
>       (require 'ispell)
>       (setq ispell-program-name "hunspell")
>       (ispell-hunspell-add-multi-dic "ru_RU,en_US")
>       (flyspell-mode 1)
>       )

You miss this step at the end:

  (ispell-change-dictionary "ru_RU,en_US")

It tells Emacs to restart Hunspell with these two dictionaries.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50241; Package emacs. (Sat, 28 Aug 2021 19:00:02 GMT) Full text and rfc822 format available.

Message #11 received at 50241 <at> debbugs.gnu.org (full text, mbox):

From: Konstantin Kharlamov <hi-angel <at> yandex.ru>
To: 50241 <at> debbugs.gnu.org
Subject: Re: bug#50241: Acknowledgement (flyspell doesn't work with multiple
 dictionaries)
Date: Sat, 28 Aug 2021 21:59:15 +0300
Alright, partially I made it to work: adding a line `(setq ispell-dictionary "ru_RU,en_US")` as in:

    (progn
      (require 'ispell)
      (setq ispell-program-name "hunspell")
      (ispell-hunspell-add-multi-dic "ru_RU,en_US")
      (setq ispell-dictionary "ru_RU,en_US")
      (flyspell-mode 1)
      )

Launches the process with correct args. However, in this case running `(flyspell-mode 1)` ends up with an error

Error in post-command-hook (flyspell-post-command-hook): (error "No data for dictionary \"ru_RU,en_US\" in ‘ispell-local-dictionary-alist’ or ‘ispell-dictionary-alist’")

On Sat, 2021-08-28 at 18:35 +0000, GNU bug Tracking System wrote:
> 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 <at> gnu.org
>
> If you wish to submit further information on this problem, please
> send it to 50241 <at> debbugs.gnu.org.
>
> Please do not send mail to help-debbugs <at> gnu.org unless you wish
> to report a problem with the Bug-tracking system.
>






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50241; Package emacs. (Sat, 28 Aug 2021 19:07:02 GMT) Full text and rfc822 format available.

Message #14 received at 50241 <at> debbugs.gnu.org (full text, mbox):

From: Konstantin Kharlamov <hi-angel <at> yandex.ru>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 50241 <at> debbugs.gnu.org
Subject: Re: bug#50241: flyspell doesn't work with multiple dictionaries
Date: Sat, 28 Aug 2021 22:05:55 +0300
On Sat, 2021-08-28 at 21:56 +0300, Eli Zaretskii wrote:
> 
> You miss this step at the end:
> 
>   (ispell-change-dictionary "ru_RU,en_US")
> 
> It tells Emacs to restart Hunspell with these two dictionaries.

Thank you! Running this command results in error:

	(error "Undefined dictionary: ru_RU,en_US")





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50241; Package emacs. (Sat, 28 Aug 2021 19:36:02 GMT) Full text and rfc822 format available.

Message #17 received at 50241 <at> debbugs.gnu.org (full text, mbox):

From: Konstantin Kharlamov <hi-angel <at> yandex.ru>
To: undisclosed-recipients:;
Cc: 50241 <at> debbugs.gnu.org
Subject: Re: bug#50241: flyspell doesn't work with multiple dictionaries
Date: Sat, 28 Aug 2021 22:35:05 +0300
I found a wrokaround: executing the following code *twice* makes it work:

    (progn
      (require 'ispell)
      (setq ispell-program-name "hunspell")
      (ispell-hunspell-add-multi-dic "ru_RU,en_US")
      (setq ispell-local-dictionary
            '(("ru_RU,en_US" "[[:alpha:]]" "[^[:alpha:]]" "['0-9]" t ("-d"
    "ru_RU,en_US") nil utf-8)))
      (ispell-change-dictionary "ru_RU,en_US")
      (flyspell-mode 1)
      )

So, manually creating an entry in ispell-local-dictionary makes it work. However note I emphasized "twice" word — for some readon (I don't know why) even this workaround works if you execute this code twice. On the first evaluation it always generates an error. I tried changing the order of various expressions, but so far wasn't able to make it behave always same way (not sure it really matters though as it's just a a workaround).






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50241; Package emacs. (Sat, 28 Aug 2021 19:37:02 GMT) Full text and rfc822 format available.

Message #20 received at 50241 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Konstantin Kharlamov <hi-angel <at> yandex.ru>
Cc: 50241 <at> debbugs.gnu.org
Subject: Re: bug#50241: flyspell doesn't work with multiple dictionaries
Date: Sat, 28 Aug 2021 22:36:26 +0300
> From: Konstantin Kharlamov <hi-angel <at> yandex.ru>
> Cc: 50241 <at> debbugs.gnu.org
> Date: Sat, 28 Aug 2021 22:05:55 +0300
> 
> On Sat, 2021-08-28 at 21:56 +0300, Eli Zaretskii wrote:
> > 
> > You miss this step at the end:
> > 
> >   (ispell-change-dictionary "ru_RU,en_US")
> > 
> > It tells Emacs to restart Hunspell with these two dictionaries.
> 
> Thank you! Running this command results in error:
> 
> 	(error "Undefined dictionary: ru_RU,en_US")

Strange.  Here, it doesn't error out.  I did this:

  M-x flyspell-mode RET
  M-x ispell-hunspell-add-multi-dic RET ru_RU,en_US RET
  M-x ispell-change-dictionary RET ru_RU,en_US RET

And I don't get any errors, and flyspell-mode works for both Russian
and English.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50241; Package emacs. (Sat, 28 Aug 2021 19:46:02 GMT) Full text and rfc822 format available.

Message #23 received at 50241 <at> debbugs.gnu.org (full text, mbox):

From: Konstantin Kharlamov <hi-angel <at> yandex.ru>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 50241 <at> debbugs.gnu.org
Subject: Re: bug#50241: flyspell doesn't work with multiple dictionaries
Date: Sat, 28 Aug 2021 22:45:00 +0300
On Sat, 2021-08-28 at 22:36 +0300, Eli Zaretskii wrote:
> > From: Konstantin Kharlamov <hi-angel <at> yandex.ru>
> > Cc: 50241 <at> debbugs.gnu.org
> > Date: Sat, 28 Aug 2021 22:05:55 +0300
> > 
> > On Sat, 2021-08-28 at 21:56 +0300, Eli Zaretskii wrote:
> > > 
> > > You miss this step at the end:
> > > 
> > >   (ispell-change-dictionary "ru_RU,en_US")
> > > 
> > > It tells Emacs to restart Hunspell with these two dictionaries.
> > 
> > Thank you! Running this command results in error:
> > 
> >         (error "Undefined dictionary: ru_RU,en_US")
> 
> Strange.  Here, it doesn't error out.  I did this:
> 
>   M-x flyspell-mode RET
>   M-x ispell-hunspell-add-multi-dic RET ru_RU,en_US RET
>   M-x ispell-change-dictionary RET ru_RU,en_US RET
> 
> And I don't get any errors, and flyspell-mode works for both Russian
> and English.

Thank you! With a little modification for steps to be:

  M-x flyspell-mode RET
  M-: (setq ispell-program-name "hunspell")
  M-x ispell-hunspell-add-multi-dic RET ru_RU,en_US RET
  M-x ispell-change-dictionary RET ru_RU,en_US RET

this worked for me! Hmm, let me try to experiment with that a bit to see why it
didn't work for me non-interactively…





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50241; Package emacs. (Sat, 28 Aug 2021 20:03:02 GMT) Full text and rfc822 format available.

Message #26 received at 50241 <at> debbugs.gnu.org (full text, mbox):

From: Konstantin Kharlamov <hi-angel <at> yandex.ru>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 50241 <at> debbugs.gnu.org
Subject: Re: bug#50241: flyspell doesn't work with multiple dictionaries
Date: Sat, 28 Aug 2021 23:02:41 +0300
On Sat, 2021-08-28 at 22:45 +0300, Konstantin Kharlamov wrote:
> On Sat, 2021-08-28 at 22:36 +0300, Eli Zaretskii wrote:
> > > From: Konstantin Kharlamov <hi-angel <at> yandex.ru>
> > > Cc: 50241 <at> debbugs.gnu.org
> > > Date: Sat, 28 Aug 2021 22:05:55 +0300
> > > 
> > > On Sat, 2021-08-28 at 21:56 +0300, Eli Zaretskii wrote:
> > > > 
> > > > You miss this step at the end:
> > > > 
> > > >   (ispell-change-dictionary "ru_RU,en_US")
> > > > 
> > > > It tells Emacs to restart Hunspell with these two dictionaries.
> > > 
> > > Thank you! Running this command results in error:
> > > 
> > >         (error "Undefined dictionary: ru_RU,en_US")
> > 
> > Strange.  Here, it doesn't error out.  I did this:
> > 
> >   M-x flyspell-mode RET
> >   M-x ispell-hunspell-add-multi-dic RET ru_RU,en_US RET
> >   M-x ispell-change-dictionary RET ru_RU,en_US RET
> > 
> > And I don't get any errors, and flyspell-mode works for both Russian
> > and English.
> 
> Thank you! With a little modification for steps to be:
> 
>   M-x flyspell-mode RET
>   M-: (setq ispell-program-name "hunspell")
>   M-x ispell-hunspell-add-multi-dic RET ru_RU,en_US RET
>   M-x ispell-change-dictionary RET ru_RU,en_US RET
> 
> this worked for me! Hmm, let me try to experiment with that a bit to see why
> it
> didn't work for me non-interactively…

Okay, so the bug seems to be in ispell-hunspell-add-multi-dic function. When called interactively, then the following interactive call to (ispell-change-dictionary) has the ru_RU,en_US dictionary as a completion. However, if ispell-hunspell-add-multi-dic was called non-interactively, the completion from the subsequent (ispell-change-dictionary) call seems to be missing.

Not sure though why the difference in behaviour, the "interactive" part of that function look innocent, simply (interactive "sPrompt"). Not sure what starting "s" means though.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50241; Package emacs. (Sat, 28 Aug 2021 20:20:02 GMT) Full text and rfc822 format available.

Message #29 received at 50241 <at> debbugs.gnu.org (full text, mbox):

From: Konstantin Kharlamov <hi-angel <at> yandex.ru>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 50241 <at> debbugs.gnu.org
Subject: Re: bug#50241: flyspell doesn't work with multiple dictionaries
Date: Sat, 28 Aug 2021 23:19:36 +0300
On Sat, 2021-08-28 at 23:02 +0300, Konstantin Kharlamov wrote:
> On Sat, 2021-08-28 at 22:45 +0300, Konstantin Kharlamov wrote:
> > On Sat, 2021-08-28 at 22:36 +0300, Eli Zaretskii wrote:
> > > > From: Konstantin Kharlamov <hi-angel <at> yandex.ru>
> > > > Cc: 50241 <at> debbugs.gnu.org
> > > > Date: Sat, 28 Aug 2021 22:05:55 +0300
> > > > 
> > > > On Sat, 2021-08-28 at 21:56 +0300, Eli Zaretskii wrote:
> > > > > 
> > > > > You miss this step at the end:
> > > > > 
> > > > >   (ispell-change-dictionary "ru_RU,en_US")
> > > > > 
> > > > > It tells Emacs to restart Hunspell with these two dictionaries.
> > > > 
> > > > Thank you! Running this command results in error:
> > > > 
> > > >         (error "Undefined dictionary: ru_RU,en_US")
> > > 
> > > Strange.  Here, it doesn't error out.  I did this:
> > > 
> > >   M-x flyspell-mode RET
> > >   M-x ispell-hunspell-add-multi-dic RET ru_RU,en_US RET
> > >   M-x ispell-change-dictionary RET ru_RU,en_US RET
> > > 
> > > And I don't get any errors, and flyspell-mode works for both Russian
> > > and English.
> > 
> > Thank you! With a little modification for steps to be:
> > 
> >   M-x flyspell-mode RET
> >   M-: (setq ispell-program-name "hunspell")
> >   M-x ispell-hunspell-add-multi-dic RET ru_RU,en_US RET
> >   M-x ispell-change-dictionary RET ru_RU,en_US RET
> > 
> > this worked for me! Hmm, let me try to experiment with that a bit to see why
> > it
> > didn't work for me non-interactively…
> 
> Okay, so the bug seems to be in ispell-hunspell-add-multi-dic function. When
> called interactively, then the following interactive call to (ispell-change-
> dictionary) has the ru_RU,en_US dictionary as a completion. However, if
> ispell-hunspell-add-multi-dic was called non-interactively, the completion
> from the subsequent (ispell-change-dictionary) call seems to be missing.
> 
> Not sure though why the difference in behaviour, the "interactive" part of
> that function look innocent, simply (interactive "sPrompt"). Not sure what
> starting "s" means though.

Okay, so, I figured there's some sort of odd cooperation between (ispell-hunspell-add-multi-dic) and (ispell-change-dictionary) going on.

When the first is called non-interactively, interactive call to the second results in no completion for the new dict, right? So, the fun thing is that if you abort prompt afterwards, then you call (ispell-hunspell-add-multi-dic) again, and then you call (ispell-change-dictionary) interactively again, the prompt will have the completion.

It looks as if call to (ispell-change-dictionary) initializes some important variable required by (ispell-hunspell-add-multi-dic) to function properly.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50241; Package emacs. (Sat, 28 Aug 2021 20:27:01 GMT) Full text and rfc822 format available.

Message #32 received at 50241 <at> debbugs.gnu.org (full text, mbox):

From: Konstantin Kharlamov <hi-angel <at> yandex.ru>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 50241 <at> debbugs.gnu.org
Subject: Re: bug#50241: flyspell doesn't work with multiple dictionaries
Date: Sat, 28 Aug 2021 23:26:28 +0300
On Sat, 2021-08-28 at 23:19 +0300, Konstantin Kharlamov wrote:
> On Sat, 2021-08-28 at 23:02 +0300, Konstantin Kharlamov wrote:
> > On Sat, 2021-08-28 at 22:45 +0300, Konstantin Kharlamov wrote:
> > > On Sat, 2021-08-28 at 22:36 +0300, Eli Zaretskii wrote:
> > > > > From: Konstantin Kharlamov <hi-angel <at> yandex.ru>
> > > > > Cc: 50241 <at> debbugs.gnu.org
> > > > > Date: Sat, 28 Aug 2021 22:05:55 +0300
> > > > > 
> > > > > On Sat, 2021-08-28 at 21:56 +0300, Eli Zaretskii wrote:
> > > > > > 
> > > > > > You miss this step at the end:
> > > > > > 
> > > > > >   (ispell-change-dictionary "ru_RU,en_US")
> > > > > > 
> > > > > > It tells Emacs to restart Hunspell with these two dictionaries.
> > > > > 
> > > > > Thank you! Running this command results in error:
> > > > > 
> > > > >         (error "Undefined dictionary: ru_RU,en_US")
> > > > 
> > > > Strange.  Here, it doesn't error out.  I did this:
> > > > 
> > > >   M-x flyspell-mode RET
> > > >   M-x ispell-hunspell-add-multi-dic RET ru_RU,en_US RET
> > > >   M-x ispell-change-dictionary RET ru_RU,en_US RET
> > > > 
> > > > And I don't get any errors, and flyspell-mode works for both Russian
> > > > and English.
> > > 
> > > Thank you! With a little modification for steps to be:
> > > 
> > >   M-x flyspell-mode RET
> > >   M-: (setq ispell-program-name "hunspell")
> > >   M-x ispell-hunspell-add-multi-dic RET ru_RU,en_US RET
> > >   M-x ispell-change-dictionary RET ru_RU,en_US RET
> > > 
> > > this worked for me! Hmm, let me try to experiment with that a bit to see
> > > why
> > > it
> > > didn't work for me non-interactively…
> > 
> > Okay, so the bug seems to be in ispell-hunspell-add-multi-dic function. When
> > called interactively, then the following interactive call to (ispell-change-
> > dictionary) has the ru_RU,en_US dictionary as a completion. However, if
> > ispell-hunspell-add-multi-dic was called non-interactively, the completion
> > from the subsequent (ispell-change-dictionary) call seems to be missing.
> > 
> > Not sure though why the difference in behaviour, the "interactive" part of
> > that function look innocent, simply (interactive "sPrompt"). Not sure what
> > starting "s" means though.
> 
> Okay, so, I figured there's some sort of odd cooperation between (ispell-
> hunspell-add-multi-dic) and (ispell-change-dictionary) going on.
> 
> When the first is called non-interactively, interactive call to the second
> results in no completion for the new dict, right? So, the fun thing is that if
> you abort prompt afterwards, then you call (ispell-hunspell-add-multi-dic)
> again, and then you call (ispell-change-dictionary) interactively again, the
> prompt will have the completion.
> 
> It looks as if call to (ispell-change-dictionary) initializes some important
> variable required by (ispell-hunspell-add-multi-dic) to function properly.

…and, the function that needs to be called before (ispell-hunspell-add-multi-dic "ru_RU,en_US") is (ispell-valid-dictionary-list)





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50241; Package emacs. (Sat, 28 Aug 2021 20:43:01 GMT) Full text and rfc822 format available.

Message #35 received at 50241 <at> debbugs.gnu.org (full text, mbox):

From: Konstantin Kharlamov <hi-angel <at> yandex.ru>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 50241 <at> debbugs.gnu.org
Subject: Re: bug#50241: flyspell doesn't work with multiple dictionaries
Date: Sat, 28 Aug 2021 23:42:08 +0300
Okay, I finally found the working combination, it is:

    (progn
      (require 'ispell)
      (setq ispell-program-name "hunspell")
      (ispell-set-spellchecker-params)
      (ispell-hunspell-add-multi-dic "ru_RU,en_US")
      (ispell-change-dictionary "ru_RU,en_US")
      (flyspell-mode 1)
      )

So, the magical function is `(ispell-set-spellchecker-params)`. Judging by its description, it has to be called before any ispell usage.

I can probably call it manually, but I presume the behaviour needs fixing.

I think perhaps, should ispell have a global variable like `ispell-initialized`, which then would be set in (ispell-set-spellchecker-params). And then the variable would be checked in `ispell-hunspell-add-multi-dic`, and if it wasn't set, throw an exception "Ispell wasn't initialized. Please call `(ispell-set-spellchecker-params)'"?





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50241; Package emacs. (Sun, 29 Aug 2021 06:14:02 GMT) Full text and rfc822 format available.

Message #38 received at 50241 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Konstantin Kharlamov <hi-angel <at> yandex.ru>
Cc: 50241 <at> debbugs.gnu.org
Subject: Re: bug#50241: flyspell doesn't work with multiple dictionaries
Date: Sun, 29 Aug 2021 09:12:58 +0300
> From: Konstantin Kharlamov <hi-angel <at> yandex.ru>
> Cc: 50241 <at> debbugs.gnu.org
> Date: Sat, 28 Aug 2021 23:42:08 +0300
> 
> Okay, I finally found the working combination, it is:
> 
>     (progn
>       (require 'ispell)
>       (setq ispell-program-name "hunspell")
>       (ispell-set-spellchecker-params)
>       (ispell-hunspell-add-multi-dic "ru_RU,en_US")
>       (ispell-change-dictionary "ru_RU,en_US")
>       (flyspell-mode 1)
>       )
> 
> So, the magical function is `(ispell-set-spellchecker-params)`. Judging by its description, it has to be called before any ispell usage.
> 
> I can probably call it manually, but I presume the behaviour needs fixing.

I'm not sure I agree.  These are commands that are supposed to be
invoked interactively, in the order I've shown, which works.  If you
want to make this part of your initialization, you need to figure out
the required sequence of calls, which you did.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50241; Package emacs. (Sun, 29 Aug 2021 12:44:02 GMT) Full text and rfc822 format available.

Message #41 received at 50241 <at> debbugs.gnu.org (full text, mbox):

From: Konstantin Kharlamov <hi-angel <at> yandex.ru>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 50241 <at> debbugs.gnu.org
Subject: Re: bug#50241: flyspell doesn't work with multiple dictionaries
Date: Sun, 29 Aug 2021 15:43:30 +0300
On Sun, 2021-08-29 at 09:12 +0300, Eli Zaretskii wrote:
> > From: Konstantin Kharlamov <hi-angel <at> yandex.ru>
> > Cc: 50241 <at> debbugs.gnu.org
> > Date: Sat, 28 Aug 2021 23:42:08 +0300
> > 
> > Okay, I finally found the working combination, it is:
> > 
> >     (progn
> >       (require 'ispell)
> >       (setq ispell-program-name "hunspell")
> >       (ispell-set-spellchecker-params)
> >       (ispell-hunspell-add-multi-dic "ru_RU,en_US")
> >       (ispell-change-dictionary "ru_RU,en_US")
> >       (flyspell-mode 1)
> >       )
> > 
> > So, the magical function is `(ispell-set-spellchecker-params)`. Judging by
> > its description, it has to be called before any ispell usage.
> > 
> > I can probably call it manually, but I presume the behaviour needs fixing.
> 
> I'm not sure I agree.  These are commands that are supposed to be
> invoked interactively, in the order I've shown, which works.  If you
> want to make this part of your initialization, you need to figure out
> the required sequence of calls, which you did.

Would you agree if I say that a good user interface means that a function invoked interactively should behave same way when it's invoked non-interactively (barring the fact that it won't show the prompt)? I would say that the answer is yes, otherwise it is very confusing.

So I would say, at least the (ispell-set-spellchecker-params) needs to be added into one of them, so the same order as if they were called interactively would work when they are invoked from a Emacs Lisp file.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50241; Package emacs. (Sun, 29 Aug 2021 13:08:01 GMT) Full text and rfc822 format available.

Message #44 received at 50241 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Konstantin Kharlamov <hi-angel <at> yandex.ru>
Cc: 50241 <at> debbugs.gnu.org
Subject: Re: bug#50241: flyspell doesn't work with multiple dictionaries
Date: Sun, 29 Aug 2021 16:07:08 +0300
> From: Konstantin Kharlamov <hi-angel <at> yandex.ru>
> Cc: 50241 <at> debbugs.gnu.org
> Date: Sun, 29 Aug 2021 15:43:30 +0300
> 
> > I'm not sure I agree.  These are commands that are supposed to be
> > invoked interactively, in the order I've shown, which works.  If you
> > want to make this part of your initialization, you need to figure out
> > the required sequence of calls, which you did.
> 
> Would you agree if I say that a good user interface means that a function invoked interactively should behave same way when it's invoked non-interactively (barring the fact that it won't show the prompt)?

No, I don't agree.  And neither does Emacs: the 'interactive' form is
not necessarily a no-op.  As a trivial example, consider:

  describe-char is an autoloaded interactive compiled Lisp function in
  ‘descr-text.el’.

  (describe-char POS &optional BUFFER)

    Probably introduced at or before Emacs version 22.1.

  Describe position POS (interactively, point) and the char after POS.
                        ^^^^^^^^^^^^^^^^^^^^^^
As you see, there's some magic happening in interactive invocations
that doesn't happen when you call this function from Lisp.

A less trivial example:

  previous-line is an interactive compiled Lisp function in ‘simple.el’.

  It is bound to C-p, <up>.

  (previous-line &optional ARG TRY-VSCROLL)

    This function is for interactive use only;
    in Lisp code use `forward-line' with negative argument instead.

  Move cursor vertically up ARG lines.
  Interactively, vscroll tall lines if ‘auto-window-vscroll’ is enabled.
  Non-interactively, use TRY-VSCROLL to control whether to vscroll tall
  lines: if either ‘auto-window-vscroll’ or TRY-VSCROLL is nil, this
  function will not vscroll.

Again, the behavior in interactive and non-interactive calls is
different.

> So I would say, at least the (ispell-set-spellchecker-params) needs to be added into one of them, so the same order as if they were called interactively would work when they are invoked from a Emacs Lisp file.

Maybe, I need to think about it.  But the general principle still
stands: it is okay for interactive and non-interactive invocations to
behave differently.  We do it all the time in Emacs.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50241; Package emacs. (Sun, 29 Aug 2021 19:51:02 GMT) Full text and rfc822 format available.

Message #47 received at 50241 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 50241 <at> debbugs.gnu.org, Konstantin Kharlamov <hi-angel <at> yandex.ru>
Subject: Re: bug#50241: flyspell doesn't work with multiple dictionaries
Date: Sun, 29 Aug 2021 21:50:10 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

>> Would you agree if I say that a good user interface means that a
>> function invoked interactively should behave same way when it's
>> invoked non-interactively (barring the fact that it won't show the
>> prompt)?
>
> No, I don't agree.

Well, it should be possible to set up multiple dictionaries without
using `M-x'.  So something here should be fixed, in my opinion.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50241; Package emacs. (Mon, 30 Aug 2021 02:26:01 GMT) Full text and rfc822 format available.

Message #50 received at 50241 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 50241 <at> debbugs.gnu.org, hi-angel <at> yandex.ru
Subject: Re: bug#50241: flyspell doesn't work with multiple dictionaries
Date: Mon, 30 Aug 2021 05:24:51 +0300
> From: Lars Ingebrigtsen <larsi <at> gnus.org>
> Cc: Konstantin Kharlamov <hi-angel <at> yandex.ru>,  50241 <at> debbugs.gnu.org
> Date: Sun, 29 Aug 2021 21:50:10 +0200
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> >> Would you agree if I say that a good user interface means that a
> >> function invoked interactively should behave same way when it's
> >> invoked non-interactively (barring the fact that it won't show the
> >> prompt)?
> >
> > No, I don't agree.
> 
> Well, it should be possible to set up multiple dictionaries without
> using `M-x'.

It is already possible, see the recipe up-thread.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50241; Package emacs. (Mon, 30 Aug 2021 02:28:02 GMT) Full text and rfc822 format available.

Message #53 received at 50241 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 50241 <at> debbugs.gnu.org, hi-angel <at> yandex.ru
Subject: Re: bug#50241: flyspell doesn't work with multiple dictionaries
Date: Mon, 30 Aug 2021 04:27:28 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

>> Well, it should be possible to set up multiple dictionaries without
>> using `M-x'.
>
> It is already possible, see the recipe up-thread.

Right.  But it should be documented -- I think
mentioning `ispell-set-spellchecker-params' is what's missing.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Mon, 30 Aug 2021 12:50:02 GMT) Full text and rfc822 format available.

Notification sent to Konstantin Kharlamov <hi-angel <at> yandex.ru>:
bug acknowledged by developer. (Mon, 30 Aug 2021 12:50:02 GMT) Full text and rfc822 format available.

Message #58 received at 50241-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 50241-done <at> debbugs.gnu.org, hi-angel <at> yandex.ru
Subject: Re: bug#50241: flyspell doesn't work with multiple dictionaries
Date: Mon, 30 Aug 2021 15:49:17 +0300
> From: Lars Ingebrigtsen <larsi <at> gnus.org>
> Cc: hi-angel <at> yandex.ru,  50241 <at> debbugs.gnu.org
> Date: Mon, 30 Aug 2021 04:27:28 +0200
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> >> Well, it should be possible to set up multiple dictionaries without
> >> using `M-x'.
> >
> > It is already possible, see the recipe up-thread.
> 
> Right.  But it should be documented -- I think
> mentioning `ispell-set-spellchecker-params' is what's missing.

OK, I made such a change in the doc string of
ispell-hunspell-add-multi-dic, and I'm therefore closing this bug
report.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 28 Sep 2021 11:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 203 days ago.

Previous Next


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