I want to run some function
f after adding a hook to a mode and after running
f remove the hook that I added, returning the result of
f if there is one.
Here is a non-working version that I hope makes the intent clear:
(defun run-function-with-hook (mode-hook hook-fn fn) (add-hook mode-hook hook-fn) (message (concat "mode hooks before running: " (prin1-to-string (symbol-value mode-to-slowdown)))) (funcall fn) (remove-hook mode-hook hook-fn)) (run-function-with-hook 'org-mode-hook (message "opening org file") (message "opened org file"))
Is this a better fit for a macro? If so, perhaps the right answer to this is an answer using a macro instead.