On Thu, Jun 13, 2019 at 4:36 PM Eli Zaretskii wrote: > > > From: Pip Cet > > Date: Thu, 13 Jun 2019 13:48:40 +0000 > > > > I've looked at the code, and it appears no particular provisions are > > being made to make sure we switch to the modified buffer before > > calling signal_after_change(). > > > > As far as I can tell, this makes `put-text-property' with a buffer > > argument pretty useless. > > Only if you have a buffer-local value of after-change-functions. I'm not sure what you're saying. I'm seeing weird behavior in these cases: - buffer-local value of after-change-functions - global value of after-change functions (current-buffer is wrong!) - overlay property modification-hooks (let ((buffer1 (generate-new-buffer "A")) (buffer2 (generate-new-buffer "B"))) (with-current-buffer buffer2 (insert "BBB")) (with-current-buffer buffer1 (insert "AAA") (overlay-put (make-overlay 1 4 buffer1) 'modification-hooks (list (lambda (&rest args) (message "%S" args)))) (goto-char 2) (insert "AAA") (put-text-property 1 4 'read-only t buffer2))) produces three calls to the lambda, but should produce only two. (The last_overlay_modification_hooks logic is a bit weird, thus the second insertion). That seems pretty wrong to me. In which cases do you think we're seeing the right behavior? Here's a first patch, which adds a "buffer" argument to signal_after_change, to be explicit about where the change happens. It should be pretty cheap in the case where we don't switch buffers.