Re: [gedit-list] gEdit - External Tools
- From: Steve Frécinaux <steve istique net>
- To: J S <core5fedora gmail com>
- Cc: gedit-list <gedit-list gnome org>
- Subject: Re: [gedit-list] gEdit - External Tools
- Date: Sun, 25 Nov 2007 15:57:19 +0100
On Sat, 2007-11-24 at 21:45 -0500, J S wrote:
> Hi, Steve.
Hello,
> I discovered your email address from this URL:
> http://live.gnome.org/Gedit/ToolLauncherPlugin
For such support questions, it's always better to ask the gedit
mailing-list (or the relevant mailing list for other projects) instead
of contacting directly the author.
> While trying to create my own "External Tools" script, i've encountered errors.
> I wonder if you might provide a suggestion, or recommended reference.
>
> INTENT:
> I wish to be able to edit PHP files, while having a command to
> "remove" or "add comment". I realize there is an existing 'plugin' for
> this function, but it handles the character '#', not '//', or '/* ...
> */', those latter which I want.
>
> TRIED:
> Using a section of a PHP file, wherein there are several lines
> (selected) containing "php line comments" of the [//] type, I wrote
> the following script(s), in this case, to attempt to remove the
> comments:
>
> #!/bin/sh
> sed 's/[\/\/ ]*$//'
> (both with and without a 'space' after the forward slash)
> #!/bin/sh
> grep '\/([\/\/][ ])*/'
>
> and other variations, including trials with 'regsub'
>
> in each trial, i selected for gEdit to "replace current selection".
> each trial failed, though some of these efforts did show in the
> 'output', the output was the exact lines which i had selected, but
> nothing changed in the document. many trials also returned error
> numbers in the same 'output' window.
Without knowing what error messages you've encountered I can't be of
much help. Anyway, it looks to me you're misunderstanding how the tools
and regexp work. For instance, to use a regexp with grep you have to
give it the -E parameter, and [\/\/ ] will cause sed to match one char
among '/', '/' and ' ' (ie, it will match each '/' or space).
Anyway, I took two minutes to create tools that do what you want (joined
as attachments). But if commenting code with // instead of # is that
important to you, you might want to try copying the code comment plugin
into ~/.gnome2/gedit/plugins and modify it for your needs.
The tools I've attached can just be dropped into ~/.gnome2/gedit/tools,
and will show up once you've restarted gedit.
# [Gedit Tool]
# Comment=Comment Test
# Input=selection
# Name=comment-test
# Applicability=all
# Output=replace-selection
sed 's,^,//,'
# [Gedit Tool]
# Comment=A Brand New Tool
# Input=selection
# Name=uncomment-test
# Applicability=all
# Output=replace-selection
sed 's,//,,'
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]