Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: Alfredo Ortega <ortegaalfredo@gmail.com>
Cc: gdb-patches@sourceware.org
Subject: Re: Use external editor in 'commands' command
Date: Fri, 18 Sep 2009 21:05:00 -0000	[thread overview]
Message-ID: <m3tyz0arqj.fsf@fleche.redhat.com> (raw)
In-Reply-To: <e598931c0908281516wc1505efga0146982975f3f6f@mail.gmail.com> 	(Alfredo Ortega's message of "Fri, 28 Aug 2009 19:16:00 -0300")

>>>>> "Alfredo" == Alfredo Ortega <ortegaalfredo@gmail.com> writes:

Alfredo> Sorry Tom for the very late answer. But I think I got all your
Alfredo> recommendations implemented on the patch.

Thanks.  And, I'm also sorry for the delay in this response :-)

Alfredo> Except that I couldn't find a way to do a cleanup erasing a file,
Alfredo> without resorting to the ui_file functions.

You can make a new handler function and directly call make_cleanup.
Search for make_cleanup, there are plenty of examples of this.

Alfredo> +  if (outfile==NULL)
Alfredo> +      error (_("Can't create temporary file for editing."));

The if should be written:  if (outfile == NULL).
The GNU style puts spaces around operators.

Also the second line is indented too far.

Alfredo> +/* Launches the editor on the breakpoint command.  
Alfredo> +   bnum is the breakpoint number.

Write "BNUM" instead.  See the coding styles for the reason.

Alfredo> +  ALL_BREAKPOINTS (b)
Alfredo> +    if (b->number == bnum)
Alfredo> +      {
Alfredo> +        if (&b->commands)

This check is wrong.  &b->commands will never be NULL.
You meant just 'if (b->commands)'.

Alfredo> +	  commands_dump_to_file (vitmp, b);
Alfredo> +        /* Edit the file.  */
Alfredo> +	cmdline = xstrprintf("%s \"%s\"",editor,vitmp);

Indentation is weird.  I guess you are mixing tabs and spaces.
Exactly which to use is often discussed; but being inconsistent is worse
than just picking one :-)

Alfredo> +        if (WEXITSTATUS(sysret) > 0)

Add a space before the "(".  This problem occurs in several places,
please fix them all.  (But this rule does not apply to "_("... fun :-)

Alfredo> +static void
Alfredo> +check_executing_commands ()

Use (void), not ().

Alfredo> +/* Like commands_command but using an external editor.  */
Alfredo> +static void
Alfredo> +edit_command (char *args, int from_tty)

Rather than duplicate a lot of commands_command, I think it would be
preferable to refactor this: rename commands_command, add an argument
indicating whether an editor should be used, and then have the new
commands_command and edit_command call the internal function.

Then you don't need check_executing_commands, either.

Alfredo> +        b->commands = l;
Alfredo> +        breakpoints_changed ();
Alfredo> +        observer_notify_breakpoint_modified (b->number);

Also, update to CVS head.  I think we're using breakpoint_set_commands now.

Alfredo> +  add_cmd ("edit", class_breakpoint, edit_command,_("\
Alfredo> +Edit the command using the external-editor variable, EDITOR environment\n\
Alfredo> +variable or /bin/ex, in that precedence."),

I think this needs a bit more documentation.  Maybe:

Like `commands', but edit the commands using an editor.
If there is an external editor (see `help set external-editor'), then
that is used.  Otherwise, if the EDITOR environment variable is set,
then it is used.  If all else fails, `/bin/ex' is used.

Alfredo> +@table @code
Alfredo> +@item set external-editor
Alfredo> +@kindex set external-editor
Alfredo> +This command controls the external text editor that internal gdb commands use. The external-editor variable has precedence over the @code{EDITOR} enviroment variable.

This at least needs some line breaks.

Tom


      reply	other threads:[~2009-09-18 21:05 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <e598931c0901141343j79164cf6we2bc5307f41f41da@mail.gmail.com>
2009-01-14 21:48 ` Alfredo Ortega
2009-01-14 22:38   ` Eli Zaretskii
2009-01-15  1:55     ` Alfredo Ortega
2009-01-22  3:25       ` dgutson
     [not found]     ` <e598931c0901141632m4f124d85l2452f7e2870cad91@mail.gmail.com>
2009-01-15  4:21       ` Eli Zaretskii
2009-01-16  7:39         ` Alfredo Ortega
2009-01-16  9:07           ` Eli Zaretskii
2009-01-16 22:08             ` Alfredo Ortega
2009-01-16 23:38               ` Daniel Jacobowitz
2009-01-16 23:58                 ` Tom Tromey
2009-01-17  9:27                   ` Eli Zaretskii
2009-01-16 23:56               ` Tom Tromey
2009-01-17  9:29               ` Eli Zaretskii
2009-01-19 11:45                 ` Alfredo Ortega
2009-02-02 22:18                   ` Tom Tromey
2009-02-19 20:05                     ` Alfredo Ortega
2009-02-19 20:26                       ` Alfredo Ortega
2009-02-24 20:20                         ` Tom Tromey
2009-08-28 23:17                           ` Alfredo Ortega
2009-09-18 21:05                             ` Tom Tromey [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3tyz0arqj.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=ortegaalfredo@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox