P. S. A node of caution. If I were designing a hothouse for malware, I would choose something like the npm package warehouse. A search for "npm malware" yields this page. Presumably Joe Orr is aware of the risks.
The node.js people do not seem even remotely concerned enough. Hiding behind the halting problem is pathetic nonsense.
Probably want to support JSX as well :-)
places at-others directive before cursor. If cursor is indented then the directive is indented by the same amount. If body already contains this directive, command is noop
extract-to-new-node
expects cursor to be placed after at-others line. Extracts all lines from at-others to cursor in new node and starts editing headline. After editing headline, returns focus to parent body.
extract-to-previous-node
extracts all lines from at-others line to cursor and append them to the body of the last child node
split-body
splits body on the cursor position in two nodes. Current node keeps first part, and new node is inserted as the following sibling to the current node and body is set to second part
shift-lines-to-previous-sibling
extracts first lines from the current body up to the cursor and append them to the previous sibling node
shift-lines-to-next-siblings
extracts lines from cursor to the end of current body, and prepends them to the next sibling node
advance-js-block
moves cursor down to the end of next block. If line at cursor starts multiline expression, moves cursor at the end of that expression, else moves cursor to the next line that starts multiline expression. Executing this command several times moves cursor several blocks ahead.
extract-current-block-in-section
extracts all lines from the current cursor position to the end of current syntax block and put them in new section node. User is expected to type name of the section.
Regarding js importing, after some research about the topic, I concluded it is not possible/practical to make perfect js importer that can fully import javascript code on its own.
Doing it right would require building complete AI for this problem space and perhaps dealing with neural networks feeding them with big data collected from github and other source code repositories.
The other part of the puzzle is the JS_ScanState class. It keeps track of context and counts of parents and curly brackets.
On Wed, Jan 17, 2018 at 3:54 AM, vitalije <vita...@gmail.com> wrote:Regarding js importing, after some research about the topic, I concluded it is not possible/practical to make perfect js importer that can fully import javascript code on its own.
Doing it right would require building complete AI for this problem space and perhaps dealing with neural networks feeding them with big data collected from github and other source code repositories.
//headline:if (typeof define === 'function' && define.amd)
//and the content of body is
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery'], factory);
} else if (typeof module === 'object' && module.exports) {
// Node/CommonJS
@others
}
})(function($, undefined) {
'use strict';
// -----------------------------------------------------------------------
// :: Replacemenet for jQuery 2 deferred objects
// -----------------------------------------------------------------------
//or another one
//headline:everyTime: function(interval, label, fn, times, belay)
//and the body
everyTime: function(interval, label, fn, times, belay) {
@others
},
// and in at-others is following code
return this.each(function() {
jQuery.timer.add(this, interval, label, fn, times, belay);
});
// ----------------------------------------------------------------------- // :: jQuery Timers // ----------------------------------------------------------------------- var jQuery = $; jQuery.fn.extend({ everyTime: function(interval, label, fn, times, belay) { return this.each(function() { jQuery.timer.add(this, interval, label, fn, times, belay); }); }, oneTime: function(interval, label, fn) { return this.each(function() { jQuery.timer.add(this, interval, label, fn, 1); }); }, stopTime: function(label, fn) { return this.each(function() { jQuery.timer.remove(this, label, fn); }); } });
function dc(n) {
return wc(n, '', -1);
}
/**
* Public API
* $.Storage.set("name", "value")
* $.Storage.set({"name1":"value1", "name2":"value2", etc})
* $.Storage.get("name")
* $.Storage.remove("name")
*/
var localStorage;
if (!hasCookies() && !isLS) {
localStorage = {};
$.extend({
Storage: {
set: wls,
get: rls,
remove: dls
}
});
} else {
if (isLS) {
localStorage = window.localStorage;
}
$.extend({
Storage: {
set: isLS ? wls : wc,
get: isLS ? rls : rc,
remove: isLS ? dls : dc
}
});
}
// -----------------------------------------------------------------------
// :: jQuery Timers
// -----------------------------------------------------------------------
var jQuery = $;
jQuery.fn.extend({
Well, obviously we don't agree on what "reasonably" imported code look like. I have had encountered dozens of js files that *are* imported correctly in terms that they can be written again with the file content unchanged, but they all suffered from creating too many or too few nodes and I had to import them by hand.
Attached to this message are two files one Leo file trying to import the other js file. Put them in the same folder and try import. It fails,
it leaves a lot of created nodes with arguably ugly names. No developer would ever name those nodes like importer does,
nor he would structure the tree like that if he were creating that file using Leo from the beginning. For me, reasonably imported file must be something close to what a developer would have if he wrote the same source file directly in Leo.
So, I can partially agree that current implementation of js importer can import some of the source files, but I personally find those imports useless most of the time. I have to reshape the tree so much that it turned to be more efficient to import whole file in one node and then to extract pieces by hand.
In the file from the previous post, there few special regex patterns that make js importer fail.
If you delete those lines 2595-2613 from jquery.terminal.js, importer will successfully import the file. Looking in generated tree here are few example nodes:
On Wed, Jan 17, 2018 at 5:30 AM, vitalije <vita...@gmail.com> wrote:
Attached to this message are two files one Leo file trying to import the other js file. Put them in the same folder and try import. It fails,I'll open a new issue for this.
Well, obviously we don't agree on what "reasonably" imported code look like.
- I have just created #655: The js importer could remove @others when a node has only one child. This is a separate, relatively low priority item. It would improve only a few imported nodes in jqterm.js.