rot13-other-window}. This displays the current buffer in another window
which applies the code when displaying the text.
+@findex rot13-region
+ If you are only interested in a region, the command @kbd{M-x
+rot13-region} might be preferable. This will encrypt/decrypt the
+active region in-place. If the buffer is read-only, it will attempt
+to display the plain text in the echo area. If the text is too long
+for the echo area, the command will pop up a temporary buffer with the
+encrypted/decrypted text.
+
@node Movemail
@section @command{movemail} program
@cindex @command{movemail} program
;;;###autoload
(defun rot13-region (start end)
- "ROT13 encrypt the region between START and END in current buffer."
+ "ROT13 encrypt the region between START and END in current buffer.
+If invoked interactively and the buffer is read-only, a message
+will be printed instead."
(interactive "r")
- (translate-region start end rot13-translate-table))
+ (condition-case nil
+ (translate-region start end rot13-translate-table)
+ (buffer-read-only
+ (when (called-interactively-p 'interactive)
+ (let ((dec (rot13-string (buffer-substring start end))))
+ (message "Buffer is read-only:\n%s" (string-trim dec)))))))
;;;###autoload
(defun rot13-other-window ()