Bug 93398 - Ability to reformat paragraphs
Summary: Ability to reformat paragraphs
Status: RESOLVED DUPLICATE of bug 78813
Alias: None
Product: kate
Classification: Applications
Component: general (show other bugs)
Version: 2.3.1
Platform: unspecified Linux
: NOR wishlist
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-11-16 22:50 UTC by Nicolas Girard
Modified: 2011-07-11 20:08 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nicolas Girard 2004-11-16 22:50:23 UTC
Version:           2.3.1 (using KDE 3.3.1 (CVS >= 20041110), Mandrake Linux Cooker i586 - Cooker)
Compiler:          gcc version 3.4.1 (Mandrakelinux 10.1 3.4.1-4mdk)
OS:                Linux (i686) release 2.6.8.1-10mdk

What I'm much often missing in Kate is the ability to
reformat paragraph in a more or less clever way.

IMHO, such an action should, at least:
- split lines that are too long and fill
  lines that are too short, regarding a maximum
  column number which could profitably be modified;
  if may default to 72 or so;
- indent the paragraph with respect for the first
  line

Ideally it should also recognize bulleted/numbered
lists, such as the wonderful Text::Autoformat perl 
package (http://search.cpan.org/~dconway/Text-Autoformat-1.12/lib/Text/Autoformat.pm),
but I guess I'm asking too much, and at that stage
a call to an external tool could be used instead. 
Or else... ?

Thanks in advance !
Comment 1 Anders Lund 2004-11-16 23:24:15 UTC
This is really a job for the text filter, imo. You can select text and enter a shell command to filter the selection through, you could even use perl with module.
When I get the time, the text filter will hae a history, and it will be possible to create actions with shortcuts using them them.
Comment 2 Nicolas Girard 2004-11-17 00:11:39 UTC
> This is really a job for the text filter, imo.

Anders,
I agree that the text filter may be a good candidate for the job ; actually I
succeeded in running a script using the perl Text::Autoformat filter through it.

But this solution suffer from at least 2 things:

- you cannot run it by typing a single shortcur yet ; as you said you'll
  enhance the text filter this point could vanish
- it introduces an external dependancy ; not all Kate users will be able
  to take advantage of it ; as ther's no official text reformatter, users
  and especially beginners will be left alone to choose a proper tool ; no
  standard behaviour or customization will lead to less documented or 
  undocumented feature, which most users won't notice.

  On the other hand such an action would perfectly fit into the core
  of kate IMHO, the more so as it may be even more useful than the
  existing "Capitalize" or "To Lowercase" features.
 
Comment 3 Jerome Quelin 2006-05-03 19:40:15 UTC
see also bug #78813
Comment 4 Daniel Richard G. 2006-05-04 06:06:37 UTC
An improved text filter facility would be nifty.

It would be awkward, however, if you always had to select the text that a filter is to operate on (or, absent that, have the filter run on the whole document). This would certainly be a bad interface to the previously-discussed paragraph-reformatting routine---you'd have to exactly select the paragraph every time.

It would be great to be able to define a filter that operates on "the current paragraph," with an assumed paragraph separator of /\n\s*\n/. Extending the concept, you could have another option that filters just "the current line." Extending it even further, you could allow filtering "the current chunk of text between two instances of this arbitrary regex." But that might make the editor Too Powerful(tm), and therefore dangerous in the hands of untrained n00bies :-)

In the end, however, I have to agree with Mr. Girard. Kate really should have a simple paragraph-reformatting routine built-in. Nearly every decent editor out there has one, and in this "Advanced Text Editor" it is sorely lacking.
Comment 5 Dominik Haumann 2006-05-04 08:12:33 UTC
You can use scripting to do this, see [1]. If you implement it with a 
script, you can attach it to this bug report :)

[1] http://www.kate-editor.org/article/scripting_katepart_with_javascript
Comment 6 Daniel Richard G. 2006-05-05 08:06:32 UTC
Oh, the scripting functionality is fine. My point, however, is that a simple reformatter should be part of the core feature set. Functions like "Join Lines," "Capitalize" et al. could also be handled via scripting, but there's a line where you expect a modern text editor to have certain common/universal functions built-in.

(The point is well-taken for an advanced reformatter, however. It would be unreasonable to expect Kate to include something like Text::Autoformat.)
Comment 7 Dominik Haumann 2010-02-20 23:42:37 UTC
Information of how to implement this as a script can be found here:
http://docs.kde.org/development/en/kdesdk/kate/advanced-editing-tools-scripting.html
Comment 8 Dominik Haumann 2011-07-11 20:08:19 UTC
simple reformatter also requested in bug #78813. Please have a look at the last comment, because you can now implement it easily through our scripting facilities.

I'd be willing to add this to the default Kate installation! Please contribute! :)

*** This bug has been marked as a duplicate of bug 78813 ***