Page 1 of 1
feature Request: user tags window/list
Posted: Wed Aug 10, 2005 2:12 pm
by raz
One feature that I liked in jEdit was the plugin for the TODO / FIXME tag window. That is, it would parse the current buffer, and display all the user defined tags, with a brief or full synopsis of the tag.
For example, if I put this in my source code:
// TODO: add better error checking here
// FIXME: use return value!
// WARN: this is a hack
or whatever my set of tags are. They would show up in a window, sorted however I wanted (by group, by position in the file, etc), and clicking on them would move the cursor to the line in question.
Is this feature a possibility, or should I get off my lazy <expletive> and write a script to do this (is it possible?).
Thanks!
raz.
Posted: Thu Aug 11, 2005 2:38 am
by jussij
Hi Raz,
That is, it would parse the current buffer, and display all the user defined tags, with a brief or full synopsis of the tag.
Inknow the feature you are referring to. I will add it to the Zeus todo list, but at this stage I would say it might be quite some time off
This type of feature really needs a seperate tool window panel (ie docked at the bottom edge) to hold this and any other tool windows in some sort of tabbed panel.
But adding such a tabbed tool panel will require a lot of code rework and is definitely no simple task
Is this feature a possibility or should I get off my lazy <expletive> and write a script to do this (is it possible?).
In the mean time I have come up with a
first draft macro script that does something similar.
My quick and dirty macro searches the current file for a set of patterns and displays the results in a tool window. Clicking on the items then takes you back to the original file at the correct line number:
Code: Select all
--
-- Name: Pattern Searching
--
-- Language: Lua Macro
--
-- Description: This macro searches the current file for a list of patterns
-- and displays the results in a tool window:
--
function create_results_file(filename, results, count)
local result = 0
-- try to create the file
file_results = io.open(filename, "w+")
if file_results ~= nil then
local index = 0
while index < count do
local line = index + 1
-- write out the text found
file_results:write(results[index + 1])
-- write out the CRLF
file_results:write("\n")
-- next line
index = index + 1
end
file_results:close()
result = 1;
else
-- failed to create file
message_box(1, "Error creating file!")
end
return result
end
function find_pattern(pattern, results, count)
local line_current = 0
local line_total = get_line_count()
-- the name of the current document
local file_name = macro_tag("$fn")
-- search the current file for the 'pattern'
while line_current < line_total do
-- get the text
local line_text = get_line_text(line_current)
local len = string.len(line_text)
if len > 0 then
-- look for all todo lines
if string.find(line_text, pattern)~= nil then
-- build up a full result text
local result_text = "\"" .. file_name .. "\"" .. " [" .. line_current .. "]" .. line_text
-- save the result into the table
results[count + 1] = result_text;
-- one more item found
count = count + 1
end
end
-- next line
line_current = line_current + 1
end
return count
end
function key_macro()
local count = 0
local results = {}
local pattern = "todo:"
-- search the current file for these patterns
count = find_pattern("todo:" , results, count)
count = find_pattern("hack:" , results, count)
count = find_pattern("fixme:", results, count)
if count == 0 then
-- nothing found
message("No pattern items found in current file!");
beep()
else
local filename = "d:\\temp\\test.txt"
-- create a temp results file
if create_results_file(filename, results, count) == 1 then
-- display the results in a tool window
file_open_tool(filename, "My Todo List")
end
end
end
key_macro() -- run the macro
Cheers Jussi
Posted: Thu Aug 11, 2005 8:47 pm
by raz
Thanks for the script!
I'll try it out in the next few days and let you know.
Thanks!
-raz