joostkremers / pandoc-mode

An Emacs minor mode for interacting with Pandoc.
https://joostkremers.github.io/pandoc-mode/
177 stars 14 forks source link

Function for adding to after-save-hook #70

Closed berquist closed 7 years ago

berquist commented 7 years ago

I have a function that exports from Markdown mode after every save:

(add-hook 'markdown-mode-hook
          (lambda ()
            (add-hook 'after-save-hook 'markdown-export t :local)))

However, when I replace 'markdown-export with 'pandoc-run-pandoc, run-hooks complains with this traceback:

Debugger entered--Lisp error: (wrong-number-of-arguments (1 . 1) 0)
  pandoc-run-pandoc()
  run-hooks(after-save-hook)
  basic-save-buffer(t)
  save-buffer(1)
  funcall-interactively(save-buffer 1)
  call-interactively(save-buffer nil nil)
  command-execute(save-buffer)

Is there another function I should be using?

joostkremers commented 7 years ago

pandoc-run-pandoc requires an argument, hook functions cannot take arguments. I guess the easiest way to deal with that is to make that argument optional. I just pushed a commit to Github that does just that. So it should work once you upgrade the pandoc-mode package.

berquist commented 7 years ago

Ok, I was confused because the docstring said "If called with a PREFIX argument", but I should have seen the lack of &OPTIONAL. Now it works as I expected.