0

This question How to run an `after-save-hook` only when the buffer has been saved manually provides a way to have after-save hook run after pressing Ctrl-x Ctrl-s, in the answer Here's an alternative solution.

However the hook cannot take a argument. I understand a -function is needed and add-function is to be used instead. The argument I wish to pass to the function is the file path of the buffer being saved as I wish to rsync it to a remote compile server.

phils
  • 48,657
  • 3
  • 76
  • 115
MMM
  • 113
  • 2

1 Answers1

1

You don’t need to pass any arguments to anything. The new hook that you have created, after-save-interactively-hook, is called just after saving the current buffer. Any hook functions you add to that list can simply call buffer-file-name to get the name of the file visited by the current buffer. For more information, use C-h f buffer-file-name to view the documentation of this function.

db48x
  • 15,741
  • 1
  • 19
  • 23