I have just joined the Emacs church. I would like to know if the following can be done.
Say I have a project folder, I would like to run some custom commands that tie to some keyboard shorcuts for that folder only.
For example, say I am in /home/Documents/project
, I would open this directory in Emacs and I would press, say C-x-F5
for example, and Emacs would send some custom commands that I declare and run in the shell.
Is it possible to do this? The only thing I manage to mess around is the compile
command, M-x compile
. But how to tell Emacs to only execute that while in /home/Documents/project
?
Below is my attempt at modifying the compile command with adhook to compile C++ file.
(add-hook 'c++-mode-hook
(lambda ()
(set (make-local-variable 'compile-command)
(concat "g++ " buffer-file-name "&& ./a.out"))))
Please let me know.
M-x shell
,M-x eshell
,M-x term
. When you use the word "shell" in the context of your question, are you contemplating opening one of those interactive buffers? Or, do you just want to run the command as a background process and perhaps see the output -- without user interaction?