Bug 125974

Summary: Setting encoding from .kateconfig doesn't fully work
Product: [Applications] kate Reporter: Niels <niels.misc>
Component: encodingAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: christoph, cyberbeat
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Niels 2006-04-20 21:01:08 UTC
Version:            (using KDE KDE 3.5.2)
Installed from:    Gentoo Packages

This is related to bug #125417 and might well be a Kate-bug.

I've made a .kateconfig. Kdevelop clearly uses it, but still files aren't shown correctly.

Example: I have a file in 8859-1 with Danish characters in it. They are displayed as squares, but the encoding is set correctly at 8859-1. If I change the encoding (tools->encoding), the characters are displayed accordingly -- but the setting doesn't change! It's stuck at 8859-1.

So it would seem the only the setting (not the display) is affected by the .kateconfig. The save-as dialogue has the correct 8859-1 option selected.
Comment 1 Jens Dagerbo 2006-04-21 17:42:48 UTC
Yes, this would be a katepart bug. KDevelop doesn't read the .kateconfig file, katepart does and the menu action is merged in by katepart.

Reassigning.
Comment 2 Dominik Haumann 2009-06-04 23:07:11 UTC
Kate sets the encoding after loading the file, but it doesn't reload the file with the right encoding.

Still valid in KDE4.
Comment 3 Dominik Haumann 2009-06-04 23:34:40 UTC
related bug for kate modelines: bug #125974
Comment 4 Dominik Haumann 2009-06-05 00:01:00 UTC
related bug for kate modelines: bug #187033  (comment #8 is wrong number)
related bug for modes/filetypes: bug #159135
Comment 5 Dominik Haumann 2010-02-19 13:19:34 UTC
*** Bug 202409 has been marked as a duplicate of this bug. ***
Comment 6 H.H. 2010-07-25 12:27:44 UTC
Please, please please someone have a look at this. This bug exists for years now, and I think will be easy to fix for someone who has good knowledge of the kate code.

I fixed this bug successfully for the kde3 version, see

http://reviewboard.kde.org/r/1915/

but when I apply the same bugfix strategy for the kde4-version, it works (and I really patch every new kate-package in my opensuse installation with my fix), but not completely (the menubar-entry is not updated), and I could not figure out, how to fix that.

I have so many projects with different encoding, and this feature really helps me much to not mess up my files in different directory trees.
Comment 7 H.H. 2010-07-25 12:30:20 UTC
here is my actual diff, that I apply regularly for me:


Index: document/katedocument.cpp
===================================================================
--- document/katedocument.cpp   (Revision 1150298)
+++ document/katedocument.cpp   (Arbeitskopie)
@@ -2070,6 +2070,11 @@
   history()->doEdit( new KateEditInfo(Kate::CloseFileEdit, documentRange(), QStringList(), KTextEditor::Range(0,0,0,0), QStringList()) );
   emit KTextEditor::Document::textRemoved(this, documentRange());
 
+
+  // read dir config (if possible and wanted)
+  if (!m_reloading)
+    readDirConfig ();
+
   bool success = m_buffer->openFile (localFilePath());
 
   // disable view updates
@@ -2087,9 +2092,6 @@
     // update file type
     updateFileType (KateGlobal::self()->modeManager()->fileType (this));
 
-    // read dir config (if possible and wanted)
-    readDirConfig ();
-
     // read vars
     readVariables();
Comment 8 H.H. 2012-01-05 19:47:47 UTC
could you please please fix this bug?
Comment 9 Christoph Cullmann 2012-11-01 16:40:53 UTC
Sorry, but just applying your patch won't cut it, as then we have no longer the filetype => dir config => variables levels.
Comment 10 H.H. 2012-11-01 16:55:12 UTC
btw I have a review request pending here:

https://git.reviewboard.kde.org/r/106420

How do you think can this problem be solved? I am willing to invest some more work, if you could explain me how I should do it right.
Comment 11 Christoph Cullmann 2012-11-01 17:25:12 UTC
Git commit 902ce49204de1035910cc504e249fd0eacf64471 by Christoph Cullmann.
Committed on 01/11/2012 at 18:23.
Pushed by cullmann into branch 'master'.

add encoding: xxxx modeline
change order of reading of variables that it can have effects for load/save for .kateconfig and on save for variable in the file itself
REVIEW: 106420
needed more modifications than in review request 106420, otherwise we regress

M  +8    -0    doc/kate/configuring.docbook
M  +33   -24   part/document/katedocument.cpp
M  +10   -2    part/mode/katemodemanager.cpp
M  +1    -1    part/mode/katemodemanager.h

http://commits.kde.org/kate/902ce49204de1035910cc504e249fd0eacf64471
Comment 12 Christoph Cullmann 2012-11-01 17:51:57 UTC
I am sorry your review request got not action that long. I look at it and fixed the remaining problems myself. Thanks for the contribution, btw.!
Comment 13 H.H. 2012-11-01 20:05:38 UTC
thank you very much! You just made my day!