From: Bastian Ballmann <bastian.ballmann@inf.ethz.ch>
To: 12611@debbugs.gnu.org
Subject: bug#12611: Bugfix for broken hunspell choices
Date: Tue, 9 Oct 2012 14:32:11 +0200 [thread overview]
Message-ID: <5074194B.6040305@inf.ethz.ch> (raw)
** Description
When using hunspell as spell checker and setting LANG=de_CH.utf-8 i
often get an empty choices buffer after running M-x ispell. The problem
is the use of the -a parameter. Hunspell only outputs half of the
corrections when using -a in contrast to a run without -a param.
Here's the configuration I tested with
(require 'ispell)
(setq ispell-dictionary-base-alist
'(
("de_DE"
"[a-zäöüßA-ZÄÖÜ]" "[^a-zäöüßA-ZÄÖÜ]" "[']" nil
("-d" "de_DE") nil utf-8)
("de_CH"
"[a-zäöüA-ZÄÖÜ]" "[^a-zäöüA-ZÄÖÜ]" "[']" nil
("-d" "de_CH") nil utf-8)
("en_US"
"[a-zA-Z]" "[^a-zA-Z]" "[']" nil
("-d" "en_US") nil utf-8)
("en_GB"
"[a-zA-Z]" "[^a-zA-Z]" "[']" nil
("-d" "en_GB") nil utf-8)
)
)
(eval-after-load "ispell"
(progn
(setq ispell-dictionary "de_CH")
(setq ispell-extra-args '("-t")) ; The input file is in TeX or
LaTeX format.
(setq ispell-silently-savep t) ; save personal dict without
confirmation
)
)
(setq-default ispell-program-name "hunspell")
(setq ispell-really-hunspell t)
(setq debug-on-error t)
The only way I was able to generate choices for all wrong written word
is by skiping the -a parameter.
** Patch
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index 51a4800..2a73926 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -1632,7 +1632,8 @@ This allows it to improve the suggestion list
based on actual misspellings."
(point-min) (point-max)
ispell-program-name nil
output-buf nil
- "-a"
+ ;; -a makes problems with choices when using
hunspell and utf-8
+ (if ispell-really-hunspell "" "-a")
;; hunspell -m option means something different
(if ispell-really-hunspell "" "-m")
ispell-args))
@@ -2577,8 +2578,12 @@ Optional third arg SHIFT is an offset to apply
based on previous corrections."
((eq (aref output 0) ?+) ; found because of root word
(substring output 2)) ; return root word
((equal 0 (string-match "[\ra-zA-Z]" output))
- (ding) ; error message from ispell!
- (message "Ispell error: %s" output)
+ (if (not (equal "hunspell" ispell-program-name))
+ (progn
+ (ding) ; error message from ispell!
+ (message "Ispell error: %s" output)
+ )
+ )
(sit-for 5)
nil)
(t ; need to process &, ?, and #'s
@@ -2664,7 +2669,8 @@ Keeps argument list for future Ispell invocations
for no async support."
(let ((process-connection-type ispell-use-ptys-p))
(apply 'start-process
"ispell" nil ispell-program-name
- "-a" ; Accept single input lines.
+ ;; -a makes problems with choices when using hunspell
and utf-8
+ (if ispell-really-hunspell "" "-a")
;; Make root/affix combos not in dict.
;; hunspell -m option means different.
(if ispell-really-hunspell "" "-m")
@@ -2752,30 +2758,34 @@ Keeps argument list for future Ispell
invocations for no async support."
(set-process-coding-system ispell-process
(ispell-get-coding-system)
(ispell-get-coding-system)))
;; Get version ID line
- (ispell-accept-output 3)
- ;; get more output if filter empty?
- (if (null ispell-filter) (ispell-accept-output 3))
- (cond ((null ispell-filter)
- (error "%s did not output version line" ispell-program-name))
- ((and
- (stringp (car ispell-filter))
- (if (string-match "warning: " (car ispell-filter))
- (progn
- (ispell-accept-output 3) ; was warn msg.
- (stringp (car ispell-filter)))
- (null (cdr ispell-filter)))
- (string-match "^@(#) " (car ispell-filter)))
- ;; got the version line as expected (we already know it's
the right
- ;; version, so don't bother checking again.)
- nil)
- (t
- ;; Otherwise, it must be an error message. Show the user.
- ;; But first wait to see if some more output is going to
arrive.
- ;; Otherwise we get cool errors like "Can't open ".
- (sleep-for 1)
- (ispell-accept-output 3)
- (error "%s" (mapconcat 'identity ispell-filter "\n"))))
- (setq ispell-filter nil) ; Discard version ID line
+ (if (not (eq ispell-program-name "hunspell"))
+ (progn
+ (ispell-accept-output 3)
+ ;; get more output if filter empty?
+ (if (null ispell-filter) (ispell-accept-output 3))
+ (cond ((null ispell-filter)
+ (error "%s did not output version line"
ispell-program-name))
+ ((and
+ (stringp (car ispell-filter))
+ (if (string-match "warning: " (car ispell-filter))
+ (progn
+ (ispell-accept-output 3) ; was warn msg.
+ (stringp (car ispell-filter)))
+ (null (cdr ispell-filter)))
+ (string-match "^@(#) " (car ispell-filter)))
+ ;; got the version line as expected (we already know
it's the right
+ ;; version, so don't bother checking again.)
+ nil)
+ (t
+ ;; Otherwise, it must be an error message. Show the
user.
+ ;; But first wait to see if some more output is
going to arrive.
+ ;; Otherwise we get cool errors like "Can't open ".
+ (sleep-for 1)
+ (ispell-accept-output 3)
+ (error "%s" (mapconcat 'identity ispell-filter "\n"))))
+ (setq ispell-filter nil) ; Discard version ID line
+ )
+ )
(let ((extended-char-mode (ispell-get-extended-character-mode)))
(if extended-char-mode ; ~ extended character mode
(ispell-send-string (concat extended-char-mode "\n"))))
Have a nice day!
Basti
--
ETH Zürich, Bastian Ballmann, IT Service Group
CAB E 44.1, Universitätsstrasse 6, CH-8092 Zürich
Tel +41 44 632 72 04
next reply other threads:[~2012-10-09 12:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-09 12:32 Bastian Ballmann [this message]
2012-10-10 10:48 ` bug#12611: Bugfix for broken hunspell choices Agustin Martin
2012-10-10 15:57 ` Eli Zaretskii
2012-10-11 10:53 ` Agustin Martin
2018-08-28 23:00 ` Noam Postavsky
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=5074194B.6040305@inf.ethz.ch \
--to=bastian.ballmann@inf.ethz.ch \
--cc=12611@debbugs.gnu.org \
/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).