unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Martin Kletzander <mk@linux.com>
Cc: 25830@debbugs.gnu.org
Subject: bug#25830: 25.2; ispell doesn't parse hunspell dictionaries properly
Date: Sun, 05 Mar 2017 17:42:14 +0200	[thread overview]
Message-ID: <83d1dvk9wp.fsf@gnu.org> (raw)
In-Reply-To: <20170228215352.GB29225@wheatley> (message from Martin Kletzander on Tue, 28 Feb 2017 22:53:52 +0100)

> Date: Tue, 28 Feb 2017 22:53:52 +0100
> From: Martin Kletzander <mk@linux.com>
> Cc: 25830@debbugs.gnu.org
> 
> >Please try the patch below.  (If it doesn't apply to your version of
> >ispell.el, tell me which version of Emacs you have, and I will try to
> >produce a compatible patch.)
> >
> 
> Sorry I didn't get to this earlier.

Now it's my turn to apologize for the delay...

> One of the hunks didn't apply correctly, so I used the file from
> master and it applied correctly.  So with your patch applied on top
> of ispell.el from current master, the situation is way better.  But
> I feel like it still doesn't work as expected.  Not that anything
> would be broken, but it uses only the first dictionary found.

You are right, that was the wrong direction to try to solve the
problem.

Here's another attempt.  It should be applied _instead_ of the
previous patch, to the original version of ispell.el.  Let me know if
it works OK for you.

Thanks.

--- lisp/textmodes/ispell.el~0	2017-01-08 06:23:52.000000000 +0200
+++ lisp/textmodes/ispell.el	2017-03-05 17:21:10.441710400 +0200
@@ -1094,10 +1094,10 @@
 
 (defun ispell-find-hunspell-dictionaries ()
   "Look for installed Hunspell dictionaries.
-Will initialize `ispell-hunspell-dictionary-alist' and
-`ispell-hunspell-dictionary-alist' after values found
-and remove `ispell-dicts-name2locale-equivs-alist'
-entries if a specific dictionary was found."
+Will initialize `ispell-hunspell-dictionary-alist' according
+to dictionaries found, and will remove aliases from the list
+in `ispell-dicts-name2locale-equivs-alist' if an explicit
+dictionary from that list was found."
   (let ((hunspell-found-dicts
 	 (split-string
 	  (with-temp-buffer
@@ -1110,18 +1110,27 @@
 	  "[\n\r]+"
 	  t))
 	hunspell-default-dict
-	hunspell-default-dict-entry)
+	hunspell-default-dict-entry
+	hunspell-multi-dict)
     (dolist (dict hunspell-found-dicts)
       (let* ((full-name (file-name-nondirectory dict))
 	     (basename  (file-name-sans-extension full-name))
 	     (affix-file (concat dict ".aff")))
 	(if (string-match "\\.aff$" dict)
 	    ;; Found default dictionary
-	    (if hunspell-default-dict
-		(error "ispell-fhd: Default dict already defined as %s.  Not using %s.\n"
-		       hunspell-default-dict dict)
-	      (setq affix-file dict)
-	      (setq hunspell-default-dict (list basename affix-file)))
+	    (progn
+	      (if hunspell-default-dict
+		  (setq hunspell-multi-dict
+			(concat (or hunspell-multi-dict
+				    (car hunspell-default-dict))
+				"," basename))
+		(setq affix-file dict)
+		;; FIXME: The cdr of the list we cons below is never
+		;; used.  Why do we need a list?
+		(setq hunspell-default-dict (list basename affix-file)))
+	      (ispell-print-if-debug
+	       "++ ispell-fhd: default dict-entry:%s name:%s basename:%s\n"
+	       dict full-name basename))
 	  (if (and (not (assoc basename ispell-hunspell-dict-paths-alist))
 		   (file-exists-p affix-file))
 	      ;; Entry has an associated .aff file and no previous value.
@@ -1161,7 +1170,8 @@
 	      (cl-pushnew (list dict-equiv-key affix-file)
                           ispell-hunspell-dict-paths-alist :test #'equal)))))
     ;; Parse and set values for default dictionary.
-    (setq hunspell-default-dict (car hunspell-default-dict))
+    (setq hunspell-default-dict (or hunspell-multi-dict
+				    (car hunspell-default-dict)))
     (setq hunspell-default-dict-entry
 	  (ispell-parse-hunspell-affix-file hunspell-default-dict))
     ;; Create an alist of found dicts with only names, except for default dict.





  reply	other threads:[~2017-03-05 15:42 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-21  9:18 bug#25830: 25.2; ispell doesn't parse hunspell dictionaries properly Martin Kletzander
2017-02-21 17:23 ` Eli Zaretskii
2017-02-21 20:24   ` Martin Kletzander
2017-02-21 20:44     ` Eli Zaretskii
2017-02-22 10:40       ` Martin Kletzander
2017-02-22 16:20         ` Eli Zaretskii
2017-02-22 16:43           ` Martin Kletzander
2017-02-25  8:24             ` Eli Zaretskii
2017-02-25 12:15               ` Martin Kletzander
2017-02-25 12:41                 ` Eli Zaretskii
2017-02-25 13:10                   ` Martin Kletzander
2017-02-27 15:54                 ` Eli Zaretskii
2017-02-28 21:53                   ` Martin Kletzander
2017-03-05 15:42                     ` Eli Zaretskii [this message]
2017-03-07 16:51                       ` Eli Zaretskii
2017-03-25 16:13                         ` Eli Zaretskii

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=83d1dvk9wp.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=25830@debbugs.gnu.org \
    --cc=mk@linux.com \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).