Bug 122448 - Incorrect options at ASPELL spell checker
Summary: Incorrect options at ASPELL spell checker
Status: RESOLVED WORKSFORME
Alias: None
Product: kdelibs
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-21 21:46 UTC by Peter Tselios
Modified: 2008-08-13 18:00 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Tselios 2006-02-21 21:46:19 UTC
Version:            (using KDE KDE 3.5.1)
Installed from:    SuSE RPMs
OS:                Linux

First of all the basics:
Installation: Suse 10/KDE 3.5.1 from Suse's RPMS
Spell checker: ASPELL with English and Greek dictionaries (Greek is the default)
Default encoding for KDE: UTF-8
Default encoding for Aspell: ISO8859-7, Greek Aspell

I hope that the following are not bugs and that I will be able to solve the problem using a "hidden" (or unkown if you prefer) option. In this case, please accept my apologies.

The problems:
Problem A:
When I open a file with ISO-885--7 encoding to any text editor (Kate, Quanta, KWrite etc) the spellchecking is not working. This is completely normal, since the aspell is not aware of the document's encoding. 
The "ps -ef | grep -i aspell" output is:
aspell -a -S -H -m -B -d el
the correct one is: aspell -a -S -H -m -B -d el --encoding=ISO-8859-7

Problem B:
ASpell is checking the html tags when we open php documents:
Lets say for example, that we have an HTML document, named spell.html.
The aspell is invoked with the (partially correct) command "aspell -a -S -H -m -B -d el"

If we rename the document to spell.php (whithout adding a single php tag) then, a spell is invoked using the command "aspell -a -S -m -B -d el" The HTML filter is not invoked. Obsiously, it' s not a solution to add the php extension to the html files, but to include php documents to the files that uses the html filter.
Comment 1 Anders Lund 2006-02-21 22:03:13 UTC
Kate has no hidden options.

I'll look into fixing it for Kate 2.5.2.
Comment 2 Peter Tselios 2006-02-21 22:07:24 UTC
Dear Anders,
     This is a **quick** answer! That's why I said "hidden" and not hidden! 
Comment 3 Anders Lund 2006-02-22 12:32:41 UTC
SVN commit 512373 by alund:

* Use HTML type for docbook and PHP
* Attempt to use the document encoding if supported by KSpell, though KSpell seems to be so full of errors that this is redundant :-( (but maybe some can be fixed)

CCBUG: 122448


 M  +16 -2     katespell.cpp  


--- branches/KDE/3.5/kdelibs/kate/part/katespell.cpp #512372:512373
@@ -29,6 +29,7 @@
 #include <kaction.h>
 #include <kstdaction.h>
 #include <kspell.h>
+#include <ksconfig.h>
 #include <kdebug.h>
 #include <kmessagebox.h>
 
@@ -102,11 +103,24 @@
   KSpell::SpellerType type = KSpell::Text;
   if ( mt == "text/x-tex" || mt == "text/x-latex" )
     type = KSpell::TeX;
-  else if ( mt == "text/html" || mt == "text/xml" )
+  else if ( mt == "text/html" || mt == "text/xml" || mt == "text/docbook" || mt == "application/x-php")
     type = KSpell::HTML;
 
+  KSpellConfig *ksc = new KSpellConfig;
+  QStringList ksEncodings;
+  ksEncodings << "US-ASCII" << "ISO 8859-1" << "ISO 8859-2" << "ISO 8859-3"
+      << "ISO 8859-4" << "ISO 8859-5" << "ISO 8859-7" << "ISO 8859-8"
+      << "ISO 8859-9" << "ISO 8859-13" << "ISO 8859-15" << "UTF-8"
+      << "KOI8-R" << "KOI8-U" << "CP1251" << "CP1255";
+
+  int enc = ksEncodings.findIndex( m_view->doc()->encoding() );
+  if ( enc > -1 )
+    ksc->setEncoding( enc );
+
+  kdDebug(13020)<<"KateSpell::spellCheck(): using encoding: "<<enc<<" ("<<ksEncodings[enc]<<") and KSpell::Type "<<type<<" (for '"<<mt<<"')"<<endl;
+
   m_kspell = new KSpell( m_view, i18n("Spellcheck"),
-                         this, SLOT(ready(KSpell *)), 0, true, true, type );
+                         this, SLOT(ready(KSpell *)), ksc, true, true, type );
 
   connect( m_kspell, SIGNAL(death()),
            this, SLOT(spellCleanDone()) );
Comment 4 Christoph Cullmann 2008-08-13 18:00:33 UTC
Seems to work, not sure, please reopen, if not...