public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Philippe Waroquiers <philippe.waroquiers@skynet.be>
To: gdb-patches@sourceware.org
Subject: [RFAv7 0/3] Allow the user to define default args for aliases
Date: Sun, 14 Jun 2020 18:39:39 +0200	[thread overview]
Message-ID: <20200614163942.19176-1-philippe.waroquiers@skynet.be> (raw)

Allow the user to define default args for user-defined aliases.

This is version 7 of the patch series.
Compared to version 6, it implements the prevention of
defining an alias of an alias having default args, as suggested
by Simon.

This prevention is implemented in cli-cmds.c validate_aliased_command
(which is valid_command_p renamed and modified).

The default-args.exp test was enhanced to test this prevention.

In the documentation, the following sentence was added in @node Aliases:
@var{COMMAND} can also be the name of an existing alias.  In this case,
@var{COMMAND} cannot be an alias that has default arguments.


The version 6 of the patch series did the following changes,
compared to the previous version:
  * it handles the comment of Simon that default args should only
    be available for user-defined aliases and not for GDB commands
    and GDB pre-defined aliases.
    As default args are now only for user-defined aliases,
    the 'show/set enable-default-args [on|off]' commands have been
    removed.
  * documentation changed accordingly.
  * help and apropos now shows the full definition of the aliases having
    default args.

Previous versions handled the comments of Christian/Eli/Pedro/Tom/Simon.

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

  set default-args ALIAS [DEFAULT-ARGS...]
  show default-args [ALIAS]

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


Using the above default-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.

Default 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'.

For what concerns changing 'alias -a' to 'alias -abbreviation":
This can for sure be done (and be backward compatible).  This can however
be done as a separate patch (I still also need to do a similar change
for the 'qcs' flags).



             reply	other threads:[~2020-06-14 16:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-14 16:39 Philippe Waroquiers [this message]
2020-06-14 16:39 ` [RFAv7 1/3] default-args: allow to define default arguments " Philippe Waroquiers
2020-06-20 19:26   ` Simon Marchi
2020-06-14 16:39 ` [RFAv7 2/3] Add tests for new default-args related commands and arguments Philippe Waroquiers
2020-06-14 16:39 ` [RFAv7 3/3] NEWS and documentation for default-args related concept and commands Philippe Waroquiers
2020-06-20 19:24 ` [RFAv7 0/3] Allow the user to define default args for aliases Simon Marchi
2020-06-21 11:48   ` Philippe Waroquiers

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=20200614163942.19176-1-philippe.waroquiers@skynet.be \
    --to=philippe.waroquiers@skynet.be \
    --cc=gdb-patches@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).