GNU bug report logs - #30028
24.5; behavior and doc of `revert-buffer' wrt markers

Previous Next

Package: emacs;

Reported by: Drew Adams <drew.adams <at> oracle.com>

Date: Mon, 8 Jan 2018 18:19:01 UTC

Severity: minor

Tags: fixed

Found in version 24.5

Fixed in version 28.1

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

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 30028 in the body.
You can then email your comments to 30028 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#30028; Package emacs. (Mon, 08 Jan 2018 18:19:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Drew Adams <drew.adams <at> oracle.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 08 Jan 2018 18:19:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.5; behavior and doc of `revert-buffer' wrt markers
Date: Mon, 8 Jan 2018 09:35:48 -0800 (PST)
That markers are typically restored when you revert is important.
This behavior is not very well documented, I think.

1. Doc: The elisp manual (node `Reverting'), but not the doc string,
   mentions that markers at the beginning and end of the buffer (after
   changes) are generally preserved (restored).  The doc string should
   mention this also - it says nothing about markers.

2. Doc: This restoring of markers happens for visited files, but not
   necessarily for other buffers, presumably.  The doc in at least the
   manual should make this clear.

3. Behavior: The manual says that preserving other markers, besides
   those described, "would be problematical".  (You might want to change
   that to "problematic", but this is not important -
   http://grammarist.com/usage/problematic-problematical)

   I can understand that in some cases restoring a marker would not
   position it correctly.  But I don't see why Emacs wouldn't/couldn't
   restore all markers anyway.  Or does it?  The doc does not make clear
   whether markers that are not "preserved" are deleted or just not
   necessarily in the correct positions.  Please make clear just how
   (all) markers are handled.

   What criteria does Emacs use for filtering out markers that it
   decides not to restore?

4. Trying to track down where the marker handling
   (e.g. saving/restoring) takes place sent me down multiple levels
   of code.  My guess (I don't have the C sources) is that it is
   actually done in `insert-file-contents'.  But the doc for that
   function (both (elisp) `Reading from Files' and doc string) says even
   less about marker handling than does the doc for `revert-buffer'.
   Can we please get more informative doc about this handling?



In GNU Emacs 24.5.1 (i686-pc-mingw32)
 of 2015-04-11 on LEG570
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --prefix=/c/usr --host=i686-pc-mingw32'




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#30028; Package emacs. (Sat, 12 Dec 2020 11:22:01 GMT) Full text and rfc822 format available.

Message #8 received at 30028 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: 30028 <at> debbugs.gnu.org
Subject: Re: bug#30028: 24.5; behavior and doc of `revert-buffer' wrt markers
Date: Sat, 12 Dec 2020 12:20:53 +0100
Drew Adams <drew.adams <at> oracle.com> writes:

> That markers are typically restored when you revert is important.
> This behavior is not very well documented, I think.
>
> 1. Doc: The elisp manual (node `Reverting'), but not the doc string,
>    mentions that markers at the beginning and end of the buffer (after
>    changes) are generally preserved (restored).  The doc string should
>    mention this also - it says nothing about markers.

I've now mentioned this in the doc string (and punting to the manual for
details).

> 2. Doc: This restoring of markers happens for visited files, but not
>    necessarily for other buffers, presumably.  The doc in at least the
>    manual should make this clear.

Yes, it's up to the specific `revert-buffer-function'.  I've now
mentioned this in the manual.

> 3. Behavior: The manual says that preserving other markers, besides
>    those described, "would be problematical".  (You might want to change
>    that to "problematic", but this is not important -
>    http://grammarist.com/usage/problematic-problematical)

Done.

>    I can understand that in some cases restoring a marker would not
>    position it correctly.  But I don't see why Emacs wouldn't/couldn't
>    restore all markers anyway.  Or does it?  The doc does not make clear
>    whether markers that are not "preserved" are deleted or just not
>    necessarily in the correct positions.  Please make clear just how
>    (all) markers are handled.
>
>    What criteria does Emacs use for filtering out markers that it
>    decides not to restore?

The manual says:

---
If they are not identical, reverting does change the buffer; in that
case, it preserves the markers in the unchanged text (if any) at the
beginning and end of the buffer.
---

So it restores markers in identical text at the start and end.  I don't
see what's unclear about that.

> 4. Trying to track down where the marker handling
>    (e.g. saving/restoring) takes place sent me down multiple levels
>    of code.  My guess (I don't have the C sources) is that it is
>    actually done in `insert-file-contents'.  But the doc for that
>    function (both (elisp) `Reading from Files' and doc string) says even
>    less about marker handling than does the doc for `revert-buffer'.
>    Can we please get more informative doc about this handling?

The Reverting node is actually describing what's happening in that
function, which is why that section starts with:

---
Reverting tries to preserve marker positions in the buffer by using the
replacement feature of @code{insert-file-contents}.
---

The `insert-file-contents' doc string is more vague here...  I'll add
the sentence about the start/end bits.

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




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 12 Dec 2020 11:22:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.1, send any further explanations to 30028 <at> debbugs.gnu.org and Drew Adams <drew.adams <at> oracle.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 12 Dec 2020 11:22:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 09 Jan 2021 12:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 101 days ago.

Previous Next


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