all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [Request for Mentor] subst-char-in-region
@ 2014-12-12 11:43 Phillip Lord
  2014-12-12 14:35 ` Stefan Monnier
  0 siblings, 1 reply; 9+ messages in thread
From: Phillip Lord @ 2014-12-12 11:43 UTC (permalink / raw)
  To: emacs-devel

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



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 #2: open.el --]
[-- Type: application/emacs-lisp, Size: 379 bytes --]

[-- Attachment #3: noisy-change.el --]
[-- Type: application/emacs-lisp, Size: 702 bytes --]

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

end of thread, other threads:[~2014-12-16 16:05 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-12 11:43 [Request for Mentor] subst-char-in-region Phillip Lord
2014-12-12 14:35 ` Stefan Monnier
2014-12-12 15:05   ` Phillip Lord
2014-12-12 16:17     ` Stefan Monnier
2014-12-15 12:15       ` Phillip Lord
2014-12-15 14:29         ` Stefan Monnier
2014-12-16 11:30           ` Phillip Lord
2014-12-16 14:07             ` Stefan Monnier
2014-12-16 16:05               ` Phillip Lord

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.