diff options
author | 2008-02-10 21:31:53 -0500 | |
---|---|---|
committer | 2008-02-10 21:31:53 -0500 | |
commit | 2a8b91209627608fe61c21ec96de31b7fffcea94 (patch) | |
tree | 039767373d0a3f688c86cc8c1692fc422b80696d /modules/textadept/editing.lua | |
parent | 655d3222b8e242bcdb96e9458dc311aee1a658e5 (diff) | |
download | textadept-2a8b91209627608fe61c21ec96de31b7fffcea94.tar.gz textadept-2a8b91209627608fe61c21ec96de31b7fffcea94.zip |
Instead of io.popen():read(), a file descriptor is kept and close()'d afterward.
Diffstat (limited to 'modules/textadept/editing.lua')
-rw-r--r-- | modules/textadept/editing.lua | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/modules/textadept/editing.lua b/modules/textadept/editing.lua index 4c5b1044..76a98f3b 100644 --- a/modules/textadept/editing.lua +++ b/modules/textadept/editing.lua @@ -219,8 +219,10 @@ end function goto_line(line) local buffer = buffer if not line then - line = io.popen('zenity --entry --title "Go To" '.. - '--text "Line Number:"'):read('*all') + local p = io.popen('zenity --entry --title "Go To" '.. + '--text "Line Number:"') + line = p:read('*all') + p:close() if line == '' then return end line = tonumber(line) end @@ -542,7 +544,9 @@ end function ruby_exec() local buffer = buffer local txt = get_sel_or_line() - local out = io.popen("ruby 2>&1 <<'_EOF'\n"..txt..'\n_EOF'):read('*all') + local p = io.popen("ruby 2>&1 <<'_EOF'\n"..txt..'\n_EOF') + local out = p:read('*all') + p:close() if out:sub(-1) == '\n' then out = out:sub(1, -2) end -- chomp buffer:replace_sel(out) end @@ -587,7 +591,9 @@ function reformat_paragraph() local buffer = buffer if buffer:get_sel_text() == '' then select_paragraph() end local txt = buffer:get_sel_text() - local out = io.popen("fmt -c -w 80 <<'_EOF'\n"..txt..'\n_EOF'):read('*all') + local p = io.popen("fmt -c -w 80 <<'_EOF'\n"..txt..'\n_EOF') + local out = p:read('*all') + p:close() if txt:sub(-1) ~= '\n' and out:sub(-1) == '\n' then out = out:sub(1, -2) end buffer:replace_sel(out) end |