From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id CLYRK6GuaWZSEQEAqHPOHw:P1 (envelope-from ) for ; Wed, 12 Jun 2024 14:20:17 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id CLYRK6GuaWZSEQEAqHPOHw (envelope-from ) for ; Wed, 12 Jun 2024 16:20:17 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=outlook.com header.s=selector1 header.b=ofQshezS; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=outlook.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1718202017; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=uSYfzFpoDP60rV4fWKUjEh0LOM1uBw5Ks6d4K5mmm9U=; b=P9+xLwKHzA3mhkRqF5oJsI0cJnOgs/0AJEZ1U2dZ8yjg/ucyLc6DlQ50d0/tYToUwWSXgn kkO0kB8s3QoNEzNy0IWUTFFkAQmi65u89vUsFBTuwnQCcv/i4EjpHONKhg3eWOBvgB7zZv rAu3A5jb2LjzFx//t2UwDm66HzsKbNPbxB9lYR8bZ8sOpa5igng1Diq6+tO+TRwAb+GkuO l4WsaTiq6cp1Mv4Q5dvZ7iiI6Vo2zhWmmFeuNNuerZQzyX8tecOIC5W+mCKq6hFr6UVucK DlRBGKC+gpLgWqC6F1oszS9BVN+chhQuxRh7D95xQj58p72E8nmu2da4JoHRbw== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=pass header.d=outlook.com header.s=selector1 header.b=ofQshezS; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=outlook.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Seal: i=2; s=key1; d=yhetil.org; t=1718202017; a=rsa-sha256; cv=pass; b=SwwtuW+5v6EgQ9g9DAlfaIV3UNobBF9IfBIBX1k/KKdNG6xhMY5nqPFzwRnsd70aehiVxq DAzV0Qawo/sq8gc/gwkSnHD+afJ5WP2wNN1ZYoWubdb3pO+Rnsc9GVrYN8gtJUt8cQjXbX Uc0Wn0rt3LOB9CD3CizcONYWh4JjPyeO7dNNJNlSf5Hogew/THYO/znPvKhg9yX+5AMb3Y MG0O9k4QodS/O150/XI2AbMRCswPsMQuZov0N+dVo/goEtrU+lv+Ey4o3+v0XtByXHRy3i yyuIz1tmx2qwOROeWOoXglWKm6V/gNFHWnfDm6fB6g7ArdjPsoBU0MLm0qpWiw== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 745646D269 for ; Wed, 12 Jun 2024 16:20:17 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sHOoy-0008W7-1e; Wed, 12 Jun 2024 10:19:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sHOos-0008Vd-De for emacs-orgmode@gnu.org; Wed, 12 Jun 2024 10:19:23 -0400 Received: from mail-bn8nam04olkn2031.outbound.protection.outlook.com ([40.92.47.31] helo=NAM04-BN8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sHOoo-0006yI-Ar for emacs-orgmode@gnu.org; Wed, 12 Jun 2024 10:19:22 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CIC00BsHQJkAlirb/hAy1CqW6WKIm7YR4shsr0xzygD41HDA3bnmp/ZY2/vZ6C+uDSwQ6tv/OXRjoZIC9YQ6/gluuwlmZgnkmhL/e8jzXPovFSuEaryDXUKuwhgoSxl1a6+ejDrvoox96lXlK9BbyZT4A1e74MR64T2utoaJcOF3sgsh3mEu4nQPopap3zb7GoGthWnqZRquMR6oveda37LNYnlEZPxXno6LQh9Isrlu1mRV+l1nDuz3Jbote6DlT1cMrbgayfe6gPG8qqusBkeE9hxyOJcaHhPUphRUL5mBvuJBO+3bIyKKapeQfDxkZp5U0ApRZRBfriBFRgVIqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uSYfzFpoDP60rV4fWKUjEh0LOM1uBw5Ks6d4K5mmm9U=; b=OEeYqt5jTeL8eAaB1MbYJVpbGY/8gkGIFthb9eSX15wg7ycbaZF8IDdyGMe6Jaj0d8uvq2ebwSSfE6AJ8lUQbATKWCoi1rkRMH7xGKyx6px74UMIzvnZqxsqEKkKsWhjVYNaggV9s3hPE8TdCpiLUEqsidcygFrdYtaSEwGKxBrLEHBPUniZjbD2XCbMcfDanV9H9ZqgEPOWYkwQtI+AU/5dailEJSMtJdusk0+YYJ/Dyf4ZE0ieKcxMKEyPLBX59Y2MjboQIsN7grLN0bh/c4iuBPOq3zBbM2RlaMAx4szxsSQIfU385kVRjJXTukFhizoDlKt2NSljQIRV1eRu6g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uSYfzFpoDP60rV4fWKUjEh0LOM1uBw5Ks6d4K5mmm9U=; b=ofQshezS1O2BSLKHslMcgXuUoN7twjJ/4FUzH7UXxHlEOfIF3tUmp4yFOmppLZ0OXpszO1y3K9hj2EE5ZbhXCsd4m7YUpbgWl5NvE6DwAxWgMQoTqCD0lz08ohtD6+TzgDNZe4lcyK7PjucSjTJbADvDOB1Cyw5wsisd3EerJUAfb/gy0QhKltCJo3a0bAofWZNTkfanlIk9MCWqY2Jen1MsCqTFKgujZRGil3isgOq8E/cwdC/wOLCe0GDVNeB29pE0eL3bzAAVS9nzsp7zWagYf4m26vevOOSQGBKdg5YlgFiAmVMVNUwRVQ/YQQa9fBad8tvPYEkNd4gf3nuC2w== Received: from CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM (2603:10b6:610:1c4::17) by SJ0PR84MB1989.NAMPRD84.PROD.OUTLOOK.COM (2603:10b6:a03:433::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.20; Wed, 12 Jun 2024 14:14:09 +0000 Received: from CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM ([fe80::5c77:7a58:48ed:9aef]) by CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM ([fe80::5c77:7a58:48ed:9aef%3]) with mapi id 15.20.7633.037; Wed, 12 Jun 2024 14:14:08 +0000 From: Morgan Smith To: emacs-orgmode@gnu.org Cc: Morgan Smith Subject: [PATCH] lisp/org-compat.el: Allow using imenu to visit non-leaf headlines Date: Wed, 12 Jun 2024 10:14:04 -0400 Message-ID: X-Mailer: git-send-email 2.45.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-TMN: [getJYfSbgvsEOoIUKBnY7yzooPjhnA/k] X-ClientProxiedBy: YT4PR01CA0418.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:10b::26) To CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM (2603:10b6:610:1c4::17) X-Microsoft-Original-Message-ID: <20240612141404.23373-1-Morgan.J.Smith@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR84MB3424:EE_|SJ0PR84MB1989:EE_ X-MS-Office365-Filtering-Correlation-Id: e9fb58e5-e09f-4cc0-2149-08dc8ae9eca4 X-Microsoft-Antispam: BCL:0; ARA:14566002|461199020|440099020|3412199017|1710799020; X-Microsoft-Antispam-Message-Info: ay7Glt2ZKUMgVAsR7d9Kf6AHPqetwEnbrTrT6I9yIkwawq7d1W0gcPOgCUd8v0qNYB7GofP0I864wWZ15QRu+ATQsXUBNZ/K+IGlD0Jx2WnISlnvdtXMXaR5cWBBQN+IEC6nxNfPcJhWQw/Ol/wHAex17Em/U1R5H4OM/7qSPEyO7txSC4yZvl1sBI90rX6oVdfzTCAynw5+oouXwUNyq4cZDxYI3DIGPTXXqjrDQuNROHhvExagJuMdYaolI8AHbfA/zxdrJ7ELejCXEeFeYdqEzxI/7tPAlJgB0Ns2ia2LK5AIVyq8ZH1k5CrD8at+cjUcE3bWPd031eNg2QejoRqIqLqMqLySDHQYiutrRpDlCVS3iJd+AXOZgavAz97NHhft8EeAhX1LLu7iL1ZRdXG3UAdFka3IRvridJFyG95yx8uXWssMyYxTp52ERnGVwDrySlwTF/mbitxV65wbsMw+/1cxYdTH2efKRdeMbJjTZdgxkeYJUZn8CwmaXpU+8qRW28e/ySw66iObNMwFradEfpQ2SYbw04rgITJA2VbaTKBuC/6OlsoeBQEd5yYp1nKsSKr/v9rc/gdrzwxZBeXYtAKU/EbAcaBam3quJnbljB1UR+qyTFhoFzBYxgyd X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?hb95MSzVBE5slQhE9aVl0jy3CUoCwS1Gf2RX5FsMFZ5HaVvjEWxgig5jNmHu?= =?us-ascii?Q?C6p+WUPRl2diRMPeoPGOxmfgl8IeV+6qN8WTml8Eq4FZPV+PzGCQ3UoCFmpI?= =?us-ascii?Q?H1KaUGXm/Z2DxJvf2OOhloRtYfGHPUP+0M7jaLNca+KPdCesUvmit/UB65b4?= =?us-ascii?Q?7xRAgEj5DzsewftvTqTQqGyGAgmtRhPhUILfofEn6v2r2cf2reEgHbyDp3AL?= =?us-ascii?Q?sPMB7cjGFJIBSusbLc0giehLovvCTE3JXJXZfJ9rurbj9id/H6y3WRDPjfC1?= =?us-ascii?Q?g++AQrZt4XsL8/Vx/fBgIddlhBzxBe5/ng6cP+CgI8i3WtpBlY60MUcRzEc9?= =?us-ascii?Q?ZUbNS/cdFTjgS8ew2dpd47woK2KnA3og4TGJ0btTCpVq83ZPUm8tSGNN1vVw?= =?us-ascii?Q?MrXwWJXsGd/u5dRDN19y5BtMwWNby/byFRT9KueRuh92h/O6/vwlDlQu3EI9?= =?us-ascii?Q?7AbAg2YtRQQk1Lyp2YlujUEcl+HgthRgIg7gWC/PHjXp7uHUdblgFKchVCaX?= =?us-ascii?Q?uWTvzpa4c+3qvQqgSvhH+4SfNXgINPEWe6ux78nRi3+4osmq+RLK6WnfzV4H?= =?us-ascii?Q?U00/3X8C6ebJbVxMwSkeObfe86FGmVhnBQuH6bhoFbiwU0a5YcGPgdfzUWCY?= =?us-ascii?Q?/36QJzI1BkomOpxM+ndfGvkS0J+V866V9LxS23IvQ/XgSmdchWha7Afk4+21?= =?us-ascii?Q?EZb2LMCgaMnBeyfRLCsjQ5UfzNnGlqZQqeBrvMkgDXSWDlkAAv36L1TIZ/Yw?= =?us-ascii?Q?H0CSnuZL6Fs1bUaBS2IWbUoAX7seBtgPURdY2VQNBFzlJtFLBAFmSe1fF7B1?= =?us-ascii?Q?58S9Q7BVbkH7e9dW3qCynTGBtsfWi8CkDeNKNf38fhj8PO3dp8XbL0TvHUad?= =?us-ascii?Q?3PvagRzr4H7jU8ZijA0e2hfGwX1grJPYOuHvp4SxlAz4BVAyzLBbR3d57sR7?= =?us-ascii?Q?MUifhhe5Hc0khTcedrOEwm2QvPRq5PO0D3tx0vxcj0zzBiDMy/0O/zxyo9s9?= =?us-ascii?Q?vJSFjc+9x4YmKrDPZHPRs09tglrNkWgCknr14z6p0s7/2KVd/qgZjEfZBboo?= =?us-ascii?Q?XzVjMJVvcbBHU8N3oaW3dYYh0Ji9nHathcuGkEY7y6SAdnaZLqht4cb+DWJ9?= =?us-ascii?Q?XUm/22Vgtga0tkcU2pTe2kB5xyXLybxPnki8LeT2GcjIlArzhiN1N0A8IGyi?= =?us-ascii?Q?wx4B62m2K0A5A6rA1OqEadk5emaLHRwLV4qy3AUScoLVUA1LmyaFUUtIDIaW?= =?us-ascii?Q?qkQaM8y5e3CAqr0Ej0y/?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e9fb58e5-e09f-4cc0-2149-08dc8ae9eca4 X-MS-Exchange-CrossTenant-AuthSource: CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2024 14:14:08.3639 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR84MB1989 Received-SPF: pass client-ip=40.92.47.31; envelope-from=Morgan.J.Smith@outlook.com; helo=NAM04-BN8-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Spam-Score: -9.47 X-Migadu-Queue-Id: 745646D269 X-Migadu-Scanner: mx10.migadu.com X-Migadu-Spam-Score: -9.47 X-TUID: sr8pJWpl/uN4 With a file like this: * headline 1 ** headline 2 We currently produce an imenu tree that looks like this: '(("headline 1" ("headline 2" . marker-2))) imenu has no clue where "headline 1" is located and thus the user can't navigate to it. With this patch installed imenu knows where non-leaf headlines are as the tree will now look like this: '(("headline 1" . marker-1) ("headline 1" ("headline 2" . marker-2))) Quirks: With the default `imenu-flatten' value of nil, it is still impossible to visit non-leaf headlines and no change is perceived. Setting `imenu-flatten' to 'group works as expected with the quirk that top level headlines don't end up in the group. Ex: * Headline 1 Group is "*" Setting the group to "Headline 1" somehow might be nice but would require upstream changes in imenu. ** Headline 2 Group is "Headline 1" *** Headline 3 Group is "Headline 1:Headline 2" Everything seems to work as expected when `imenu-flatten' is set to 'prefix or 'annotation. * lisp/org-compat.el (org-imenu-get-tree): Add the current headline to the tree as a simple item even if it isn't a leaf. --- lisp/org-compat.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/org-compat.el b/lisp/org-compat.el index d6620f962..a1152186d 100644 --- a/lisp/org-compat.el +++ b/lisp/org-compat.el @@ -1447,8 +1447,8 @@ This also applied for speedbar access." (let* ((m (point-marker)) (item (propertize headline 'org-imenu-marker m 'org-imenu t))) (push m org-imenu-markers) - (if (>= level last-level) - (push (cons item m) (aref subs level)) + (push (cons item m) (aref subs level)) + (unless (>= level last-level) (push (cons item (cl-mapcan #'identity (cl-subseq subs (1+ level)))) (aref subs level)) -- 2.45.1