diff --git a/common/content/editor.js b/common/content/editor.js index 25dff89b..01a25ebd 100644 --- a/common/content/editor.js +++ b/common/content/editor.js @@ -470,7 +470,7 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), { } try { - var tmpfile = io.createTempFile(); + var tmpfile = io.createTempFile("txt", "." + buffer.uri.host); if (!tmpfile) throw Error(_("io.cantCreateTempFile")); diff --git a/common/modules/config.jsm b/common/modules/config.jsm index 574f788f..9e5b7c0c 100644 --- a/common/modules/config.jsm +++ b/common/modules/config.jsm @@ -568,12 +568,6 @@ var ConfigBase = Class("ConfigBase", { sidebars: {}, - /** - * @property {string} The leaf name of any temp files created by - * {@link io.createTempFile}. - */ - get tempFile() this.name + ".txt", - /** * @constant * @property {string} The default highlighting rules. diff --git a/common/modules/io.jsm b/common/modules/io.jsm index f09a4d96..8a3a06b2 100644 --- a/common/modules/io.jsm +++ b/common/modules/io.jsm @@ -307,23 +307,20 @@ var IO = Module("io", { }, /** - * Creates a temporary file. + * Returns a temporary file. * + * @param {string} ext The filename extension. + * @default "txt" + * @param {string} label A metadata string appended to the filename. Useful + * for identifying the file, beyond its extension, to external + * applications. + * @default "" * @returns {File} */ - createTempFile: function createTempFile(name, type) { - if (name instanceof Ci.nsIFile) { - var file = name.clone(); - if (!type || type == "file") - file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, octal(666)); - else - file.createUnique(Ci.nsIFile.DIRECTORY_TYPE, octal(777)); - } - else { - file = services.directory.get("TmpD", Ci.nsIFile); - file.append(this.config.tempFile + (name ? "." + name : "")); - file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, octal(666)); - } + createTempFile: function createTempFile(ext = "txt", label = "") { + let file = services.directory.get("TmpD", Ci.nsIFile); + file.append(config.name + label + "." + ext); + file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, octal(666)); services.externalApp.deleteTemporaryFileOnExit(file); @@ -543,9 +540,9 @@ var IO = Module("io", { * @returns {boolean} false if temp files couldn't be created, * otherwise, the return value of *func*. */ - withTempFiles: function withTempFiles(func, self, checked, ext) { + withTempFiles: function withTempFiles(func, self, checked, ext, label) { let args = array(util.range(0, func.length)) - .map(bind("createTempFile", this, ext)).array; + .map(bind("createTempFile", this, ext, label)).array; try { if (!args.every(util.identity)) return false; diff --git a/pentadactyl/content/config.js b/pentadactyl/content/config.js index 2dde4bc1..183f6d10 100644 --- a/pentadactyl/content/config.js +++ b/pentadactyl/content/config.js @@ -79,16 +79,6 @@ var Config = Module("config", ConfigBase, { else dactyl.beep(); } - }, - - get tempFile() { - let prefix = this.name; - try { - prefix += "-" + window.content.document.location.hostname; - } - catch (e) {} - - return prefix + ".txt"; } }) diff --git a/teledactyl/content/config.js b/teledactyl/content/config.js index 6c85f30d..72215c86 100644 --- a/teledactyl/content/config.js +++ b/teledactyl/content/config.js @@ -116,10 +116,7 @@ var Config = Module("config", ConfigBase, { modes.main = modes.MESSAGE; } } - }, - - // to allow Vim to :set ft=mail automatically - tempFile: "teledactyl.eml" + } }, { }, { commands: function initCommands(dactyl, modules, window) {