I attempted to add a new hook to the autocmd subsystem to allow me to bind
actions to the current working directory changing.

Attached is my attempt, I also tried patching ex_cd in desperation while it
wasn't working. I think my issue is in the way I'm invoking apply_autocmds, 
but
this seems to be the right approach. I would appreciate pointers in the 
right
direction.

Thanks.

Rich

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
diff -r cc606937e937 src/fileio.c
--- a/src/fileio.c	Thu Dec 08 18:44:51 2011 +0100
+++ b/src/fileio.c	Sun Dec 11 01:45:34 2011 +1100
@@ -7679,6 +7679,7 @@
     {"InsertCharPre",	EVENT_INSERTCHARPRE},
     {"MenuPopup",	EVENT_MENUPOPUP},
     {"QuickFixCmdPost",	EVENT_QUICKFIXCMDPOST},
+    {"PwdChanged",      EVENT_PWDCHANGED},
     {"QuickFixCmdPre",	EVENT_QUICKFIXCMDPRE},
     {"RemoteReply",	EVENT_REMOTEREPLY},
     {"SessionLoadPost",	EVENT_SESSIONLOADPOST},
diff -r cc606937e937 src/misc2.c
--- a/src/misc2.c	Thu Dec 08 18:44:51 2011 +0100
+++ b/src/misc2.c	Sun Dec 11 01:45:34 2011 +1100
@@ -5965,8 +5965,12 @@
 	return -1;
     r = mch_chdir((char *)dir_name);
     vim_free(dir_name);
+#ifdef FEAT_AUTOCMD
+    if (r)
+        apply_autocmds(EVENT_PWDCHANGED, NULL, NULL, FALSE, curbuf);
+#endif
     return r;
-#endif
+#endif /* FEAT_SEARCHPATH */
 }
 
 /*
diff -r cc606937e937 src/vim.h
--- a/src/vim.h	Thu Dec 08 18:44:51 2011 +0100
+++ b/src/vim.h	Sun Dec 11 01:45:34 2011 +1100
@@ -1293,6 +1293,7 @@
     EVENT_TABENTER,		/* after entering a tab page */
     EVENT_SHELLCMDPOST,		/* after ":!cmd" */
     EVENT_SHELLFILTERPOST,	/* after ":1,2!cmd", ":w !cmd", ":r !cmd". */
+    EVENT_PWDCHANGED,	        /* when the working directory has changed */
     NUM_EVENTS			/* MUST be the last one */
 };
 

Raspunde prin e-mail lui