all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 34720@debbugs.gnu.org, dunni@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	[thread overview]
Message-ID: <87ftln2f0f.fsf@gnus.org> (raw)
In-Reply-To: <83mufvdomu.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 27 Aug 2019 11:00:09 +0300")

Eli Zaretskii <eliz@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





  reply	other threads:[~2019-08-27  8:23 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-03 15:28 bug#34720: 26.1; Reverting a GPG buffer moves all markers to the end of the file Ian Dunn
2019-07-09 16:33 ` Lars Ingebrigtsen
2019-08-26  7:20   ` Lars Ingebrigtsen
2019-08-26  7:59     ` Eli Zaretskii
2019-08-26  8:14       ` Lars Ingebrigtsen
2019-08-26  9:42         ` Eli Zaretskii
2019-08-27  7:14           ` Lars Ingebrigtsen
2019-08-27  8:00             ` Eli Zaretskii
2019-08-27  8:23               ` Lars Ingebrigtsen [this message]
2019-08-27  8:41                 ` Eli Zaretskii
2019-08-27  9:05                   ` Lars Ingebrigtsen
2019-08-27  9:17                     ` Eli Zaretskii
2019-08-27  9:15                   ` Lars Ingebrigtsen
2019-08-27 10:20                     ` Eli Zaretskii
2019-08-30  9:48                       ` Lars Ingebrigtsen
2019-08-30 10:21                         ` Lars Ingebrigtsen
2019-08-30 12:19                         ` Eli Zaretskii
2019-08-27  8:37               ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ftln2f0f.fsf@gnus.org \
    --to=larsi@gnus.org \
    --cc=34720@debbugs.gnu.org \
    --cc=dunni@gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.