[prev in list] [next in list] [prev in thread] [next in thread]
List: ktexteditor-devel
Subject: [PATCH] Teach katepart to understand emacs' "-*- coding: ... -*-"
From: "Vladimir V. Perepelitsa" <inthrax () gmail ! com>
Date: 2008-08-28 17:58:27
Message-ID: 200808282158.27912.inthrax () gmail ! com
[Download RAW message or body]
Very simple patch, that applies without offsets to stable versions of kdelibs
3.5.9 and 3.5.10 and affect next files:
kate/part/katedocument.cpp
kate/part/katedocument.h
Adds static QRegExp KateDocument::kvLineEmacsEncoding, and use it inside
KateDocument::readVariableLine
--
Vladimir Perepelitsa aka Mons Anderson
<inthrax@gmail.com> / #99779956
["kdelibs-3.5.9-katepart-emacs-coding.patch" (text/x-diff)]
diff -r -U5 kdelibs-3.5.9/kate/part/katedocument.cpp kdelibs-3.5.9.mod/kate/part/katedocument.cpp
--- kdelibs-3.5.9/kate/part/katedocument.cpp 2007-10-08 13:51:56.000000000 +0400
+++ kdelibs-3.5.9.mod/kate/part/katedocument.cpp 2008-08-21 11:59:30.000000000 +0400
@@ -4587,10 +4587,11 @@
/* TODO
add config options (how many lines to read, on/off)
add interface for plugins/apps to set/get variables
add view stuff
*/
+QRegExp KateDocument::kvLineEmacsEncoding = QRegExp("-\\*-\\s*coding:\\s*(.*)\\s*-\\*-");
QRegExp KateDocument::kvLine = QRegExp("kate:(.*)");
QRegExp KateDocument::kvLineWildcard = QRegExp("kate-wildcard\\((.*)\\):(.*)");
QRegExp KateDocument::kvLineMime = QRegExp("kate-mimetype\\((.*)\\):(.*)");
QRegExp KateDocument::kvVar = QRegExp("([\\w\\-]+)\\s+([^;]+)");
@@ -4631,17 +4632,24 @@
void KateDocument::readVariableLine( QString t, bool onlyViewAndRenderer )
{
// simple check first, no regex
// no kate inside, no vars, simple...
- if (t.find("kate") < 0)
+ if (t.find("kate") + t.find("-*-") < 0)
return;
// found vars, if any
QString s;
- if ( kvLine.search( t ) > -1 )
+ if ( kvLineEmacsEncoding.search( t ) > -1 )
+ {
+ s = "encoding ";
+ s.append( kvLineEmacsEncoding.cap(1) );
+
+ kdDebug (13020) << "normal variable line emacs: matched: " << s << endl;
+ }
+ else if ( kvLine.search( t ) > -1 )
{
s = kvLine.cap(1);
kdDebug (13020) << "normal variable line kate: matched: " << s << endl;
}
diff -r -U5 kdelibs-3.5.9/kate/part/katedocument.h kdelibs-3.5.9.mod/kate/part/katedocument.h
--- kdelibs-3.5.9/kate/part/katedocument.h 2007-10-08 13:51:55.000000000 +0400
+++ kdelibs-3.5.9.mod/kate/part/katedocument.h 2008-08-28 11:43:00.000000000 +0400
@@ -997,10 +997,11 @@
static bool checkColorValue( QString value, QColor &col );
/**
* helper regex to capture the document variables
*/
+ static QRegExp kvLineEmacsEncoding;
static QRegExp kvLine;
static QRegExp kvLineWildcard;
static QRegExp kvLineMime;
static QRegExp kvVar;
_______________________________________________
KTextEditor-Devel mailing list
KTextEditor-Devel@kde.org
https://mail.kde.org/mailman/listinfo/ktexteditor-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic