You want to execute a specific command when a file is saved.

Asked 2 years ago, Updated 2 years ago, 103 views

You want to execute a specific command when you save a file.
(I would like to run hoge-command target-file).
(Assume that you have a command to reflect the file to the destination server)

How do I achieve this?

I thought flymake would make this happen, but I'm asking because I haven't found the document clearly describing the setting (only) to make this happen.

emacs

2022-09-30 21:22

1 Answers

As metropolis wrote,
I think it's better to use after-save-hook.

Simply registering a function in after-save-hook
No matter what buffer you save it in, it's called that function. When registering with add-hook, make it buffer local, or
I think it is necessary to make a decision within the registered function.

 (add-hook HOOK FUNCTION & optional APPEND LOCAL)

This seems to be the answer you want.
https://stackoverflow.com/questions/6138029/how-to-add-a-hook-to-only-run-in-a-particular-mode


2022-09-30 21:22

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.