How to add a hook to only run in a particular mode?

If you take a look at the documentation for add-hook (or C-h f add-hook RET), you’ll see that one possible solution is to make the hook local to the major modes you want. This is slightly more involved than vderyagin’s answer, and looks like this: (add-hook ‘org-mode-hook (lambda () (add-hook ‘after-save-hook ‘a-test-save-hook nil ‘make-it-local))) The … Read more

How can I hook Windows functions in C/C++?

Take a look at Detours, it’s perfect for this sort of stuff. For system-wide hooking, read this article from MSDN. First, create a DLL which handles hooking the functions. This example below hooks the socket send and receive functions. #include <windows.h> #include <detours.h> #pragma comment( lib, “Ws2_32.lib” ) #pragma comment( lib, “detours.lib” ) #pragma comment( … Read more

git post-receive hook not running

In order for a Git hook to run, it needs to have permissions set to allow it to be executable. If a hook doesn’t seem to be running, check the permissions, and make sure it’s executable. If it isn’t you can make all hooks executable like this: chmod ug+x .git/hooks/* …or if you want to … Read more

Linux X11 – Global Keyboard Hook

Try compile easy code from this page: http://webhamster.ru/site/page/index/articles/comp/367 It’s sample of get global keyboard event. This small app working as xinput. Remark 1: Write device ID to mian.cpp (get ID by running xinput without parameters): sprintf(deviceId, “9”); Remark 2: Compile command: gcc ./main.cpp -lstdc++ -lX11 -lXext -lXi Remakr 3: Before compile, install libxi-dev package: apt-get … Read more

git-clone and post-checkout hook

I suppose you could make a custom installation – rename the hooks in …/share/git-core/templates/hooks to remove the .sample suffix. You could also make a template directory full of symlinks to a hooks directory inside the repository, (e.g. post-checkout -> ../../hooks/post-checkout). Then if the cloned repo contained that particular hook, it’d get executed. You’re right, though, … Read more

Git pre-commit hooks only for a specific subfolder?

If you use pre-commit, specify files to include (or exclude to exclude) specific directories, e.g. run hooks only in my_dir: files: ^my_dir/ repos: – repo: https://github.com/pre-commit/pre-commit-hooks hooks: … or run everywhere but inside my_dir: exclude: ^my_dir/ repos: – repo: https://github.com/pre-commit/pre-commit-hooks hooks: … If you have a long list of exclusions, use verbose regex: exclude: > … Read more

tech