unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: hw <hw@adminart.net>
To: help-gnu-emacs@gnu.org
Subject: Re: What should I use to unrestrict a buffer?
Date: Thu, 08 Feb 2024 06:38:15 +0100	[thread overview]
Message-ID: <6566e11c1b329e777c4e9dd7f62e662d6c484829.camel@adminart.net> (raw)
In-Reply-To: <86y1cdb5h6.fsf@gnu.org>

On Thu, 2024-01-25 at 21:03 +0200, Eli Zaretskii wrote:
> > From: hw <hw@adminart.net>
> > Date: Thu, 25 Jan 2024 19:30:17 +0100
> > 
> > On Thu, 2024-01-25 at 09:14 +0200, Eli Zaretskii wrote:
> > > > From: hw <hw@adminart.net>
> > > > Date: Wed, 24 Jan 2024 21:12:56 +0100
> > > > 
> > > > Also, I don't want possible restrictions to be restored, like
> > > > (without-restriction) would do.
> > > 
> > > Why not?  After you do whatever you need to do with the widened
> > > buffer, you are supposed to return the restrictions to their previous
> > > state, and that includes restoring the restrictions present before the
> > > widening.  Why would you need to avoid restoring them, and thus change
> > > the restrictions behind some other Lisp program which doesn't expect
> > > its restrictions to be lifted?
> > 
> > I want to behold the whole buffer after the operation was performed to
> > see if the outcome looks ok.  And if the external program has found an
> > error, it puts a message into the first line of its output (the
> > buffer) which I'm unlikely to be able to see when the buffer is
> > restricted.
> > 
> > Keeping or restoring restrictions wouldn't be useful.
> 
> The restrictions that cannot be lifted via a call to 'widen' aren't
> supposed to be lifted.  IOW, a Lisp program that calls 'widen' is not
> allowed to look beyond those restrictions that 'widen' cannot remove.
> So what you want to do is not supposed to be done, and this is a
> protocol of using restrictions in Emacs.
> 
> The problem is not serious, btw, since it is a very rare situation to
> see such restrictions in practice.  So you can simply disregard that
> possibility.

I can't just disregard the problem because disregarding it means that
many hours of work which may have been done over many years could get
lost in an instance just because some buffer restriction has been
overlooked.

Is there a way to find out if any restrictions are in effect so that
the function may refuse to replace the buffer contents when
restrictions could lead to loosing those contents, or parts of them?

Otherwise it's an accident waiting to happen, and it basically makes
all functionality to pipe buffer contents through external programs
and updating the buffer with the result, if not useless, at least a
bad security risk.




      reply	other threads:[~2024-02-08  5:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-24 20:12 What should I use to unrestrict a buffer? hw
2024-01-25  7:14 ` Eli Zaretskii
2024-01-25 18:30   ` hw
2024-01-25 19:03     ` Eli Zaretskii
2024-02-08  5:38       ` hw [this message]

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=6566e11c1b329e777c4e9dd7f62e662d6c484829.camel@adminart.net \
    --to=hw@adminart.net \
    --cc=help-gnu-emacs@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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).