all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#75072: [PATCH] Set marker insertion type for Imenu markers
@ 2024-12-24 22:58 Morgan Willcock
  2024-12-25 10:02 ` Morgan Willcock
  2024-12-25 12:00 ` Eli Zaretskii
  0 siblings, 2 replies; 4+ messages in thread
From: Morgan Willcock @ 2024-12-24 22:58 UTC (permalink / raw)
  To: 75072

[-- Attachment #1: Type: text/plain, Size: 1286 bytes --]

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'


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Set-marker-insertion-type-for-Imenu-markers.patch --]
[-- Type: text/patch, Size: 1168 bytes --]

From 814ace3cda2c793a1d772f64c200d1f533cc94e5 Mon Sep 17 00:00:00 2001
From: Morgan Willcock <morgan@ice9.digital>
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


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

end of thread, other threads:[~2024-12-26  9:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-24 22:58 bug#75072: [PATCH] Set marker insertion type for Imenu markers Morgan Willcock
2024-12-25 10:02 ` Morgan Willcock
2024-12-26  9:00   ` Eli Zaretskii
2024-12-25 12:00 ` Eli Zaretskii

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.