GNU bug report logs - #34720
26.1; Reverting a GPG buffer moves all markers to the end of the file

Previous Next

Package: emacs;

Reported by: Ian Dunn <dunni <at> gnu.org>

Date: Sun, 3 Mar 2019 15:29:01 UTC

Severity: normal

Tags: confirmed, fixed

Found in version 26.1

Fixed in version 27.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 34720 <at> debbugs.gnu.org, dunni <at> gnu.org
Subject: bug#34720: 26.1; Reverting a GPG buffer moves all markers to the end of the file
Date: Tue, 27 Aug 2019 10:23:28 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

> These just restore a single marker: the point marker.  That's a far
> cry from restoring all the markers.  I don't think the latter is
> possible in all cases without violating the principle of least
> astonishment (by placing the markers at locations that have nothing in
> comm on with where they have been before the editing operation).

Hm.  Doesn't the code below restore all markers (that it can restore)?

static void
restore_window_points (Lisp_Object window_markers, ptrdiff_t inserted,
		       ptrdiff_t same_at_start, ptrdiff_t same_at_end)
{
  for (; CONSP (window_markers); window_markers = XCDR (window_markers))
    if (CONSP (XCAR (window_markers)))
      {
	Lisp_Object car = XCAR (window_markers);
	Lisp_Object marker = XCAR (car);
	Lisp_Object oldpos = XCDR (car);
	if (MARKERP (marker) && FIXNUMP (oldpos)
	    && XFIXNUM (oldpos) > same_at_start
	    && XFIXNUM (oldpos) < same_at_end)
	  {
	    ptrdiff_t oldsize = same_at_end - same_at_start;
	    ptrdiff_t newsize = inserted;
	    double growth = newsize / (double)oldsize;
	    ptrdiff_t newpos
	      = same_at_start + growth * (XFIXNUM (oldpos) - same_at_start);
	    Fset_marker (marker, make_fixnum (newpos), Qnil);
	  }
      }
}

And I just tested with the test case in this bug report, which is

(progn
  (setq test-marker (make-marker))
  (move-marker test-marker (point)))

append to the file, and then `M-x revert-buffer': test-marker remains at
the same position.

So I think Finsert_file_contents really restores (for some value of
"restores") all the markers?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




This bug report was last modified 5 years and 261 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.