Hi Lex,
On 2010-07-29 05:20, Lex Trotman wrote:
I better warn you that it might take a while, the developers are a bit
overloaded with real life at the moment.
No problem, but thanks for the warning anyway.
Well, here's just the next script: It solves the problem that geany -g
can only create tag files for one language at a time, but there may be
multiple source code languages present in a project.
This script runs geany -g with the correct parameters to generate tag
files for all supported languages for the source files encountered in
the current directory tree.
This script gets its information (which file extensions are supported
for which languages) from parsing the Geany configuration files as well
as reading the directory tree searching for matching source files. It
also sets up CFLAGS automatically to include all directories containing
#include files in sorted breadth-first order.
I have to add that I wrote this script by mistake - I did not know
what Geany's tag-files are actually used for.
What I expected them to be was something like ctags files; that is, they
would allow me to find a tag declaration everywhere in a project, and
not just in the currently opened files.
But it turned out that tag files are actually only used for keyboard
completion and ballon help. ;-)
Cheers,
Guenther
#! /usr/bin/env lua
-- Generate loadable tag files for Geany.
--
-- This script runs geany -g with the correct parameters to generate
-- tag files for all supported languages for the source files in the
-- current directory tree.
--
-- This script gets its information from parsing the Geany configuration
-- files as well as reading the directory tree searching for matching
-- source files. It also sets up CFLAGS automatically to include all
-- directories containing #include files in sorted breadth-first order.
--
-- (c) 2010 by Guenther Brunthaler.
--
-- This script is free software.
-- Distribution is permitted under the terms of the GPLv3.
local old_globals= {}; for k in pairs(_G) do old_globals[k]= true; end
local base= /usr/share/geany
local includes_xtns= h H hxx h++ hpp inl
-- langs[LANGSYM].name == LANGUAGE.
-- langs[LANGSYM].files[INDEX] == RELATIVE_FILENAME.
local langs= {}
local globs= {} -- globs[PATTERN][LANGSYM] == true.
local directs= {} -- directs[STRING][LANGSYM] == true.
local function add_config(filename)
local section, s, lang, pats, mode, sym, tbl
for line in io.lines(filename) do
line= string.match(line, ^%s*(.-)%s*$)
if line ~= and not string.match(line, ^#) then
s= string.match(line, ^%[([^%]]+)%]$)
if s then
section= s
elseif section == Extensions then
lang, pats= string.match(line, ^([^=]+)%s*=%s*(.-;)$)
if lang then
sym= string.lower(lang)
if not langs[sym] then langs[sym]= {files= {}, name= lang}; end
for xpat in string.gmatch(pats, %s*([^;]-)%s*;) do
s= string.match(xpat, ^%*([^*]*)$)
if s then
if s == then
mode= false
else
xpat= s
mode= suffix
end
else
s= string.match(xpat, ^([^*]+)%*$)
if s then
xpat= s
mode= prefix
else
mode=
string.match(xpat, %*) and complex or whole
end
end
if mode then
if mode == whole then
tbl= directs
else
tbl= globs
xpat= string.gsub(xpat, ([-[%]^(%).*+?$]), %%%1)
if mode == prefix then
xpat= ^ .. xpat
elseif mode == suffix then
xpat= xpat .. $
else
assert(mode == complex)
xpat= ^ .. string.gsub(xpat, %%%*, .*) .. $
end
end
if not tbl[xpat] then
tbl[xpat]= {}
end
tbl[xpat][sym]= true
end
end
else
io.stderr:write(
string.format('Could not parse line %s!\n', line)
)
end
end
end
end
end
add_config(base .. /filetype_extensions.conf)
--[[
do
local o
for _, t in
ipairs{{n= directs, t= directs}, {n= globs, t= globs}}
do
o= {}
for k in pairs(t.t) do
table.insert(o, k)
end
table.sort(o)
for _, k in ipairs(o) do
o= {}
for k in pairs(t.t[k]) do
table.insert(o,