From ea43382430f7c3f6c03fef48a0897c31e0868aec Mon Sep 17 00:00:00 2001 From: Qi Xiao Date: Sat, 13 Oct 2018 18:38:14 +0100 Subject: [PATCH] newedit/utils -> newedit/editutil. --- newedit/binding.go | 4 ++-- newedit/binding_test.go | 4 ++-- newedit/builtins.go | 6 +++--- newedit/core/utils.go | 4 ++-- newedit/{utils => editutil}/action_error.go | 2 +- newedit/{utils => editutil}/action_error_test.go | 2 +- newedit/{utils => editutil}/basic_mode.go | 2 +- newedit/{utils => editutil}/basic_mode_test.go | 2 +- newedit/editutil/doc.go | 2 ++ newedit/insert/insert.go | 4 ++-- newedit/insert_api.go | 6 +++--- newedit/utils/doc.go | 2 -- 12 files changed, 20 insertions(+), 20 deletions(-) rename newedit/{utils => editutil}/action_error.go (97%) rename newedit/{utils => editutil}/action_error_test.go (97%) rename newedit/{utils => editutil}/basic_mode.go (99%) rename newedit/{utils => editutil}/basic_mode_test.go (99%) create mode 100644 newedit/editutil/doc.go delete mode 100644 newedit/utils/doc.go diff --git a/newedit/binding.go b/newedit/binding.go index bbca51dc..bd03fd8a 100644 --- a/newedit/binding.go +++ b/newedit/binding.go @@ -10,8 +10,8 @@ import ( "github.com/elves/elvish/edit/ui" "github.com/elves/elvish/eval" "github.com/elves/elvish/eval/vals" + "github.com/elves/elvish/newedit/editutil" "github.com/elves/elvish/newedit/types" - "github.com/elves/elvish/newedit/utils" ) // TODO(xiaq): Move the implementation into this package. @@ -51,7 +51,7 @@ func callBinding(nt notifier, ev *eval.Evaler, f eval.Callable) types.HandlerAct err := frame.Call(f, nil, eval.NoOpts) if err != nil { - if action, ok := eval.Cause(err).(utils.ActionError); ok { + if action, ok := eval.Cause(err).(editutil.ActionError); ok { return types.HandlerAction(action) } // TODO(xiaq): Make the stack trace available. diff --git a/newedit/binding_test.go b/newedit/binding_test.go index e54dc353..546bc9aa 100644 --- a/newedit/binding_test.go +++ b/newedit/binding_test.go @@ -7,8 +7,8 @@ import ( "github.com/elves/elvish/edit/ui" "github.com/elves/elvish/eval" + "github.com/elves/elvish/newedit/editutil" "github.com/elves/elvish/newedit/types" - "github.com/elves/elvish/newedit/utils" ) func TestKeyHandlerFromBinding_CallsBinding(t *testing.T) { @@ -88,7 +88,7 @@ func TestCallBinding_CapturesAction(t *testing.T) { nt := &fakeNotifier{} action := callBinding(nt, ev, eval.NewBuiltinFn("test", func() error { - return utils.ActionError(types.CommitCode) + return editutil.ActionError(types.CommitCode) })) if action != types.CommitCode { t.Errorf("got ret = %v, want %v", action, types.CommitCode) diff --git a/newedit/builtins.go b/newedit/builtins.go index e2f78a48..3315dd77 100644 --- a/newedit/builtins.go +++ b/newedit/builtins.go @@ -2,8 +2,8 @@ package newedit import ( "github.com/elves/elvish/edit/eddefs" + "github.com/elves/elvish/newedit/editutil" "github.com/elves/elvish/newedit/types" - "github.com/elves/elvish/newedit/utils" ) //elvish:doc-fn binding-map @@ -18,7 +18,7 @@ var makeBindingMap = eddefs.MakeBindingMap // special exception. func exitBinding() error { - return utils.ActionError(types.NoAction) + return editutil.ActionError(types.NoAction) } //elvish:doc-fn commit-code @@ -27,5 +27,5 @@ func exitBinding() error { // being edited. Internally, this works by raising a special exception. func commitCode() error { - return utils.ActionError(types.CommitCode) + return editutil.ActionError(types.CommitCode) } diff --git a/newedit/core/utils.go b/newedit/core/utils.go index 58dc42cc..3f6f7d4c 100644 --- a/newedit/core/utils.go +++ b/newedit/core/utils.go @@ -1,8 +1,8 @@ package core import ( + "github.com/elves/elvish/newedit/editutil" "github.com/elves/elvish/newedit/types" - "github.com/elves/elvish/newedit/utils" ) // Returns the first non-nil value. If all are nil, return utils.BasicMode{} @@ -12,5 +12,5 @@ func getMode(modes ...types.Mode) types.Mode { return mode } } - return utils.BasicMode{} + return editutil.BasicMode{} } diff --git a/newedit/utils/action_error.go b/newedit/editutil/action_error.go similarity index 97% rename from newedit/utils/action_error.go rename to newedit/editutil/action_error.go index fe85acc5..e0100004 100644 --- a/newedit/utils/action_error.go +++ b/newedit/editutil/action_error.go @@ -1,4 +1,4 @@ -package utils +package editutil import ( "fmt" diff --git a/newedit/utils/action_error_test.go b/newedit/editutil/action_error_test.go similarity index 97% rename from newedit/utils/action_error_test.go rename to newedit/editutil/action_error_test.go index 1a2b5f2e..0ea067d9 100644 --- a/newedit/utils/action_error_test.go +++ b/newedit/editutil/action_error_test.go @@ -1,4 +1,4 @@ -package utils +package editutil import ( "testing" diff --git a/newedit/utils/basic_mode.go b/newedit/editutil/basic_mode.go similarity index 99% rename from newedit/utils/basic_mode.go rename to newedit/editutil/basic_mode.go index c9a7d36d..e0e925df 100644 --- a/newedit/utils/basic_mode.go +++ b/newedit/editutil/basic_mode.go @@ -1,4 +1,4 @@ -package utils +package editutil import ( "unicode/utf8" diff --git a/newedit/utils/basic_mode_test.go b/newedit/editutil/basic_mode_test.go similarity index 99% rename from newedit/utils/basic_mode_test.go rename to newedit/editutil/basic_mode_test.go index 69a17d12..5826d0f6 100644 --- a/newedit/utils/basic_mode_test.go +++ b/newedit/editutil/basic_mode_test.go @@ -1,4 +1,4 @@ -package utils +package editutil import ( "fmt" diff --git a/newedit/editutil/doc.go b/newedit/editutil/doc.go new file mode 100644 index 00000000..bbc182a6 --- /dev/null +++ b/newedit/editutil/doc.go @@ -0,0 +1,2 @@ +// Package editutil provides utilities for the editor. +package editutil diff --git a/newedit/insert/insert.go b/newedit/insert/insert.go index 50ad04e2..9ca7b26c 100644 --- a/newedit/insert/insert.go +++ b/newedit/insert/insert.go @@ -9,8 +9,8 @@ import ( "github.com/elves/elvish/edit/tty" "github.com/elves/elvish/edit/ui" + "github.com/elves/elvish/newedit/editutil" "github.com/elves/elvish/newedit/types" - "github.com/elves/elvish/newedit/utils" "github.com/elves/elvish/parse" ) @@ -132,7 +132,7 @@ func (m *Mode) handleKey(k ui.Key, st *types.State) types.HandlerAction { if m.KeyHandler != nil { action = m.KeyHandler(k) } else { - action = utils.BasicHandler(tty.KeyEvent(k), st) + action = editutil.BasicHandler(tty.KeyEvent(k), st) } if k.Mod != 0 || k.Rune < 0 { m.inserts = "" diff --git a/newedit/insert_api.go b/newedit/insert_api.go index 9327a9a4..282eee60 100644 --- a/newedit/insert_api.go +++ b/newedit/insert_api.go @@ -5,9 +5,9 @@ import ( "github.com/elves/elvish/eval" "github.com/elves/elvish/eval/vals" "github.com/elves/elvish/eval/vars" + "github.com/elves/elvish/newedit/editutil" "github.com/elves/elvish/newedit/insert" "github.com/elves/elvish/newedit/types" - "github.com/elves/elvish/newedit/utils" "github.com/xiaq/persistent/hashmap" ) @@ -32,9 +32,9 @@ func initInsert(ed editor, ev *eval.Evaler) (*insert.Mode, eval.Ns) { }.AddBuiltinFns(":", map[string]interface{}{ "start": func() { st.SetMode(m) }, "default-handler": func() error { - action := utils.BasicHandler(tty.KeyEvent(st.BindingKey()), st) + action := editutil.BasicHandler(tty.KeyEvent(st.BindingKey()), st) if action != types.NoAction { - return utils.ActionError(action) + return editutil.ActionError(action) } return nil }, diff --git a/newedit/utils/doc.go b/newedit/utils/doc.go deleted file mode 100644 index 5ef9b561..00000000 --- a/newedit/utils/doc.go +++ /dev/null @@ -1,2 +0,0 @@ -// Package utils provides utilities for the editor. -package utils