diff options
| author | Alan Mackenzie | 2021-11-12 18:43:22 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2021-11-12 18:43:22 +0000 |
| commit | 974192413f8a81171b8fd28dfd5c081ce06d3dec (patch) | |
| tree | 5d9dfc6b4a9b16de5d4d00e3d4fc129bf606a35c | |
| parent | 2c5be6ddca96443722e5e527a015b1d3574ed081 (diff) | |
| download | emacs-974192413f8a81171b8fd28dfd5c081ce06d3dec.tar.gz emacs-974192413f8a81171b8fd28dfd5c081ce06d3dec.zip | |
In insert_file_contents, always set windows' point markers.
This fixes bug #51776.
* src/fileio.c (restore_window_points): Restore a w->mpoint even when that
marker originally pointed into the unchanged area near BOB or EOB. This
prevents that window's point being moved a long way from its starting place
due to the removal of the central part of the buffer by insert_file_contents.
| -rw-r--r-- | src/fileio.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/fileio.c b/src/fileio.c index 3c13d3fe416..a7b1649fae8 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -3827,6 +3827,7 @@ restore_window_points (Lisp_Object window_markers, ptrdiff_t inserted, | |||
| 3827 | Lisp_Object car = XCAR (window_markers); | 3827 | Lisp_Object car = XCAR (window_markers); |
| 3828 | Lisp_Object marker = XCAR (car); | 3828 | Lisp_Object marker = XCAR (car); |
| 3829 | Lisp_Object oldpos = XCDR (car); | 3829 | Lisp_Object oldpos = XCDR (car); |
| 3830 | ptrdiff_t newpos; | ||
| 3830 | if (MARKERP (marker) && FIXNUMP (oldpos) | 3831 | if (MARKERP (marker) && FIXNUMP (oldpos) |
| 3831 | && XFIXNUM (oldpos) > same_at_start | 3832 | && XFIXNUM (oldpos) > same_at_start |
| 3832 | && XFIXNUM (oldpos) < same_at_end) | 3833 | && XFIXNUM (oldpos) < same_at_end) |
| @@ -3834,10 +3835,12 @@ restore_window_points (Lisp_Object window_markers, ptrdiff_t inserted, | |||
| 3834 | ptrdiff_t oldsize = same_at_end - same_at_start; | 3835 | ptrdiff_t oldsize = same_at_end - same_at_start; |
| 3835 | ptrdiff_t newsize = inserted; | 3836 | ptrdiff_t newsize = inserted; |
| 3836 | double growth = newsize / (double)oldsize; | 3837 | double growth = newsize / (double)oldsize; |
| 3837 | ptrdiff_t newpos | 3838 | newpos = same_at_start |
| 3838 | = same_at_start + growth * (XFIXNUM (oldpos) - same_at_start); | 3839 | + growth * (XFIXNUM (oldpos) - same_at_start); |
| 3839 | Fset_marker (marker, make_fixnum (newpos), Qnil); | ||
| 3840 | } | 3840 | } |
| 3841 | else | ||
| 3842 | newpos = XFIXNUM (oldpos); | ||
| 3843 | Fset_marker (marker, make_fixnum (newpos), Qnil); | ||
| 3841 | } | 3844 | } |
| 3842 | } | 3845 | } |
| 3843 | 3846 | ||