~delthas/senpai-dev

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH senpai] special case /b as /buffer

Details
Message ID
<20231016173413.66320-1-vlad@vladh.net>
DKIM signature
missing
Download raw message
Patch: +13 -8
Many people use “/b xxx” to switch between buffers. In senpai, you can't
currently do this, because “/b” is ambiguous between “/buffer” and
“/ban”, so you have to at least type “/bu”. I've added a special case
for “/b” which directly treats it as “/buffer”.

Signed-off-by: Vlad-Stefan Harbuz <vlad@vladh.net>
---
 commands.go | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/commands.go b/commands.go
index c146ac2..cf0e29d 100644
--- a/commands.go
+++ b/commands.go
@@ -803,15 +803,20 @@ func (app *App) handleInput(buffer, content string) error {

	var chosenCMDName string
	var found bool
	for key := range commands {
		if !strings.HasPrefix(key, cmdName) {
			continue
		}
		if found {
			return fmt.Errorf("ambiguous command %q (could mean %v or %v)", cmdName, chosenCMDName, key)
		}
		chosenCMDName = key
	if cmdName == "B" {
		chosenCMDName = "BUFFER"
		found = true
	} else {
		for key := range commands {
			if !strings.HasPrefix(key, cmdName) {
				continue
			}
			if found {
				return fmt.Errorf("ambiguous command %q (could mean %v or %v)", cmdName, chosenCMDName, key)
			}
			chosenCMDName = key
			found = true
		}
	}
	if !found {
		return fmt.Errorf("command %q doesn't exist", cmdName)
-- 
2.42.0
Details
Message ID
<399a3e9e-7f59-4f95-90fc-32f48a5822d1@dille.cc>
In-Reply-To
<20231016173413.66320-1-vlad@vladh.net> (view parent)
DKIM signature
pass
Download raw message
Hi,

Thanks for your patch!

I ended up implementing this for all prefixes of /buffer.

See: 
https://git.sr.ht/~delthas/senpai/commit/1a988df7955d7648c47d28fed7735628d2a8ec26
Reply to thread Export thread (mbox)