jEdit Community - Resources for users of the jEdit Text Editor
New unindentThisLine property
Submitted by Anonymous on Monday, 14 March, 2005 - 22:24
I don't know if this is user error, or a bug, so I thought I'd start in the troubleshooting forum.

I constantly use jEdit to edit Ruby scripts (whose files end in .rb). Ruby uses a lot of keywords to specify blocks and other areas where one might want to indent. For example

def foo( num )
     a=1
     begin
         # some code
         if a==1
             # more code
         elsif a==2
             # more code
         else
             # blah
         end
         # yadayadayada
     end
     return a
end

I can get indenting to work just fine when I use the indentNextLines="\s*((if\s+.*|elsif\s+.*|else\s*|do(\s*|\s+.*)|case\s+.*|when\s+.*|while\s+.*|for\s+.*|until\s+.*|loop\s+.*|def\s+.*|class\s+.*|module\s+.*|begin.*|unless\s+.*)*)"

However, if I add a unindentThisLine property, not only does it not work, it screws up my indentNextLines property. The following is how the same code above would look with indentThisLine="\s*((end\s*|else\s*|elsif\s+)*)"

def foo( num )
a=1
begin
# some code
if a==1
# more code
elsif a==2
# more code
else
     # blah
end
     # yadayadayada
return a
end

Normally, with only using the indentNextLines, I would get proper indentation after the begin, def, if, elsif and else statements. If I add the unindentThisLine property, not only do the lines not get unindented at the right time, but the indentNextLines breaks. As you can see in the above example, I only got indentation *after* and "else" or an "end" (which were specified in unindentThisLine). And only the next line was indented, after that it unindented.

So, it seems that the addition of unindentThisLine break indentNextLine, plus anything I specify in unindentThisLine does not unindent, but rather indents the next (and only the next 1) line.

Am I doing something wrong? Or is this a bug?
Comment viewing options
Select your preferred way to display the comments and click 'Save settings' to activate your changes.
Okay, I think I figured it ou
by Anonymous on Wed, 16/03/2005 - 03:54
Okay, I think I figured it out. To get the above indenting actions, I added the following properties to the ruby.xml mode file (with brackets replaced by < and > of course):

[PROPERTY NAME="unindentThisLine" VALUE="\s*(end\s*|else\s*|elsif\s+.*)\s*" /]
[PROPERTY NAME="electricKeys" VALUE="\s*(end\s*|else\s*|elsif\s+.*)\s*" /]
[PROPERTY NAME="unindentNextLines" VALUE="\s*(end\s*|else\s*|elsif\s+.*)\s*" /]
User login
Browse archives
« March 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
31
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   82338
Context Free Art (*.cfdg)   0.31   46042
JBuilder scheme   .001   18486
BBEdit scheme   1.0   18107
ColdFusion scheme   1.0   18015
R Edit Mode - extensive version   0.1   17461
Advanced HTML edit mode   1.0   16194
Matlab Edit Mode   1.0   16056
jEdit XP icons   1.0   15220
XP icons for jEdit   1.1   14281