[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Imenu and structured documents

From: Daniele Nicolodi
Subject: Imenu and structured documents
Date: Sat, 28 Sep 2019 14:41:53 -0600
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Thunderbird/60.9.0


an user of a major-mode I co-maintain
asked for supporting imenu: the major mode allows to section the file
leveraging outline-minor-mode and the user would like to see the list of
sections in imenu.

I don't use imenu myself, but reading the documentation it seems that
the use case at hand is not very well supported. The problem is that the
sections in a beancount input file can contain beancount directives AND
subsections. A typical example:

;;; 2017

2016-12-31 balance Assets:Savings 1000000.00 USD
2017-01-01 open Assets:Checking

;;;; 2017 January

2019-01-01 * "Foo"
  Expenses:Foo   20.00 USD

;;;; 2017 February

2019-02-01 * "Foo"
  Expenses:Foo   30.00 USD

where section headings have prefix ";;;+\s+".

The problem is that while imenu allows for defining entries and
submenus, submenus cannot be entries themselves. Thus, using submenus
for headings deep in the hierarchy, in the example above, there is no
way to have a menu entry jumping to "2017" because the menu structure
would be:

2017 -- 2017 January
        2017 February

I had a look at what other modes do I there isn't an unique way to
handle this. org-mode uses submenus, while latex-mode uses a flat menu
structure with prefixes, that in the example above would result in menu
entries like:

. 2017
. . 2017 January
. . 2017 February

I haven't looked at other modes (and at the top of my head I cannot
think about other modes that support buffers with similar structure).

What is the best way to handle this?

I am tempted to go the latex-mode way because it feels more complete,
but it is also a bit ugly.

Thank you!


reply via email to

[Prev in Thread] Current Thread [Next in Thread]