diff options
author | Alexey Yerin <yyp@disroot.org> | 2021-04-27 15:58:36 +0300 |
---|---|---|
committer | Hubert Hirtz <hubert@hirtz.pm> | 2021-04-27 16:39:06 +0200 |
commit | c7eceaa8da3cfcc008d8b89849bc44145d054f68 (patch) | |
tree | 839102108833003ee13aa57458b0a5979db03662 /commands.go | |
parent | senpai.5: fix typo (diff) |
Add BUFFER command to jump to the matching buffer
Is is very useful when you have joined a bunch of channels and scrolling
with Ctrl+n/Ctrl+p is quite inefficient.
Diffstat (limited to 'commands.go')
-rw-r--r-- | commands.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/commands.go b/commands.go index b3c2d14..6be50ed 100644 --- a/commands.go +++ b/commands.go @@ -100,6 +100,14 @@ func init() { Desc: "show or set the topic of the current channel", Handle: commandDoTopic, }, + "BUFFER": { + AllowHome: true, + MinArgs: 1, + MaxArgs: 1, + Usage: "<name>", + Desc: "switch to the buffer containing a substring", + Handle: commandDoBuffer, + }, } } @@ -375,3 +383,12 @@ func (app *App) handleInput(buffer, content string) error { return cmd.Handle(app, buffer, args) } + +func commandDoBuffer(app *App, buffer string, args []string) error { + name := args[0] + if !app.win.JumpBuffer(args[0]) { + return fmt.Errorf("none of the buffers match %q", name) + } + + return nil +} |