From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: phillip.lord@newcastle.ac.uk (Phillip Lord) Newsgroups: gmane.emacs.devel Subject: [Request for Mentor] subst-char-in-region Date: Fri, 12 Dec 2014 11:43:43 +0000 Message-ID: <87r3w5jdow.fsf@newcastle.ac.uk> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1418384693 13376 80.91.229.3 (12 Dec 2014 11:44:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 12 Dec 2014 11:44:53 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Dec 12 12:44:42 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XzOeE-000666-9M for ged-emacs-devel@m.gmane.org; Fri, 12 Dec 2014 12:44:38 +0100 Original-Received: from localhost ([::1]:56707 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XzOeD-0004o6-Tw for ged-emacs-devel@m.gmane.org; Fri, 12 Dec 2014 06:44:37 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57762) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XzOdX-00042G-Hu for emacs-devel@gnu.org; Fri, 12 Dec 2014 06:44:01 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XzOdO-0007Jt-Ob for emacs-devel@gnu.org; Fri, 12 Dec 2014 06:43:55 -0500 Original-Received: from cheviot22.ncl.ac.uk ([128.240.234.22]:36414) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XzOdO-0007JS-ID for emacs-devel@gnu.org; Fri, 12 Dec 2014 06:43:46 -0500 Original-Received: from smtpauth-vm.ncl.ac.uk ([10.8.233.129] helo=smtpauth.ncl.ac.uk) by cheviot22.ncl.ac.uk with esmtp (Exim 4.63) (envelope-from ) id 1XzOdL-00050E-Ef for emacs-devel@gnu.org; Fri, 12 Dec 2014 11:43:44 +0000 Original-Received: from jangai.ncl.ac.uk ([10.66.67.223] helo=localhost) by smtpauth.ncl.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.63) (envelope-from ) id 1XzOdL-0001UX-FH for emacs-devel@gnu.org; Fri, 12 Dec 2014 11:43:43 +0000 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 128.240.234.22 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:179890 Archived-At: --=-=-= Content-Type: text/plain 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. --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=open.el Content-Transfer-Encoding: quoted-printable (setq enable-local-variables nil) (setq inhibit-splash-screen t) (load-file "~/emacs/lentic/noisy-change.el") (switch-to-buffer "test-buffer") (setq noisy-change-log t) (insert "ooo\nbbb") (split-window-below) (switch-to-buffer "*noisy-change-log*") (other-window 1) (defun temp() (interactive) (subst-char-in-region (point-min) (point-max) ?o ?x)) --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=noisy-change.el Content-Transfer-Encoding: quoted-printable (defvar noisy-change-log nil) (make-variable-buffer-local 'noisy-change-log) (defmacro noisy-change-log (&rest rest) "Log REST." `(when noisy-change-log (with-current-buffer (get-buffer-create "*noisy-change-log*") (goto-char (point-max)) (insert (concat (format ,@rest) "\n"))))) (defun noisy-change-before-function (start stop) (noisy-change-log "before(%s,%s)" start stop)) (defun noisy-change-after-function (start stop length) (noisy-change-log "after(%s,%s,%s)" start stop length)) (add-hook 'before-change-functions 'noisy-change-before-function) (add-hook 'after-change-functions 'noisy-change-after-function) --=-=-=--