From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Morgan Willcock Newsgroups: gmane.emacs.bugs Subject: bug#75072: [PATCH] Set marker insertion type for Imenu markers Date: Tue, 24 Dec 2024 22:58:08 +0000 Message-ID: <87ldw4664f.fsf@ice9.digital> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16925"; mail-complaints-to="usenet@ciao.gmane.io" To: 75072@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Dec 24 23:59:15 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tQDru-0004Fg-P1 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 24 Dec 2024 23:59:15 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQDri-0002HF-Vt; Tue, 24 Dec 2024 17:59:03 -0500 Original-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 1tQDri-0002H4-6N for bug-gnu-emacs@gnu.org; Tue, 24 Dec 2024 17:59:02 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQDrh-0003fU-Tc for bug-gnu-emacs@gnu.org; Tue, 24 Dec 2024 17:59:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:Subject; bh=t6s/KJ9PdKdmS2u/iCLHDHaK2dgOwVyzRtW6WYUWJvw=; b=QZ1NqNoryBaGVr5dnmuXXH07oFJ9SCjD9gdkSL0W0BNEuvSkUnRiXEyMuJYNsT50KG6NY7evUDiJaXS8WWzHrR8EQkcScXOBxFPSo2Rua3sM4XcPfagur+OsImtyp8vLYsWnOHfxr1jxzi2eS8GmLn6DztkBuq1RUPERYUrobabmQhY4woRXInrAGm/ydEsFbQZ8ZGZy1m8ALdkbO136pNjbo5WPt68ZeCI75OHTE8oTGh9MqCqu3UMU83RWTf5eVp+aFS/kAOxV9aAUChCansS++0TCgW2K7YVpX7h4yVhnRpNw8Ym0CUf6YyEpNtUaaB7zc9ke6rTGrjp2VGI5Cw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tQDrh-0004HF-OZ for bug-gnu-emacs@gnu.org; Tue, 24 Dec 2024 17:59:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Morgan Willcock Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 24 Dec 2024 22:59:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 75072 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.173508111016384 (code B ref -1); Tue, 24 Dec 2024 22:59:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 24 Dec 2024 22:58:30 +0000 Original-Received: from localhost ([127.0.0.1]:35297 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tQDrB-0004G8-Pr for submit@debbugs.gnu.org; Tue, 24 Dec 2024 17:58:30 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:43758) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tQDr9-0004Fz-Ee for submit@debbugs.gnu.org; Tue, 24 Dec 2024 17:58:28 -0500 Original-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 1tQDr6-0002FW-Vh for bug-gnu-emacs@gnu.org; Tue, 24 Dec 2024 17:58:26 -0500 Original-Received: from relay2-d.mail.gandi.net ([2001:4b98:dc4:8::222]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tQDr2-0003cQ-S1 for bug-gnu-emacs@gnu.org; Tue, 24 Dec 2024 17:58:24 -0500 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 014B840003 for ; Tue, 24 Dec 2024 22:58:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ice9.digital; s=gm1; t=1735081096; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=t6s/KJ9PdKdmS2u/iCLHDHaK2dgOwVyzRtW6WYUWJvw=; b=VZhD/8j2qYBZ2ScSykfVB+/cCkbTJAZuDZnL3V8kTfLQI9u3oL9Zh0ONICKvUmuK/7is6i ExI7QmjwWTaCAcX1dJWe3r2f2hO4oZweuSFEL2hwropkgCQ3Th3Q2YL6X1ZuBrmd12d4Kg zxMAsnF4+oofpYRY66lh6Locksiy6K4YSpeDuIXYkDoux4YOtnM88n8YNF0PhrROnVzuuR og5h64Iaoe3Eh1hAq8KeoEjcrHHWGntNN6Q38qk7x9EpyNJP8LrXajXfW6jIC7c1IbvsIo +4Xklt4Yhq+xYymvg+wlz8IcQhm1z316nCoBIcbVtNFDO2ABprzhJ6KG+ZcJnQ== X-GND-Sasl: morgan@ice9.digital Received-SPF: pass client-ip=2001:4b98:dc4:8::222; envelope-from=morgan@ice9.digital; helo=relay2-d.mail.gandi.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:297704 Archived-At: --=-=-= Content-Type: text/plain Tags: patch The internal Imenu function for creating an Imenu index uses markers by default, but the marker insertion type is left at the default type which does not advance the marker position when additional characters are inserted at the marker position. Attached is a patch which sets the marker insertion type to advance the marker position in the same scenario. This change means that the Imenu index will continue to be valid instead of the marker becoming desynced from the buffer contents, i.e. jumping to an index position and inserting characters will keep the marker in the correct place. I can't think of a situation where the previous marker behaviour was intentional, but it is likely that the issue wouldn't be seen by anyone who sets imenu-auto-rescan to t or in modes which do not use both imenu-prev-index-position-function and imenu-extract-index-name-function to create the Imenu index. I've assumed this would go on the master branch. Thanks, Morgan In GNU Emacs 30.0.93 (build 2, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw3d scroll bars) of 2024-12-20 built on inspiron System Description: Debian GNU/Linux 12 (bookworm) Configured using: 'configure --with-native-compilation=aot --with-xml2 --with-x-toolkit=lucid --with-tree-sitter' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-Set-marker-insertion-type-for-Imenu-markers.patch >From 814ace3cda2c793a1d772f64c200d1f533cc94e5 Mon Sep 17 00:00:00 2001 From: Morgan Willcock Date: Tue, 24 Dec 2024 21:39:43 +0000 Subject: [PATCH] Set marker insertion type for Imenu markers * lisp/imenu.el (imenu-default-create-index-function): Configure Imenu markers to advance their position when text is inserted at the marker position. --- lisp/imenu.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lisp/imenu.el b/lisp/imenu.el index ba1ba5fcd00..0c6a7080e17 100644 --- a/lisp/imenu.el +++ b/lisp/imenu.el @@ -583,7 +583,11 @@ imenu-default-create-index-function (and (stringp name) ;; [ydi] Updated for imenu-use-markers. (push (cons name - (if imenu-use-markers (point-marker) (point))) + (if imenu-use-markers + (let ((marker (point-marker))) + (set-marker-insertion-type marker t) + marker) + (point))) index-alist))) index-alist)) ;; Use generic expression if possible. -- 2.39.5 --=-=-=--