From: Eli Zaretskii <eliz@gnu.org>
To: "Björn Bidar" <bjorn.bidar@thaodan.de>
Cc: 68648@debbugs.gnu.org
Subject: bug#68648: 30.0.50; read-only-mode-hook's are not executed when buffer-read-only is t
Date: Tue, 23 Jan 2024 20:23:16 +0200 [thread overview]
Message-ID: <86a5ov6h9n.fsf@gnu.org> (raw)
In-Reply-To: <874jf4nove.fsf@> (message from Björn Bidar on Tue, 23 Jan 2024 15:47:01 +0200)
> From: Björn Bidar <bjorn.bidar@thaodan.de>
> Cc: Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors <bug-gnu-emacs@gnu.org>,
> 68648@debbugs.gnu.org
> Date: Tue, 23 Jan 2024 15:47:01 +0200
>
> Eli Zaretskii <eliz@gnu.org> writes:
>
> >> 1. (add-hook 'read-only-mode-hook (lambda () (print "foobar")))
> >> 2. open file that is read-only
> >> 3. foobar should be print but isn't.
> >
> > That's because read-only-mode is not entered when you visit a
> > write-protected file.
>
> It does look like the mode is entered because when calling
> read-only-mode it is disabled.
That's only a circumstantial evidence. read-only-mode is a thin
wrapper around buffer-read-only variable, but setting buffer-read-only
directly (which is what we do when you visit a write-protected file)
doesn't invoke the mode function, and thus the mode hook is not run.
For the same reason, the setting of view-read-only is not honored in
the scenario you described.
next prev parent reply other threads:[~2024-01-23 18:23 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <875xzma0hd.fsf@>
2024-01-22 9:00 ` bug#68648: 30.0.50; read-only-mode-hook's are not executed when buffer-read-only is t Eli Zaretskii
2024-01-23 13:47 ` Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-23 13:47 ` Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors
[not found] ` <874jf4nove.fsf@>
2024-01-23 18:23 ` Eli Zaretskii [this message]
2024-02-01 9:48 ` Eli Zaretskii
2024-02-01 14:17 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-01 14:58 ` Eli Zaretskii
2024-02-01 17:58 ` Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-03 9:32 ` Eli Zaretskii
2024-02-03 16:28 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-03 22:09 ` Stefan Kangas
2024-02-10 8:37 ` Eli Zaretskii
2024-01-21 20:35 Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors
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=86a5ov6h9n.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=68648@debbugs.gnu.org \
--cc=bjorn.bidar@thaodan.de \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).