bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#68648: 30.0.50; read-only-mode-hook's are not executed when buffer-r


From: Eli Zaretskii
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

> 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.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]