~delthas/senpai-dev

senpai: special case /b as /buffer v1 REJECTED

Vlad-Stefan Harbuz: 1
 special case /b as /buffer

 1 files changed, 13 insertions(+), 8 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~delthas/senpai-dev/patches/45760/mbox | git am -3
Learn more about email & git

[PATCH senpai] special case /b as /buffer Export this patch

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
Hi,

Thanks for your patch!

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

See: 
https://git.sr.ht/~delthas/senpai/commit/1a988df7955d7648c47d28fed7735628d2a8ec26