Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/trepl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSoumith Chintala <soumith@gmail.com>2014-11-02 20:41:31 +0300
committerSoumith Chintala <soumith@gmail.com>2014-11-02 20:41:31 +0300
commiteba1075db092b689e356067bb94e9e02e1e1453c (patch)
treedb91f15c9cec6bbdafc6d0c677bf584d34524a3c
parent2f8224f3e8a6bb00a20365d653d6c70b77fcc2a6 (diff)
adding tensor/storage completion using metatables
-rw-r--r--completer.lua13
1 files changed, 13 insertions, 0 deletions
diff --git a/completer.lua b/completer.lua
index 5fc278c..352d00e 100644
--- a/completer.lua
+++ b/completer.lua
@@ -80,6 +80,19 @@ table.insert(M.completers.value, function(t, sep)
end
end)
+-- tensor/storage completer
+table.insert(M.completers.value, function(t, sep)
+ if not (torch.isTensor(t) or torch.isStorage(t)) then return end
+ for k, v in pairs(t.__metatable) do
+ if type(k) == "number" and sep == "[" then
+ coyield(k.."]")
+ elseif type(k) == "string" and (sep ~= ":" or type(v) == "function") then
+ coyield(k)
+ end
+ end
+end)
+
+
-- This function does the same job as the default completion of readline,
-- completing paths and filenames. Rewritten because
-- rl_basic_word_break_characters is different.