Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Expanding global aliases on key press (II)
- X-seq: zsh-users 14023
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Expanding global aliases on key press (II)
- Date: Thu, 09 Apr 2009 18:39:19 -0700
- In-reply-to: <grlaip$ufh$3@xxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <grlaip$ufh$3@xxxxxxxxxxxxx>
On Apr 9, 7:16pm, Thorsten Kampe wrote:
}
} accept-line()
} { emulate -LR zsh
} match-words-by-style -w shell
} local ga=$matched_words[2]
} if [[ -n $ga ]]; then
} matched_words[2]="${${galiases[$ga]}:-$ga}"
} LBUFFER="${(j::)matched_words[1,3]}"; fi
} zle .accept-line;}
}
} zle -N accept-line
} ##
}
} jed Makefile (with the cursor still being after the "M")
} now when I press enter this expands to
} jed | mostakefile (which of course is nonsense)
Interesting, I would have expected match-words-by-style to be a bit
more clever about this case (e.g., I didn't expect "Makefile" to
be split into "M" and "akefile" in matched_words, although now that
I see it I'm not entirely sure what I would want instead, and it is
in fact possible to detect this situation from $matched_words).
} Is there a way to modify Bart's above function so that expansion of
} global aliases is only done when the cursor is at the end of the line
} (or not "in" a word)?
Yes, change [[ -n $ga ]] to
[[ -n $ga && ( -n $matched_words[4] || -z $matched_words[5] ) ]]
Messages sorted by:
Reverse Date,
Date,
Thread,
Author