public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@palves.net>
To: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 5/5] Add "save history" command
Date: Mon, 30 Jan 2023 15:12:27 +0000	[thread overview]
Message-ID: <f5a62879-5261-9c71-2582-e7f1ea0e9276@palves.net> (raw)
In-Reply-To: <cd5cce49-b773-6f6b-2f30-6dbf90df88ba@palves.net>



On 2023-01-30 2:50 p.m., Pedro Alves wrote:
> On 2023-01-29 4:21 p.m., Tom Tromey wrote:
>>  
>> +@kindex save history
>> +@item save history @var{filename}
>> +Occasionally you may want to save your history to a file.  This
>> +command will do just that, saving the commands in your current session
>> +to the named file.  Note that you should normally edit the saved
>> +history before using @code{source} to reload it, as the @code{save
>> +history} command itself will be at the end of the file.
> 
> We could also suggest using "server save history" here.  Something like,
> "Alternatively, you can use the server prefix to blah, blah.  @xref."
> 
> Prefixing a comment with "server" makes it so that it won't be added to
> the history:
> 
>   https://sourceware.org/gdb/current/onlinedocs/gdb.html/Server-Prefix.html
> 

An alternative idea would be to make use of the fact that history entries are
already numbered, and to let the user say which history entry range to save.

E.g., we have:

 (gdb) help show commands 
 Show the history of commands you typed.
 You can supply a command number to start with, or a `+' to start after
 the previous command number shown.

and, e.g., I see currently:

 (gdb) show commands 
  1016  q
  1017  q
  1018  p 1
  1019  p 2
  1020  p 3
  1021  show commands
  1022  p 4
  1023  p 5
  1024  apropos history
  1025  show commands 

so we could support something like:

 (gdb) save history $filename 1020 1025  # save from 1020 to 1025

 (gdb) save history $filename 1020       # save from 1020 to $end

 (gdb) save history $filename -5         # save from 1020 ($last - 5) to end

 (gdb) save history $filename -5 -1      # save from 1020 ($last - 5) to 1024 ($last - 1)

or whatever other syntax makes sense and achieves a similar effect.

Being able to save just the last N entries seems like a useful feature.

      reply	other threads:[~2023-01-30 15:12 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-29 16:21 [PATCH 0/5] Additions to "save" command Tom Tromey
2023-01-29 16:21 ` [PATCH 1/5] Save breakpoints so they are automatically pending Tom Tromey
2023-01-31 15:14   ` Alexandra Petlanova Hajkova
2023-01-29 16:21 ` [PATCH 2/5] Move show_user_1 to cli-cmds.c Tom Tromey
2023-01-29 16:21 ` [PATCH 3/5] Add "save user" command Tom Tromey
2023-01-29 16:57   ` Eli Zaretskii
2023-01-30 14:53   ` Pedro Alves
2023-01-30 23:35     ` Tom Tromey
2023-01-29 16:21 ` [PATCH 4/5] Add "save skip" command Tom Tromey
2023-01-29 16:54   ` Eli Zaretskii
2023-01-29 16:21 ` [PATCH 5/5] Add "save history" command Tom Tromey
2023-01-29 16:56   ` Eli Zaretskii
2023-01-30 14:50   ` Pedro Alves
2023-01-30 15:12     ` Pedro Alves [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=f5a62879-5261-9c71-2582-e7f1ea0e9276@palves.net \
    --to=pedro@palves.net \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).