Subject: Re: bug#68648: 30.0.50; read-only-mode-hook's are not executed when buffer-read-only is t

From: Björn Bidar <[email-masked]>
Date: Tue, 23 Jan 2024 15:47:01 +0200

Eli Zaretskii <[email-masked]> writes:

> On January 21, 2024 10:35:26 PM GMT+02:00, "Björn Bidar via Bug
> reports for GNU Emacs, the Swiss army knife of text editors"
> <[email-masked]> wrote:
>> I noticed when opening a file which isn't readable that
>> read-only-mode-hooks are not executed.
>> 
>> 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.