all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Imenu and structured documents
@ 2019-09-28 20:41 Daniele Nicolodi
  2019-09-28 22:16 ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Daniele Nicolodi @ 2019-09-28 20:41 UTC (permalink / raw)
  To: Emacs developers

Hello,

an user of a major-mode I co-maintain
https://bitbucket.org/blais/beancount/src/default/editors/emacs/beancount.el
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
  Assets:Checking

;;;; 2017 February

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

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!

Cheers,
Dan



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-09-29 18:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-28 20:41 Imenu and structured documents Daniele Nicolodi
2019-09-28 22:16 ` Stefan Monnier
2019-09-28 22:50   ` Daniele Nicolodi
2019-09-29 18:25     ` Stefan Monnier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.