-
Notifications
You must be signed in to change notification settings - Fork 166
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
add async export #56
add async export #56
Conversation
allow for possibility of process completing in between evaluating links in sync-do-async chain by creating markdown-async-result. use lexical-binding so that lambdas have access to lexically let-bound variables. lexical-binding is required globally; the alternative is to change every let(*) which encloses a markdown-do-sync-or-async call to lexical-let(*), which is difficult to keep track of and inconsistent.
Ok, how should this be dealt with then? @syohex the build fails on this. Should I suppress warnings, or (require 'cl) at runtime? I don't like that, but I'm not sure what else to do. |
You should remove |
Cool, we've just changed it all to use cl-lib. |
I just saw this markdown-preview-mode project and thought I'd pass it along in case anything could be useful. I only looked at it quickly, but it looks like the Markdown output is generated using an idle timer. |
I like that a lot, actually. Thanks for pointing it out. I thought I'd looked around for stuff like this before I wrote it, glad there's some existing code. |
Superseded by #69. |
This is more of a WIP than a completed feature; it needs a bit (a lot) more documentation/testing (any testing)/refactoring. Basically, it adds a defcustom
markdown-export-async
, which, if non-nil, performs the export operation in an asynchronous subprocess. This is nice because it pauses a lot less when the user saves while working, especially for larger files.This is done without duplicating all the export code for sync and async by replacing all calls to
markdown
(and all functions that call those functions which callmarkdown
, etc) with use of themarkdown-do-sync-or-async
macro, which performs the normal synchronous operation ifasyncp
is nil, but creates a lambda which attaches to the process sentinel otherwise (which is the reason for thelexical-binding: t;
, or sets its result tomarkdown-async-result
if the process finished.Once the
lexical-binding: t;
was added, I worked to fix some of the byte compiler errors. I would recommend taking a look at b5eb8cb closely; I did my best to fix what was obvious but I may have done something silly due to lack of familiarity with the code.The default callback for the async export (set in
markdown-make-process-sentinel
) is to message the user saying it completed; I'm considering making that a defcustom as well, or just a boolean for whether or not to message the user at all.I'll be working on this more, and I know I already have a pr up, so don't worry about getting to this super fast.