jEdit Community - Resources for users of the jEdit Text Editor
question
Submitted by McSwell on Thursday, 19 April, 2007 - 14:11
I'm trying to add special coloring for #ifdef (etc.) in Python files. These constructions are not a part of standard Python, hence not included in the standard jEdit Python mode. That is, my intention is to use the built-in Python coloring for all the normal Python keywords etc., and to extend this by adding a different coloring for #ifdef etc.

I did the following: to my user's 'catalog' file (i.e. the one in c:\documents and settings\<username>\.jedit\modes) I added the following line:

<MODE NAME="python2" FILE="python.xml" FILE_NAME_GLOB="*.py" />

Then I created in that same directory a file python.xml, which leaving out the usual stuff has the following:

<RULES>
<IMPORT DELEGATE="python::MAIN"/>
<KEYWORDS>
<KEYWORD4>#ifdef</KEYWORD4>
</KEYWORDS>
</RULES>

(I tried to indent the above, but I'm not sure how to do that in this forum...) And of course I set a special color for KEYWORD4 in jEdit's Utilities | Global Options: Syntax Highlighting.

If I'm understanding the documentation in the jEdit Help, this is the recommended way to extend a built-in coloring.

But it doesn't work. That is, I don't get any special coloring for #ifdef, only the normal Python coloring.

I have ruled out a number of things that I could be doing wrong. Specifically, I get #ifdef colored appropriately (as KEYWORD4) if I leave out the <IMPORT DELEGATE> line--but then I of course don't get any of the normal Python coloring. I have also verified that there are no KEYWORD4 tags in the original (as-shipped) python.xml file.

So what am I doing wrong?

Mike Maxwell
Comment viewing options
Select your preferred way to display the comments and click 'Save settings' to activate your changes.
answered my own Q
by McSwell on Thu, 19/04/2007 - 14:20
Aargh, I think I just found the answer...because the #ifdef starts with a '#', which is the Python comment char, the definition of '#' in the <EOL_SPAN> tag for comments overrides its use as a keyword. I'll have to experiment with maybe using a rule tag, instead of a keyword, to color the #ifdef...
User login
Browse archives
« November 2024  
MoTuWeThFrSaSu
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
Poll
Are you interested in language packs for jEdit?
Yes, and I could help maintain translations
26%
Yes, I'd like to have translations
32%
Indifferent
35%
No, that'd be bad (please comment)
7%
Total votes: 1093
Syndication
file   ver   dls
German Localization light   4.4.2.1   101634
Context Free Art (*.cfdg)   0.31   46062
BBEdit scheme   1.0   18601
JBuilder scheme   .001   18502
ColdFusion scheme   1.0   18031
R Edit Mode - extensive version   0.1   17481
Advanced HTML edit mode   1.0   16213
Matlab Edit Mode   1.0   16075
jEdit XP icons   1.0   15236
XP icons for jEdit   1.1   14300