diff --git a/common/content/buffer.js b/common/content/buffer.js index 0ffe198e..449eacb8 100644 --- a/common/content/buffer.js +++ b/common/content/buffer.js @@ -976,9 +976,11 @@ const Buffer = Module("buffer", { */ viewSourceExternally: Class("viewSourceExternally", XPCOM([Ci.nsIWebProgressListener, Ci.nsISupportsWeakReference]), { - init: function (doc) { + init: function (doc, callback) { let url = isString(doc) ? doc : doc.location.href; let charset = isString(doc) ? null : doc.characterSet; + this.callback = callback || + function (file) editor.editFileExternally(file.path); let webNav = window.getWebNavigation(); try { @@ -994,7 +996,7 @@ const Buffer = Module("buffer", { let uri = util.newURI(url, charset); if (uri.scheme == "file") - editor.editFileExternally(uri.QueryInterface(Ci.nsIFileURL).file.path); + this.callback(File(uri.QueryInterface(Ci.nsIFileURL).file)); else { if (descriptor) { // we'll use nsIWebPageDescriptor to get the source because it may @@ -1035,7 +1037,7 @@ const Buffer = Module("buffer", { this.file = io.createTempFile(); this.file.write(this.docShell.document.body.textContent); } - editor.editFileExternally(this.file.path); + this.callback(this.file); this.file.remove(false); } finally { @@ -1318,7 +1320,25 @@ const Buffer = Module("buffer", { let chosenData = null; let filename = args[0]; + let command = commandline.command; if (filename) { + if (filename[0] == "!") + return buffer.viewSourceExternally(buffer.focusedFrame.document, + function (file) { + let output = io.system(filename.substr(1), file); + commandline.command = command; + commandline.commandOutput({output}); + }); + + if (/^>>/.test(filename)) { + let file = io.File(filename.replace(/^>>\s*/, "")); + dactyl.assert(file.exists() && file.isWritable(), file.path.quote() + ": E212: Can't open file for writing"); + return buffer.viewSourceExternally(buffer.focusedFrame.document, + function (tmpFile) { + file.write(tmpFile.read(), ">>"); + }); + } + let file = io.File(filename); dactyl.assert(!file.exists() || args.bang, @@ -1347,7 +1367,14 @@ const Buffer = Module("buffer", { { argCount: "?", bang: true, - completer: function (context) completion.file(context) + completer: function (context) { + if (context.filter[0] == "!") + return; + if (/^>>/.test(context.filter)) + context.advance(/^>>\s*/.exec(context.filter)[0].length); + return completion.file(context) + }, + literal: 0 }); commands.add(["st[op]"], diff --git a/common/content/io.js b/common/content/io.js index 0402c395..35b8f763 100644 --- a/common/content/io.js +++ b/common/content/io.js @@ -433,7 +433,9 @@ lookup: function escape(str) '"' + str.replace(/[\\"$]/g, "\\$&") + '"'; return this.withTempFiles(function (stdin, stdout, cmd) { - if (input) + if (input instanceof File) + stdin = input; + else if (input) stdin.write(input); // TODO: implement 'shellredir' diff --git a/common/locale/en-US/browsing.xml b/common/locale/en-US/browsing.xml index db139c85..77c40487 100644 --- a/common/locale/en-US/browsing.xml +++ b/common/locale/en-US/browsing.xml @@ -415,6 +415,26 @@ want to bypass &dactyl.appName;'s key handling and pass keys directly to + + :write >> file + +

+ Appends the current web page to the file file. The given + file must already exist. +

+
+
+ + + :write !cmd + +

+ Writes the current web page to cmd and prints the command's + output. +

+
+
+

Quitting

diff --git a/pentadactyl/NEWS b/pentadactyl/NEWS index bb041635..70151b6a 100644 --- a/pentadactyl/NEWS +++ b/pentadactyl/NEWS @@ -57,14 +57,15 @@ * Added 'banghist' option. * Added BookmarkChange, BookmarkRemove autocommands. * Added -keyword, -tags, -title to :delbmarks. + * Added "passwords" and "venkman" dialogs to :dialog. * Added 'hintkeys' option. + * Added "transliterated" option to 'hintmatching'. * Replaced 'focuscontent' with 'strictfocus'. * Added 'wildanchor' option. - * Added "transliterated" option to 'hintmatching'. * Added -javascript option to :abbrev and :map. * Added several new options to :map. * Added -agent flag to :style. - * Added "passwords" and "venkman" dialogs to :dialog. + * Added :write !cmd and :write >>file * Removed the :source line at the end of files generated by :mkpentadactylrc. * gf now toggles between source and content view.