mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-05 03:17:50 +08:00
eval: Add DeleteGlobal
Will be use by edit module soon.
This commit is contained in:
parent
b178367ca7
commit
9fae00d125
|
@ -174,6 +174,19 @@ func (ev *Evaler) ExtendGlobal(ns Nser) {
|
|||
ev.global = CombineNs(ev.global, ns.Ns())
|
||||
}
|
||||
|
||||
// DeleteGlobal deletes a binding from the global namespace.
|
||||
func (ev *Evaler) DeleteGlobal(name string) {
|
||||
ev.mu.Lock()
|
||||
defer ev.mu.Unlock()
|
||||
g := ev.global.clone()
|
||||
for i := range g.infos {
|
||||
if g.infos[i].name == name {
|
||||
g.infos[i].deleted = true
|
||||
}
|
||||
}
|
||||
ev.global = g
|
||||
}
|
||||
|
||||
// Builtin returns the builtin Ns.
|
||||
func (ev *Evaler) Builtin() *Ns {
|
||||
ev.mu.RLock()
|
||||
|
|
Loading…
Reference in New Issue
Block a user