emacs-devel
[Top][All Lists]
Advanced

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

[Request for Mentor] subst-char-in-region


From: Phillip Lord
Subject: [Request for Mentor] subst-char-in-region
Date: Fri, 12 Dec 2014 11:43:43 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)


I believe that subst-char-in-region is signally incorrectly to before
and after-change-functions. This is causing me difficulties with a
package I am writing (lentic, formerly linked-buffer), as
subst-char-in-region is called by fill-paragraph which breaks lentic.

In a clean emacs, launched with the file open.el (it and noisy-change.el
are attached), I create a single buffer with contents

ooo
bbb

Changing ooo to xxx reports the following from Emacs

before(1,8)
after(1,4,3)

But this does not really make sense to me because the start and stop
reported by the before-change-function is much wider than that reported
by the after-change-functions. The reason for this is that the
before-change-function gets from the first change to the end of the
entire region here (in editfns.c)

modify_text (pos, XINT (end));

while after-change gets from the start to the last changed character here.

signal_after_change (changed,
                   last_changed - changed, last_changed - changed);


I have created a (bad) fix for this, currently on branch...

origin/fix/subst-char-in-region

(hopefully adding a new branch is okay for this, obviously it can be
deleted later). After adding this fix I get...

before(1,8)
after(1,8,8)

This seems consistent and correct to me. My fix is not good though since
it is overly conservative. It's probably bad for other reasons also
since I don't know C (willing to learn though).

Assuming others agree with me that this behaviour is wrong, I would like
to fix the problem, but would welcome some help and code review.


Attachment: open.el
Description: application/emacs-lisp

Attachment: noisy-change.el
Description: application/emacs-lisp


reply via email to

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