2

I am still using older emacs versions (27.1 & 26.1 are on my work machines).

At some point I likely want to upgrade, but one thing that I use quite frequently is toggle-read-only, which gives me a deprecation warning and tells my I should switch to read-only-mode instead.

Is there any difference between the two? Or can I just write something like (advice-add 'toggle-read-only :override 'read-only-mode) in my .emacs?

2 Answers 2

3

Prior to Emacs 24, toggle-read-only itself did much of what read-only-mode code does (make use of view-mode etc.).

From Emacs 24 until Emacs 29, toggle-read-only just used read-only-mode:

(defun toggle-read-only (&optional arg interactive) "Change whether this buffer is read-only." (declare (obsolete read-only-mode "24.3")) (interactive (list current-prefix-arg t)) (if interactive (call-interactively 'read-only-mode) (read-only-mode (or arg 'toggle)))) 

Starting with Emacs 29 they removed toggle-read-only altogether, presumably as being essentially redundant.

If you are only using toggle-read-only interactively then just switch to using read-only-mode. If you are using toggle-read-only in some Lisp code you have, and if you're using Emacs 29 or later, then you'll either need to adjust your Lisp code, to use read-only-mode, or add the old code (above) that defines toggle-read-only.

3

As of 24.3, toggle-read-only is just a wrapper for read-only-mode (which was also introduced in 24.3).

(defun toggle-read-only (&optional arg interactive) "Change whether this buffer is read-only." (declare (obsolete read-only-mode "24.3")) (interactive (list current-prefix-arg t)) (if interactive (call-interactively 'read-only-mode) (read-only-mode (or arg 'toggle)))) 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.