diff options
author | Soumith Chintala <soumith@gmail.com> | 2014-11-02 20:41:31 +0300 |
---|---|---|
committer | Soumith Chintala <soumith@gmail.com> | 2014-11-02 20:41:31 +0300 |
commit | eba1075db092b689e356067bb94e9e02e1e1453c (patch) | |
tree | db91f15c9cec6bbdafc6d0c677bf584d34524a3c | |
parent | 2f8224f3e8a6bb00a20365d653d6c70b77fcc2a6 (diff) |
adding tensor/storage completion using metatables
-rw-r--r-- | completer.lua | 13 |
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. |