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

Suggestion for <<done>> #16

Closed
tmedwards opened this issue Jul 20, 2018 · 2 comments
Closed

Suggestion for <<done>> #16

tmedwards opened this issue Jul 20, 2018 · 2 comments

Comments

@tmedwards
Copy link
Contributor

tmedwards commented Jul 20, 2018

To avoid the duplicate task ID issue, have you thought of doing something like the following?

(function () {

    var taskCount = 1;

    Macro.add('done', {
        skipArgs : true,
        tags : null,
        handler : function () {
            var wikiCode = this.payload[0].contents.trim();

            // bail out if no payload
            if (wikiCode === '') {
                return;
            }

            // register the task
            postdisplay[':chapel-done-macro-' + taskCount] = function (task) {
                delete postdisplay[task]; // single use
                $.wiki(wikiCode); // wikify the source code
            };

            // increment the task ID counter
            taskCount++;
        }
    });

})();

EDIT: Added the skipArgs property.

@ChapelR
Copy link
Owner

ChapelR commented Jul 20, 2018

That is a much better idea than caching it. Thank you.

@tmedwards
Copy link
Contributor Author

Also, just thought of this. Since you're not doing anything with the arguments, you may as well disable argument processing via skipArgs. For example:

    Macro.add('done', {
        skipArgs : true,
        tags : null,
        handler : function () {

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

No branches or pull requests

2 participants