Subject: bug#39179: 27.0.50; [PATCH] Add filter to gdb-mi register buffer

From: Yuan Fu <[email-masked]>
Date: Fri, 31 Jan 2020 18:08:18 -0500

> On Jan 31, 2020, at 4:56 AM, Eli Zaretskii <[email-masked]> wrote:
> 
>> From: Yuan Fu <[email-masked]>
>> Date: Sat, 18 Jan 2020 15:51:31 -0500
>> 
>> On startup, there will be a button “[filter off]” on the header line
>> of the register buffer. Clicking on it enables the register filter,
>> changes the button to “[filter on]” and adds a “[-|+]” button next to
>> it. Click “+” to add patterns to the pattern list, click “-” to
>> remove. Register whose name matches any pattern in the list is
>> displayed. You can also use key “f” for toggle, “+” to add pattern,
>> “-” to remove pattern.
> 
> I'm not sure it's a good idea to implement this as a button on the
> header-line.  Such buttons are for frequent operations, and also have
> the disadvantage of being unavailable on TTY frames.  What are the
> chances users will need to redefine the register patters frequently
> enough to justify the button?  Wouldn't it be much easier to have a
> defcustom whose value users could interactively modify as needed?

I mainly use it to display only the registers I care about, say, all the *dx registers (rdx, edx, dx) or all the r** registers (rdx, rsi, etc). And that depends on the program you are working on. The main motivation behind this patch is that, currently the register buffer simply displays all the possible registers (153 on my machine), and tracking on some of them is very hard (scrolling back and forth, very annoying).

So this feather is a session-based quick filtering for interesting registers, I don’t think defcustom makes it better.

As for the buttons, I mimicked the buttons on memory buffer. And you don’r really need to use these buttons, instead of clicking this buttons, I just hit -/+/f key (since register buffer is a special buffer) and it’s convenient:

>> You can also use key “f” for toggle, “+” to add pattern,
>> “-” to remove pattern.

---------------------------------

> And please don't use non-ASCII characters in log messages, as these
> could cause trouble reading the Git log on less capable terminals.
> 
>> * lisp/progmodes/gdb-mi.el (gdb-registers-enable-filter,
>> gdb-registers-filter-pattern-list, gdb-header-click-event-handler,
>> gdb-registers-add-to-display, gdb-registers-remove-from-display,
>> gdb-registers-toggle-filter): new
>                                ^^^
> "New functions."
> 
>> (gdb-registers-handler-custom): condition check before adding each
>> register
>> (gdb-registers-mode-map): add new keys
>> (gdb-registers-header): add new buttons
> 
> Please start description of changes with a capitalized word, and end
> with a period -- these should be complete English sentences.
> 
>> +;; automatically local because we don't want filters persist across gdb sessions
> 
> Likewise in comments: complete sentences (here and elsewhere in the
> patch).
> 
> Thanks.

I’ve fixed these bits, here is the revised patch.

Yuan