I need to test if the buffer has been modified even if
(save-buffer) has been called after the changes.
I thought to use
add-variable-watcher but I found that
buffer-modified-p is a function, not a variable.
I thought something like
(add-hook 'before-save-hook 'myfunction) where
myfunction should set a
t and remove the hook at the same time. In this case I could test
(or (buffer-modified-p) custom-variable)
I mean something like
(defun myfunction (VAR) (setq VAR t) (remove-hook 'before-save-hook 'myfunction) (defmacro mymacro `(let ((VAR nil)) (add-hook 'before-save-hook 'myfunction) ,@body (if (or (buffer-modified-p) VAR) ...)))
(This is not a MWE but only an idea of code...)
How can I add a function with one argument (
custom-variable) to 'before-save-hook? Is it a bad idea? I need to avoid
lambda function because of the need to remove it from the hook.
I'm open to other ideas.