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

add async export #56

Closed
wants to merge 12 commits into from

Conversation

cosmicexplorer
Copy link
Contributor

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 call markdown, etc) with use of the markdown-do-sync-or-async macro, which performs the normal synchronous operation if asyncp is nil, but creates a lambda which attaches to the process sentinel otherwise (which is the reason for the lexical-binding: t;, or sets its result to markdown-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.

Danny McClanahan added 4 commits January 3, 2016 05:12
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.
@cosmicexplorer
Copy link
Contributor Author

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.

@syohex
Copy link
Collaborator

syohex commented Jan 4, 2016

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 eval-when-compile around (require 'cl). Because changes of this PR contains gensym which is cl function. Or use cl-lib functions and macros instead of cl.el(This PR enables lexical-binding and lexical-binding was introduced at Emacs 24. package.el was also bundled since Emacs 24. So it is no problem to use cl-lib.el. Emacs 24.1 and 24.2 users can download cl-lib by package.el)

@cosmicexplorer
Copy link
Contributor Author

Cool, we've just changed it all to use cl-lib.

@jrblevin
Copy link
Owner

jrblevin commented Jan 6, 2016

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.

@cosmicexplorer
Copy link
Contributor Author

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.

@cosmicexplorer
Copy link
Contributor Author

Superseded by #69.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants