[RFAv2,0/3] Allow the user to define default leading args for commands and aliases

Message ID 20190805205159.31689-1-philippe.waroquiers@skynet.be
Headers show
Series
  • Allow the user to define default leading args for commands and aliases
Related show

Message

Philippe Waroquiers Aug. 5, 2019, 8:51 p.m.
Allow the user to define default leading args for commands and aliases.

This patch series implements, tests and documents the following commands:

  set leading-args COMMAND [LEADING-ARGS...]
  show leading-args [COMMAND]
  set enable-leading-args [on|off]
  show enable-leading-args


It also changes the alias command to be:
  alias [-a] [--] ALIAS = COMMAND [LEADING-ARGS...]


Using the above leading-args commands and arguments, you can
define default arguments for commands or define powerful aliases.

For example:

  alias bt_ALL = backtrace -entry-values both -frame-arg all -past-main -past-entry -full

defines the alias bt_ALL that will give as much information as possible
in a backtrace.

Leading args can usefully be combined with the 'with' command, such as:

Make "wLapPeu" an alias of 2 nested "with":
  alias wLapPeu = with language pascal -- with print elements unlimited --

or have an alias pp10 to pretty print an expression with a maximum of
10 elements:

  alias pp10 = with print pretty -- with print elem 10 -- print

This patch series also adds a completer for 'alias'.


Note 1: a preliminary version of this idea (using a command called
'add-args' was discussed in
https://sourceware.org/ml/gdb-patches/2019-06/msg00395.html
where Tom suggested to make it more GDB like, using 'set' command.

Note 2: Following another comment of Tom, there is no '=' character
to separate COMMAND from its leading args.
If ever this would be ambiguous in some cases, we could introduce
an optional '=' character to separate COMMAND from its LEADING-ARGS.
Similarly, the alias command has no separator between COMMAND
and its LEADING-ARGS.

Compared to the first version, the changes are:
  * Removed the = separator between COMMAND and LEADING-ARGS
  * Converted alias command to use the option framework.
  * Show the leading args of aliases in 'help aliases'.

Comments

Philippe Waroquiers Sept. 7, 2019, 11:43 a.m. | #1
Ping.
Thanks
Philippe

On Mon, 2019-08-05 at 22:51 +0200, Philippe Waroquiers wrote:
> Allow the user to define default leading args for commands and aliases.

> 

> This patch series implements, tests and documents the following commands:

> 

>   set leading-args COMMAND [LEADING-ARGS...]

>   show leading-args [COMMAND]

>   set enable-leading-args [on|off]

>   show enable-leading-args

> 

> 

> It also changes the alias command to be:

>   alias [-a] [--] ALIAS = COMMAND [LEADING-ARGS...]

> 

> 

> Using the above leading-args commands and arguments, you can

> define default arguments for commands or define powerful aliases.

> 

> For example:

> 

>   alias bt_ALL = backtrace -entry-values both -frame-arg all -past-main -past-entry -full

> 

> defines the alias bt_ALL that will give as much information as possible

> in a backtrace.

> 

> Leading args can usefully be combined with the 'with' command, such as:

> 

> Make "wLapPeu" an alias of 2 nested "with":

>   alias wLapPeu = with language pascal -- with print elements unlimited --

> 

> or have an alias pp10 to pretty print an expression with a maximum of

> 10 elements:

> 

>   alias pp10 = with print pretty -- with print elem 10 -- print

> 

> This patch series also adds a completer for 'alias'.

> 

> 

> Note 1: a preliminary version of this idea (using a command called

> 'add-args' was discussed in

> https://sourceware.org/ml/gdb-patches/2019-06/msg00395.html

> where Tom suggested to make it more GDB like, using 'set' command.

> 

> Note 2: Following another comment of Tom, there is no '=' character

> to separate COMMAND from its leading args.

> If ever this would be ambiguous in some cases, we could introduce

> an optional '=' character to separate COMMAND from its LEADING-ARGS.

> Similarly, the alias command has no separator between COMMAND

> and its LEADING-ARGS.

> 

> Compared to the first version, the changes are:

>   * Removed the = separator between COMMAND and LEADING-ARGS

>   * Converted alias command to use the option framework.

>   * Show the leading args of aliases in 'help aliases'.

> 

>
Pedro Alves Sept. 8, 2019, 6:50 p.m. | #2
Hi Philippe,

Do you have an updated/rebased version of this patchset
pushed somewhere?  I'd like to give it a try, but
I could no longer apply it.

On 8/5/19 9:51 PM, Philippe Waroquiers wrote:
> Allow the user to define default leading args for commands and aliases.

> 

> This patch series implements, tests and documents the following commands:

> 

>   set leading-args COMMAND [LEADING-ARGS...]

>   show leading-args [COMMAND]

>   set enable-leading-args [on|off]

>   show enable-leading-args

> 

> 

> It also changes the alias command to be:

>   alias [-a] [--] ALIAS = COMMAND [LEADING-ARGS...]

> 

> 

> Using the above leading-args commands and arguments, you can

> define default arguments for commands or define powerful aliases.


Not a bit deal, and I can definitely live with this as is.

But let me just say something that crosses my mind when I read this.

Wouldn't "set default-args" be a better name for this?

We already have "set default-collect", which is a bit similar.

But mainly, I just look at leading-args, and think like this:

what is "set leading-args"?  leading-args is a way to set the default
arguments for commands.

Even above you said:

 "you can define default arguments for commands"

:-)

Also, coming from the other direction, I can see users wondering
about this this way:

"Is there some way to specify the default arguments of a command?
 I'm kind of tired of always typing ....."

A lot more than this way:

"Is there some way to specify the leading arguments of a command?
 I'm kind of tired of always typing ....."

My 50c.

Thanks,
Pedro Alves