BUF_TS_LINECOL_POINT (current_buffer));
#endif
+ /* Run the before-change-functions *before* we move the gap. */
+ modify_text (start1, end2);
+
/* Make sure the gap won't interfere, by moving it out of the text
we will operate on. */
if (start1 < gap && gap < end2)
enough to use as the temporary storage? That would avoid an
allocation... interesting. Later, don't fool with it now. */
- modify_text (start1, end2);
tmp_interval1 = copy_intervals (cur_intv, start1, len1);
tmp_interval2 = copy_intervals (cur_intv, start2, len2);
USE_SAFE_ALLOCA;
(should (string= (format "%S" (format "%S %S" [1] (symbol-function '+)))
str))))
+(ert-deftest editfns-tests--bug76124 ()
+ (with-temp-buffer
+ (insert "Emacs forever!foo\n")
+ (insert "toto\n")
+ (goto-char (point-min))
+ ;; Remove the trailing "foo", so as to move the gap between the
+ ;; two lines.
+ (delete-region (- (pos-eol) 3) (pos-eol))
+ (add-hook 'before-change-functions
+ (lambda (beg end)
+ ;; Eglot uses `encode-coding-region' which can also move
+ ;; the gap, but let's do it more forcefully here.
+ (save-excursion
+ (goto-char beg)
+ (end-of-line)
+ (unless (> (point) end)
+ (with-silent-modifications
+ (insert "foo")
+ (delete-char -3)))))
+ nil t)
+ (goto-char (point-min))
+ (transpose-regions (pos-bol) (pos-eol)
+ (pos-bol 2) (pos-eol 2))
+ (should (equal (buffer-string) "toto\nEmacs forever!\n"))))
+
;;; editfns-tests.el ends here