Example #1
0
func complFormHeadInner(head string, ed *Editor) []*candidate {
	if eval.DontSearch(head) {
		return complArgInner(head, ed, true)
	}

	cands := []*candidate{}

	foundCommand := func(s string) {
		if strings.HasPrefix(s, head) {
			cands = append(cands, &candidate{
				source: styled{s[len(head):], styleForGoodCommand},
				menu:   styled{s, ""},
			})
		}
	}
	for special := range isBuiltinSpecial {
		foundCommand(special)
	}
	for variable := range ed.evaler.Global() {
		if strings.HasPrefix(variable, eval.FnPrefix) {
			foundCommand(variable[len(eval.FnPrefix):])
		}
	}
	for command := range ed.isExternal {
		foundCommand(command)
	}
	return cands
}
Example #2
0
func goodFormHead(head string, ed *Editor) bool {
	if isBuiltinSpecial[head] {
		return true
	} else if eval.DontSearch(head) {
		// XXX don't stat twice
		return eval.IsExecutable(head) || isDir(head)
	} else {
		return ed.evaler.Global()[eval.FnPrefix+head] != nil ||
			ed.isExternal[head]
	}
}