Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

why re-read from init-buf-string in markdown-export? #55

Closed
cosmicexplorer opened this issue Jan 4, 2016 · 2 comments
Closed

why re-read from init-buf-string in markdown-export? #55

cosmicexplorer opened this issue Jan 4, 2016 · 2 comments
Labels

Comments

@cosmicexplorer
Copy link
Contributor

I'm puzzling over some of the code in markdown-export. After running markdown-after-export-hook, if the buffer is modified by any of the hooks or markdown-standalone, it is re-read from that initial state init-buf-string. Why is that? snip here:

      (run-hooks 'markdown-before-export-hook)
      (markdown-standalone output-buffer-name)
      (with-current-buffer output-buffer
        (run-hooks 'markdown-after-export-hook)
        (save-buffer))
      ;; if modified, restore initial buffer
      (when (buffer-modified-p init-buf)
        (erase-buffer)
        (insert init-buf-string)
        (save-buffer)
        (goto-char init-point))

Is there any reason why this is happening? It doesn't seem to affect anything normally, but I'm working on an asynchronous-export feature for fun (#56) and this erases any input the user has entered from the time export begins to the time the process ends.

@jrblevin
Copy link
Owner

jrblevin commented Jan 4, 2016

This was mostly added in commit ae0aeb3. I had to look back at the description to refresh my memory (but the motivation wasn't really written down there). The idea is that functions that run with markdown-before-export-hook are preprocessors of a sort that need to modify the raw Markdown source before being sent to the Markdown processor. For example, one might run a script to carry out automatic equation numbering in a mathematical document. We wouldn't want to actually modify the Markdown document for this, rather, just make the changes temporarily before running Markdown.

@cosmicexplorer
Copy link
Contributor Author

That makes perfect sense. I'll find a way around it for the async thing.

@jrblevin jrblevin closed this as completed Jan 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants