Bug 87682 - indent won't work correct for perl
Summary: indent won't work correct for perl
Status: RESOLVED DUPLICATE of bug 91414
Alias: None
Product: kate
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-08-21 14:05 UTC by Martin Fernau
Modified: 2007-12-07 07:05 UTC (History)
2 users (show)

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 Martin Fernau 2004-08-21 14:05:59 UTC
Version:            (using KDE KDE 3.3.0)
Installed from:    Gentoo Packages
Compiler:          gcc 3.3.4-r1 
OS:                Linux

Hi all, 
 
the indent for the perl-module isn't working correct! 
I tried to use the c-, python- and normal-style but none is working in the right way.
To explain my problem, I give you two examples.
 
if I have this construct: 
} else { <-
| 
}

or:
sub xy {
   for () { <-
|
   }
}
 
After pressing enter on the '<-' marked position, my cursor is at the place marked with the '|'. No indent... My examples applies to the c-style ident.
For c++-Code instead, the indent is working correct. This seems to be only affected by the perl-highlight-module?

kdevelop also use the kate-part. So, kdevelop is also affected by this problem!

Regards,
Martin
Comment 1 Anders Lund 2004-09-28 12:38:09 UTC
The cstyle indent is very c specific, and it integrates with the hlghlight attributes used by c-like languages. AFAIK it works with c, c++, c#, java and javascript.
Maybe we should have a more general 'bstyle' for languages using brace blocks.
Comment 2 Martin Fernau 2004-09-28 14:59:30 UTC
hm... but it worked with older versions of kate. If I set the option to indent with three spaces instead of tabs, you can see, that the cursor is placed on the 2nd column instead of the 3rd. It seems, that kate (or which ever part of it) places the cursor to the last but one position. Strange behavior
Comment 3 Anders Lund 2004-09-28 15:30:50 UTC
Kates default autoindenter simply keeps the indent.so
__x<RET>
__

The idea of more advanced autoindenters would be to automatically add or remove space according to code formatting, eg space is added after
{<RET>
etc. That is what the Cstyle indenter does, but it will not work with perl or php.
Comment 4 Martin Fernau 2004-09-28 16:03:09 UTC
And in this case, I currently have no chance to have a normal indent working for my perl skripts? kdevelop also use the same indent for which reason kdevelop is also delimited in this case? Or do I simply misunderstand something
Comment 5 Dominik Haumann 2004-09-28 17:57:39 UTC
Do you have "Keep indent profile" in the "Indentation"-section enabled? Maybe this helps. (There is still shift-return for >= KDE 3.3.0, which copys all non-letter and non-number characters from the current line; just a workaround maybe).
Comment 6 Martin Fernau 2004-09-28 18:29:50 UTC
Thanks for the tip!
I've activated the 'Keep indent profile' already, thus this won't help me. But 'shift-return' my help in the meanwhile!

Hoping, that indent will work sometimes again in kde.

Regards
Comment 7 Anders Lund 2004-09-28 22:32:32 UTC
you can use the default autoindenter, which will allways make an indentation similar to the last line with text on it. As I said, for a more sophisticated indenter for perl and php, we need a extra type.
Comment 8 Martin Fernau 2004-09-28 22:58:35 UTC
ah yes, ok. The default-indent is similar to 'shift enter' ok.
It's ok for me so far. Thanks a lot!

Regards
Comment 9 Anders Lund 2004-11-01 12:07:33 UTC
CVS commit by alund: 

FEATURE:
Add a variable based autoindenter.
This indenter matches a line and the first line with content above against
regular expressions to decide if a line should be [un]indented. When a newline
is entered, both the old and the new line is considered, and it can be triggered
to indent the current by typing one of a list of characters.
The regular expression patterns and trigger character list are read from document
variables, which can be embedded directly in the document or read from a filetype
configuration.

The following variables are used:
- var-indent-indent-after: a regular expression pattern, if the first line with content above the current, indentation is added
- var-indent-indent: a regular expression pattern, if the current line matches indent is added. this is not tested if the above matched.
- var-indent-unindent: a regular expression pattern, if it matches the current line, indent is removed.
- var-indent-triggerchars: a string of characters, when any is typed, the current line is reindented.

This should be usable for adding basic autoindentatin to bash, lua, basic, perl...
Note that kates document variables currently can't contain a semicolon, (would be a common trigger char), I'm going to fix that.

CCBUG: 87682


  M +161 -1    kateautoindent.cpp   1.36
  M +50 -10    kateautoindent.h   1.19
  M +2 -1      kateconfig.h   1.46



Comment 10 Mario Tanev 2004-11-11 04:03:40 UTC
Is there a way to add this configuration for other languages, such as scheme?

Thanks
Comment 11 Anders Lund 2004-11-11 09:06:39 UTC
You can create a filtype configuration and set the options using variables. In released versions you have kates standard autoindenter, which is the default if you turn autoindent on. The standard indenter simply keeps the indentation that is in a line. The variable based indenter will hopefully be in the next release (KDE 3.4/Kate 2.4)
Comment 12 Christoph Cullmann 2005-03-24 18:21:28 UTC
this should be remembered as "we need some more facilities for perl and co"

*** This bug has been marked as a duplicate of 91414 ***
Comment 13 Alok 2007-12-07 07:05:34 UTC
I am using KDE 3.5.5 "release 45.4" , openSUSE 10.2 (Linux (x86_64) release 2.6.18.8-0.5-default)

I found a related problem hence I'm appending it here...
When we have a perl if statement of the following form, the editor indents even the brace

Expected Result:
if($var =~ /#.*/) <return>
| <------------Cursor position(brace ( '{' ) comes here)


Observed result :
if($var =~ /#.*/) <return>
   | <---------------- Cursor position (brace is incorrectly indented

I have tried C-Style and python indentation modes and observed the same result in both the cases. I do agree that may be this happens because there is no dedicated indentation mode for perl. But it would be great if this is fixed.