geany/geany — pull request #208 by kernc (2014-01-31 22:47:26+00:00)
Title: Send selection to (run-once) custom command

In Geany, one can already send the selection to custom commands, but those have to be explicitly defined beforehand via GUI. This is not appropriate for commands that would be run infrequently.

This commit adds the feature that one can send the selection to an external command that is provided ad-hoc via a dialog input field.

It's somewhat related to this [feature request](https://sourceforge.net/p/geany/feature-requests/275/), at least its last comment.

The commit introduces two new translatable labels. "Custom Command" in the menu (currently without a mnemonic, I'd actually change that), and "Command:" in the input dialog.

If it were up to me, I'd also assign a keyboard shortcut to it, something like `Ctrl+/` if it were available (currently used for something really inessential that is roughly immitated by `Ctrl+Left`).

Say I assign `Ctrl+/` to this feature, I can easily imagine doing:
* `Ctrl+A`, `Ctrl+/`, `pastebinit`, `Enter` (and replace the GeniusPaste plugin),
* `Ctrl+A`, `Ctrl+/`, `grep -v dont_want_this`, `Enter` (which is possible with a little more complex expression with Find&Replace),
* `Ctrl+A`, `Ctrl+/`, `cut -f4`, `Enter` (which is possible through Find&Replace albeit with some thought and more typing),
* `Ctrl+A`, `Ctrl+/`, `astyle --style=k&r` or , `Enter` (and ignore all those "tidy source code feature" requests),
* `Ctrl+A`, `Ctrl+/`, `sh -c "some_line_I_need_full_shell_parsing_for"`, `Enter`,
* I could `sort` the selection, and `sort --reverse` it without adding a separate command through the GUI,
* I could even run `thunar` or `xfce4-terminal` in the current directory as they both have daemons running. (With a non-forking program, like `xterm`, I would have to close it first before continuing in Geany.)
* et cetera.

There are no sane arguments against merging this feature but the comments on my poor code. I particularly resent the `-2` magic, about which I'm totally open to ideas. :-)