From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Daniele Nicolodi Newsgroups: gmane.emacs.devel Subject: Imenu and structured documents Date: Sat, 28 Sep 2019 14:41:53 -0600 Message-ID: <4011ff51-bb95-9515-e331-094d01195f96@grinta.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="51107"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 To: Emacs developers Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Sep 28 22:42:30 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iEJXu-000D8t-Qr for ged-emacs-devel@m.gmane.org; Sat, 28 Sep 2019 22:42:27 +0200 Original-Received: from localhost ([::1]:34898 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iEJXt-0006qJ-NY for ged-emacs-devel@m.gmane.org; Sat, 28 Sep 2019 16:42:25 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54819) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iEJXX-0006q1-Ps for emacs-devel@gnu.org; Sat, 28 Sep 2019 16:42:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iEJXW-0002Rq-BW for emacs-devel@gnu.org; Sat, 28 Sep 2019 16:42:03 -0400 Original-Received: from zed.grinta.net ([109.74.203.128]:54280) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1iEJXV-0002Oy-Sw for emacs-devel@gnu.org; Sat, 28 Sep 2019 16:42:02 -0400 Original-Received: from black.local (c-73-229-170-236.hsd1.co.comcast.net [73.229.170.236]) (Authenticated sender: daniele) by zed.grinta.net (Postfix) with ESMTPSA id 34EC1E0B62 for ; Sat, 28 Sep 2019 20:41:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=grinta.net; s=mail; t=1569703317; bh=COfzPEzP1TIRulGT9bfF/PJZYW7qUPVTZeexDPwY1Z4=; h=To:From:Subject:Date:From; b=eMb2eoYV9MY3aEGFslszGRc3OlXWGsRrKxyyzd4NcfP6G5yC5JrTK46BYPRBNV5o5 LjNJwQOj5ha/uS+rIhQywuFGbLDIKqy33QQsLWdE9dSQX2jZZgNAELHWC32jonpsvc +Ex7G48HWSM8LqpVJxUFuxE7RNtl7VfJByTERGZA= Openpgp: preference=signencrypt Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 109.74.203.128 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:240375 Archived-At: 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