mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-15 20:17:50 +08:00
32 lines
597 B
Go
32 lines
597 B
Go
package edit
|
|
|
|
import (
|
|
"github.com/elves/elvish/eval"
|
|
"github.com/elves/elvish/eval/types"
|
|
"github.com/xiaq/persistent/hashmap"
|
|
)
|
|
|
|
func init() {
|
|
atEditorInit(func(ed *Editor, ns eval.Ns) {
|
|
ed.abbr = types.EmptyMap
|
|
ns["abbr"] = eval.NewVariableFromPtr(&ed.abbr)
|
|
})
|
|
}
|
|
|
|
func abbrIterate(abbr hashmap.Map, cb func(abbr, full string) bool) {
|
|
for it := abbr.Iterator(); it.HasElem(); it.Next() {
|
|
abbrValue, fullValue := it.Elem()
|
|
abbr, ok := abbrValue.(string)
|
|
if !ok {
|
|
continue
|
|
}
|
|
full, ok := fullValue.(string)
|
|
if !ok {
|
|
continue
|
|
}
|
|
if !cb(abbr, full) {
|
|
break
|
|
}
|
|
}
|
|
}
|