add autocmd! to remove specific autocmds

This commit is contained in:
Matt Friedman 2018-07-02 22:53:04 -07:00
parent b026462dd4
commit 06a8e1db53
2 changed files with 13 additions and 0 deletions

View file

@ -161,6 +161,8 @@ const DEFAULTS = o({
exaliases: o({
alias: "command",
au: "autocmd",
"au!": "rmautocmd",
"autocmd!": "rmautocmd",
b: "buffer",
o: "open",
w: "winopen",

View file

@ -2352,6 +2352,17 @@ export function autocmd(event: string, url: string, ...excmd: string[]) {
config.set("autocmds", event, url, excmd.join(" "))
}
/** Remove autocmds
@param event Curently, 'TriStart', 'DocStart', 'DocEnd', 'TabEnter' and 'TabLeft' are supported.
@param url For DocStart, DocEnd, TabEnter, and TabLeft: a fragment of the URL on which the events will trigger, or a JavaScript regex (e.g, `/www\.amazon\.co.*\/`)
*/
//#background
export function rmautocmd(event: string, url: string) {
if (!["DocStart", "DocEnd", "TriStart", "TabEnter", "TabLeft"].includes(event)) throw event + " is not a supported event."
config.unset("autocmds", event, url)
}
/**
* Helper function to put Tridactyl into ignore mode on the provided URL.
*