mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 18:47:58 +01:00
Profide default leaf names in :write for people who can't be bothered to think up their own.
--HG-- extra : rebase_source : 6bfef2eff2a7319af53fa9610fd8f16d5513e221
This commit is contained in:
@@ -147,6 +147,14 @@ const Buffer = Module("buffer", {
|
|||||||
destroy: function () {
|
destroy: function () {
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getDefaultNames: function getDefaultNames(doc) {
|
||||||
|
let ext = services.mime.getPrimaryExtension(doc.contentType, doc.location.href.replace(/.*\./, ""));
|
||||||
|
return [[doc.title, "Page Name"], [doc.location.pathname.replace(/.*\//, ""), "File Name"]]
|
||||||
|
.filter(function ([leaf, title]) leaf)
|
||||||
|
.map(function ([leaf, title]) [leaf.replace(util.OS.illegalCharacters, encodeURIComponent)
|
||||||
|
.replace(RegExp("(\\." + ext + ")?$"), "." + ext), title]);
|
||||||
|
},
|
||||||
|
|
||||||
_triggerLoadAutocmd: function _triggerLoadAutocmd(name, doc) {
|
_triggerLoadAutocmd: function _triggerLoadAutocmd(name, doc) {
|
||||||
let args = {
|
let args = {
|
||||||
url: doc.location.href,
|
url: doc.location.href,
|
||||||
@@ -1307,10 +1315,12 @@ const Buffer = Module("buffer", {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let file = io.File(filename);
|
let file = io.File(filename.replace(RegExp(File.PATH_SEP + "*$"), ""));
|
||||||
|
|
||||||
dactyl.assert(!file.exists() || args.bang,
|
if (filename.substr(-1) === File.PATH_SEP || file.exists() && file.isDirectory())
|
||||||
"E13: File exists (add ! to override)");
|
file.append(buffer.getDefaultNames(doc)[0][0]);
|
||||||
|
|
||||||
|
dactyl.assert(args.bang || !file.exists(), "E13: File exists (add ! to override)");
|
||||||
|
|
||||||
chosenData = { file: file, uri: window.makeURI(doc.location.href, doc.characterSet) };
|
chosenData = { file: file, uri: window.makeURI(doc.location.href, doc.characterSet) };
|
||||||
}
|
}
|
||||||
@@ -1340,7 +1350,12 @@ const Buffer = Module("buffer", {
|
|||||||
return;
|
return;
|
||||||
if (/^>>/.test(context.filter))
|
if (/^>>/.test(context.filter))
|
||||||
context.advance(/^>>\s*/.exec(context.filter)[0].length);
|
context.advance(/^>>\s*/.exec(context.filter)[0].length);
|
||||||
return completion.file(context);
|
|
||||||
|
context.fork("generated", context.filter.replace(/[^/]*$/, "").length,
|
||||||
|
this, function (context) {
|
||||||
|
context.completions = buffer.getDefaultNames(content.document);
|
||||||
|
});
|
||||||
|
return context.fork("files", 0, completion, "file");
|
||||||
},
|
},
|
||||||
literal: 0
|
literal: 0
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -407,10 +407,11 @@ want to bypass &dactyl.appName;'s key handling and pass keys directly to
|
|||||||
<spec>:sav<oa>eas</oa><oa>!</oa> <oa>file</oa></spec>
|
<spec>:sav<oa>eas</oa><oa>!</oa> <oa>file</oa></spec>
|
||||||
<description>
|
<description>
|
||||||
<p>
|
<p>
|
||||||
Save current web page to disk. If <oa>file</oa> is
|
Save current web page to disk. If <oa>file</oa> is omitted, save to
|
||||||
omitted, save to the page's default filename. Existing
|
the page's default filename. If <oa>file</oa> is a directory or ends
|
||||||
documents will only be overwritten if <oa>!</oa> is
|
with your platform's path separator, save to the page's default
|
||||||
given.
|
filename in that directory. Existing documents will only be
|
||||||
|
overwritten if <oa>!</oa> is given.
|
||||||
</p>
|
</p>
|
||||||
</description>
|
</description>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ XML.prettyPrinting = <hl key="Boolean">false</hl>;
|
|||||||
<hl key="HelpXMLAttribute">xmlns</hl>{NS}></hl></escape>
|
<hl key="HelpXMLAttribute">xmlns</hl>{NS}></hl></escape>
|
||||||
<author email="maglione.k@gmail.com">Kris Maglione</author>
|
<author email="maglione.k@gmail.com">Kris Maglione</author>
|
||||||
<license href="http://opensource.org/licenses/mit-license.php">MIT</license>
|
<license href="http://opensource.org/licenses/mit-license.php">MIT</license>
|
||||||
<project name="Pentadactyl" minVersion="1.0"/>
|
<project name="Pentadactyl" min-version="1.0"/>
|
||||||
<p>
|
<p>
|
||||||
This plugin provides the same features as the ever popular FlashBlock
|
This plugin provides the same features as the ever popular FlashBlock
|
||||||
Firefox addon. Flash animations are substituted with place holders which
|
Firefox addon. Flash animations are substituted with place holders which
|
||||||
@@ -204,7 +204,7 @@ XML.prettyPrinting = <hl key="Boolean">false</hl>;
|
|||||||
triggers to toggle the playing of animation on the current page.
|
triggers to toggle the playing of animation on the current page.
|
||||||
</p>
|
</p>
|
||||||
<item>
|
<item>
|
||||||
<tags>'flashblock' 'fb'</tags>
|
<tags>'fb' 'flashblock'</tags>
|
||||||
<spec>'flashblock' 'fb'</spec>
|
<spec>'flashblock' 'fb'</spec>
|
||||||
<type>boolean</type>
|
<type>boolean</type>
|
||||||
<default>true</default>
|
<default>true</default>
|
||||||
|
|||||||
@@ -546,7 +546,7 @@
|
|||||||
|
|
||||||
<warning>
|
<warning>
|
||||||
&dactyl.appName; will not behave correctly if the editor forks its
|
&dactyl.appName; will not behave correctly if the editor forks its
|
||||||
own process, rather than blocking until editing is complete. Gvim
|
own process rather than blocking until editing is complete. Gvim
|
||||||
invoked without the <em>-f</em> option is one such example.
|
invoked without the <em>-f</em> option is one such example.
|
||||||
</warning>
|
</warning>
|
||||||
</description>
|
</description>
|
||||||
@@ -961,7 +961,7 @@
|
|||||||
<p>
|
<p>
|
||||||
Alternatively, you can specify which plugins to load and which to
|
Alternatively, you can specify which plugins to load and which to
|
||||||
omit in your <tt><t>&dactyl.name;rc</t></tt> using something like
|
omit in your <tt><t>&dactyl.name;rc</t></tt> using something like
|
||||||
the below:
|
the following:
|
||||||
</p>
|
</p>
|
||||||
<code><ex>:set loadplugins=</ex>!<str delim="'">foo|bar</str>,<str delim="'">\.(js|&dactyl.fileExt;)$</str></code>
|
<code><ex>:set loadplugins=</ex>!<str delim="'">foo|bar</str>,<str delim="'">\.(js|&dactyl.fileExt;)$</str></code>
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
@@ -391,9 +391,7 @@ function iter(obj) {
|
|||||||
if (obj.constructor instanceof ctypes.StructType)
|
if (obj.constructor instanceof ctypes.StructType)
|
||||||
return (function () {
|
return (function () {
|
||||||
for (let prop in values(obj.constructor.fields))
|
for (let prop in values(obj.constructor.fields))
|
||||||
let ([name, type] = Iterator(prop).next()) {
|
yield let ([name, type] = Iterator(prop).next()) [name, obj[name]];
|
||||||
yield [name, obj[name]];
|
|
||||||
}
|
|
||||||
})();
|
})();
|
||||||
obj = {};
|
obj = {};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ const Services = Module("Services", {
|
|||||||
this.add("io", "@mozilla.org/network/io-service;1", Ci.nsIIOService);
|
this.add("io", "@mozilla.org/network/io-service;1", Ci.nsIIOService);
|
||||||
this.add("json", "@mozilla.org/dom/json;1", Ci.nsIJSON, "createInstance");
|
this.add("json", "@mozilla.org/dom/json;1", Ci.nsIJSON, "createInstance");
|
||||||
this.add("livemark", "@mozilla.org/browser/livemark-service;2", Ci.nsILivemarkService);
|
this.add("livemark", "@mozilla.org/browser/livemark-service;2", Ci.nsILivemarkService);
|
||||||
|
this.add("mime", "@mozilla.org/mime;1", Ci.nsIMIMEService);
|
||||||
this.add("observer", "@mozilla.org/observer-service;1", Ci.nsIObserverService);
|
this.add("observer", "@mozilla.org/observer-service;1", Ci.nsIObserverService);
|
||||||
this.add("pref", "@mozilla.org/preferences-service;1", [Ci.nsIPrefBranch2, Ci.nsIPrefService]);
|
this.add("pref", "@mozilla.org/preferences-service;1", [Ci.nsIPrefBranch2, Ci.nsIPrefService]);
|
||||||
this.add("privateBrowsing", "@mozilla.org/privatebrowsing;1", Ci.nsIPrivateBrowsingService);
|
this.add("privateBrowsing", "@mozilla.org/privatebrowsing;1", Ci.nsIPrivateBrowsingService);
|
||||||
|
|||||||
@@ -18,10 +18,8 @@ const win32 = /^win(32|nt)$/i.test(services.runtime.OS);
|
|||||||
|
|
||||||
function loadData(name, store, type) {
|
function loadData(name, store, type) {
|
||||||
try {
|
try {
|
||||||
if (storage.infoPath)
|
let data = storage.infoPath.child(name).read();
|
||||||
var file = storage.infoPath.child(name).read();
|
let result = JSON.parse(data);
|
||||||
if (file)
|
|
||||||
var result = services.json.decode(file);
|
|
||||||
if (result instanceof type)
|
if (result instanceof type)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -37,8 +35,11 @@ function saveData(obj) {
|
|||||||
|
|
||||||
const StoreBase = Class("StoreBase", {
|
const StoreBase = Class("StoreBase", {
|
||||||
OPTIONS: ["privateData", "replacer"],
|
OPTIONS: ["privateData", "replacer"],
|
||||||
|
|
||||||
fireEvent: function (event, arg) { storage.fireEvent(this.name, event, arg); },
|
fireEvent: function (event, arg) { storage.fireEvent(this.name, event, arg); },
|
||||||
|
|
||||||
get serial() JSON.stringify(this._object, this.replacer),
|
get serial() JSON.stringify(this._object, this.replacer),
|
||||||
|
|
||||||
init: function (name, store, load, options) {
|
init: function (name, store, load, options) {
|
||||||
this._load = load;
|
this._load = load;
|
||||||
|
|
||||||
@@ -49,11 +50,14 @@ const StoreBase = Class("StoreBase", {
|
|||||||
this[k] = v;
|
this[k] = v;
|
||||||
this.reload();
|
this.reload();
|
||||||
},
|
},
|
||||||
|
|
||||||
changed: function () { this.timer.tell() },
|
changed: function () { this.timer.tell() },
|
||||||
|
|
||||||
reload: function reload() {
|
reload: function reload() {
|
||||||
this._object = this._load() || this._constructor();
|
this._object = this._load() || this._constructor();
|
||||||
this.fireEvent("change", null);
|
this.fireEvent("change", null);
|
||||||
},
|
},
|
||||||
|
|
||||||
save: function () { saveData(this); },
|
save: function () { saveData(this); },
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -205,8 +209,8 @@ const Storage = Module("Storage", {
|
|||||||
|
|
||||||
fireEvent: function fireEvent(key, event, arg) {
|
fireEvent: function fireEvent(key, event, arg) {
|
||||||
this.removeDeadObservers();
|
this.removeDeadObservers();
|
||||||
// Safe, since we have our own Array object here.
|
|
||||||
if (key in observers)
|
if (key in observers)
|
||||||
|
// Safe, since we have our own Array object here.
|
||||||
for each (let observer in observers[key])
|
for each (let observer in observers[key])
|
||||||
observer.callback.get()(key, event, arg);
|
observer.callback.get()(key, event, arg);
|
||||||
if (key in keys)
|
if (key in keys)
|
||||||
@@ -481,12 +485,11 @@ const File = Class("File", {
|
|||||||
/**
|
/**
|
||||||
* @property {string} The current platform's path separator.
|
* @property {string} The current platform's path separator.
|
||||||
*/
|
*/
|
||||||
get PATH_SEP() {
|
PATH_SEP: Class.memoize(function () {
|
||||||
delete this.PATH_SEP;
|
|
||||||
let f = services.directory.get("CurProcD", Ci.nsIFile);
|
let f = services.directory.get("CurProcD", Ci.nsIFile);
|
||||||
f.append("foo");
|
f.append("foo");
|
||||||
return this.PATH_SEP = f.path.substr(f.parent.path.length, 1);
|
return f.path.substr(f.parent.path.length, 1);
|
||||||
},
|
}),
|
||||||
|
|
||||||
DoesNotExist: function (error) ({
|
DoesNotExist: function (error) ({
|
||||||
exists: function () false,
|
exists: function () false,
|
||||||
@@ -544,7 +547,7 @@ const File = Class("File", {
|
|||||||
joinPaths: function (head, tail, cwd) {
|
joinPaths: function (head, tail, cwd) {
|
||||||
let path = this(head, cwd);
|
let path = this(head, cwd);
|
||||||
try {
|
try {
|
||||||
// FIXME: should only expand env vars and normalise path separators
|
// FIXME: should only expand environment vars and normalize path separators
|
||||||
path.appendRelativePath(this.expandPath(tail, true));
|
path.appendRelativePath(this.expandPath(tail, true));
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
|
|||||||
@@ -501,7 +501,9 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
|||||||
/** @property {boolean} True if the OS is Mac OS X. */
|
/** @property {boolean} True if the OS is Mac OS X. */
|
||||||
get isMacOSX() this._arch == "Darwin",
|
get isMacOSX() this._arch == "Darwin",
|
||||||
/** @property {boolean} True if the OS is some other *nix variant. */
|
/** @property {boolean} True if the OS is some other *nix variant. */
|
||||||
get isUnix() !this.isWindows && !this.isMacOSX
|
get isUnix() !this.isWindows && !this.isMacOSX,
|
||||||
|
/** @property {RegExp} A RegExp which matches illegal characters in path components. */
|
||||||
|
get illegalCharacters() this.isWindows ? /[<>:"/\\|?*\x00-\x1f]/ : /\//
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user