! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
Add an option to pipe the text to an external command.
Status:
RESOLVED: MOVED
Product:
Mousepad
Component:
General

Comments

Description negora 2014-08-21 09:50:35 CEST
Because we all have very different needs, and I guess that you don't want Mousepad to be bloated with too specific options, it would be good to have an option to pipe the text to an external command or script. This way the experienced users could extend the functionality of the editor (up to some point) without the need to request new features every time.

For example, one could pipe the text to the command "sort" and have all lines ordered.

I don't know how complicated it would be to program something like this, specially because of the possibility to undo the operation. But on a first stage it could be a irreversible operation, warning the user before, of course.
Comment 1 Andre Miranda editbugs 2014-09-06 01:39:46 CEST
This seems interesting, but we need to specify it better.

How would the external command be called?
By hotkeys, an input field as the search bar or both?
A toolbar button with a dropdown list of saved commands?
Would we consider the return 0 as success and reject anything else?

Another point is that this needs to be executed in another thread combined with a dialog asking the user to wait + a cancel button. This would prevent the UI to block while big files and/or intense processing commands are being executed.
Comment 2 negora 2014-09-10 18:18:36 CEST
There is a plug-in for gEdit 2.x called "External tool" from which I took this idea. Mousepad doesn't need something so complex, but I guess that it could take some ideas from it. In this plug-in there is a configuration menu that allows you to write a custom shell script, give it a name, and set the input and the output: The whole document, the current selection only, all opened documents... Once it's defined, you can call the desired shell script from a list in the "Tools" menu.

In my opinion, Mousepad would have enough with a configuration menu to specify a command or script (its path), a name, the input and the output, limiting the later to the current selection and the whole document. Nothing else.

Then, the command could be called from a simple tree menu, as it's done in gEdit.
Comment 3 Matthew Brush editbugs 2014-09-11 02:09:00 CEST
Geany implements this feature pretty well. If I remember correctly it uses g_spawn_async_with_pipes() and GIOChannels to prevent blocking (though it doesn't work async on Windows due to GLib bug, not that it matters much for Mousepad). It has a dialog that lets user add commands and labels for them and assigns an ID to each command. The commands are accessible through a menu (though in Geany it's too deeply nested, IMO), and also by pressing Ctrl+N where N is the ID of the command. For example I have `sort -u` as ID 1 (Ctrl+1) and own little Python script that adds newline escapes to C preprocessor defines nicely aligned as ID 2 (Ctrl+2).

I agree this would be a super useful feature, but I wonder how many different features like this would be added, and whether it would be better to just bite the bullet and add "plugin" support using LibPeas to save some code/bugs/bloat. I actually have a local branch that adds Peas plugin support to Mousepad and exposes 3 GObject interfaces for plugins to use (same ones as SublimeText and Gedit). Not counting GObject boilerplate, I'd estimate that total integration of Peas would require less code than even implementing this single feature similar to how Geany does.
Comment 4 Andre Miranda editbugs 2014-09-11 02:30:38 CEST
I think of this external command feature like a quick-n-dirt way to extend mousepad functions, like a poor man's plugin system, albeit kinda kludge it's also very powerful, easy to create crazy things and unix-like.
A real plugin system is very neat, but I don't see mousepad as gedit, a really simple text editor that can be incredibly extends via plugins, nor as geany, a simple IDE also extensible via plugins.
Comment 5 Andre Miranda editbugs 2014-09-17 03:29:40 CEST
Just as another reference, mEdit has this feature too.
Comment 6 Git Bot editbugs 2020-05-24 01:28:20 CEST
-- GitLab Migration Automatic Message --

This bug has been migrated to xfce.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.xfce.org/apps/mousepad/-/issues/10.

Please create an account or use an existing account on one of our supported OAuth providers. 

If you want to fork to submit patches and merge requests please continue reading here: https://docs.xfce.org/contribute/dev/git/start#gitlab_forks_and_merge_requests

Also feel free to reach out to us on the mailing list https://mail.xfce.org/mailman/listinfo/xfce4-dev

Bug #11097

Reported by:
negora
Reported on: 2014-08-21
Last modified on: 2020-05-24

People

Assignee:
Matthew Brush
CC List:
2 users

Version

Version:
Unspecified
Target Milestone:
Mousepad 0.2.x

Attachments

Additional information