emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] iimage-mode: reset point for each regexp


From: LensPlaysGames
Subject: [PATCH] iimage-mode: reset point for each regexp
Date: Sun, 5 Feb 2023 13:46:20 -0800

When creating a minor mode that would replace certain regexp matches
with inline images, I was glad to find iimage-mode already existed to
make this process easier; better yet, it's built in to Emacs core.
However, upon customising the functionality of this mode, by altering
iimage-mode-image-regex-alist to contain more than one item, I found
an interesting quirk of the mode's behaviour. If a regular expression
early in the list matched late in the buffer, then regular expression
matches later in the list would no longer replace matches early in the
buffer. I didn't expect the alist to have such strict ordering, and
I'm not sure if that's intentional, especially as the defaults have
only one element in this alist.

When peering at the source code, I didn't notice any documentation
indicating that this behaviour is expected. I also noticed the cause
of this behaviour: '(goto-char (point-min))' is used outside of the
'dolist' iteration that loops over regular expressions to match, which
means that each regexp search begins at the end of the last... By
moving this goto-char call one line down, within the 'dolist' body,
each regexp search begins at, well, the beginning. This gives expected
behaviour in my minor mode (such that an alphabetized list of exact
matches can have all occurrences replaced with inline images in a
buffer). If this behaviour is intended, feel free to ignore this post.

Attached is a patch generated with git that implements the above change.

Attachment: iimage.patch
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]