On 14.06.05, [EMAIL PROTECTED] wrote:
> On Tue, 14 Jun 2005, Jean-Marc Lasgouttes wrote:
> > I think that if you manage to provide a reasonably up-to-date doc for
> > 1.3.x (or better 1.4.x), we will be able to enforce updating of the
> > lfuns.
>
> Ok, I guess extracting everything from LyXAction again might be in order
> then, i.e. writing a small awk or sed script.
Here comes a small python script that does the work. (Currently, it prints
just the "M-x names" but parses all of the Array content on the way, so
extending is easy.)
Call extract-lfuns.py with the path to LyXAction.C as argument.
G�nter
--
G.Milde web.de
#!/usr/bin/env python
# extract-lfuns.py -*- coding: iso-8859-1 -*-
# Copyright (c) 2005 G�nter Milde
# Released under the terms of the GNU General Public License (ver. 2 or later)
# extract the name and flags of lyx functions from the file LyXAction.C
# This version works for the new format in LyX 1.4.x (without docstring)
import sys, string
def extract_lfuns(source):
"""extract name and flags of lfuns from C source, return as list"""
lfuns = {}
for line in source:
if line.find("{ LFUN_") >= 0:
line = line.strip(" \t\n{},")
lfun, line = line.split(",", 1)
fields = [field.strip(' "') for field in line.split(",")]
lfuns[lfun] = fields
return lfuns
if __name__ == '__main__':
try:
extract_lfuns(file(sys.argv[1]))
except IndexError:
print "Usage: lyx-bindings <source-filename>"
lfuns = extract_lfuns(file("/usr/src/lyx-cvs/devel/src/LyXAction.C"))
for fields in lfuns.values():
if fields[0]:
print "\t".join(fields)