[Conkeror] [PATCH] A first pass at completion for minibuffer.read_file
Nelson Elhage
nelhage at MIT.EDU
Fri Mar 21 20:46:45 PDT 2008
>From 55ec1fa06b66100ce8618e1c7427fa62ff559d44 Mon Sep 17 00:00:00 2001
From: Nelson Elhage <nelhage at mit.edu>
Date: Tue, 18 Mar 2008 13:54:19 -0400
Subject: [PATCH] A first pass at completion for minibuffer.read_file
---
modules/localfile.js | 32 +++++++++++++++++++++++++++++++-
1 files changed, 31 insertions(+), 1 deletions(-)
diff --git a/modules/localfile.js b/modules/localfile.js
index 5f2d399..3b24521 100644
--- a/modules/localfile.js
+++ b/modules/localfile.js
@@ -207,7 +207,9 @@ minibuffer.prototype.read_file_path = function () {
var result = yield this.read(
$prompt = arguments.$prompt,
$initial_value = arguments.$initial_value,
- $history = arguments.$history);
+ $history = arguments.$history,
+ $completer = file_path_completer(),
+ $auto_complete = true);
yield co_return(result);
}
@@ -238,3 +240,31 @@ minibuffer.prototype.read_file_check_overwrite = function () {
yield co_return(file);
} while (true);
};
+
+function file_path_completer() {
+ return function(input, pos, conservative) {
+ var f = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
+ var ents = [];
+ var dir;
+ try {
+ f.initWithPath(input);
+ if(f.exists() && f.isDirectory())
+ dir = f;
+ else
+ dir = f.parent;
+ if(!dir.exists()) return null;
+ var iter = dir.directoryEntries;
+ while(iter.hasMoreElements()) {
+ var e = iter.getNext();
+ ents.push(e.path);
+ }
+ } catch(e) {
+ return null;
+ }
+ function id(x) { return x};
+ return prefix_completer($completions = ents,
+ $get_string = id,
+ $get_description = id,
+ $get_value = id)(input, pos, conservative);
+ };
+}
--
1.5.2.5
More information about the Conkeror
mailing list