Subject: bug#77221: [PATCH] modification hooks are called 3x for each yank

From: JD Smith <[email-masked]>
Date: Sun, 23 Mar 2025 18:14:03 -0400

Evaluate:

 (add-hook 'after-change-functions (lambda (beg end len) (message "GOT %s->%s [%s]" beg end len)) nil t)

Then yank text.  You'll see the before/after change functions are called 3x upon each yank.  This is due to the final text property changes made by `insert-for-yank-1'.  For substantial amounts of yanked text, this is inefficient.  

Patch attached.