From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.bugs Subject: bug#58843: Print "decrypted" rot13 text is buffer is read-only Date: Fri, 28 Oct 2022 19:37:28 +0000 Message-ID: <87zgdf20zr.fsf@posteo.net> References: <877d0j3ix1.fsf@posteo.net> <838rkzkb99.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9967"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 58843@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Oct 28 21:38:14 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ooVBF-0002Kg-DY for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 28 Oct 2022 21:38:13 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ooVB7-0008Q5-G3; Fri, 28 Oct 2022 15:38:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ooVB4-0008LL-GL for bug-gnu-emacs@gnu.org; Fri, 28 Oct 2022 15:38:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ooVB4-0006Ix-90 for bug-gnu-emacs@gnu.org; Fri, 28 Oct 2022 15:38:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ooVB3-0002Nr-Sl for bug-gnu-emacs@gnu.org; Fri, 28 Oct 2022 15:38:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Philip Kaludercic Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 28 Oct 2022 19:38:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58843 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 58843-submit@debbugs.gnu.org id=B58843.16669858659141 (code B ref 58843); Fri, 28 Oct 2022 19:38:01 +0000 Original-Received: (at 58843) by debbugs.gnu.org; 28 Oct 2022 19:37:45 +0000 Original-Received: from localhost ([127.0.0.1]:34312 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ooVAn-0002NM-0U for submit@debbugs.gnu.org; Fri, 28 Oct 2022 15:37:45 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:44285) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ooVAj-0002N6-SC for 58843@debbugs.gnu.org; Fri, 28 Oct 2022 15:37:43 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id B1C51240105 for <58843@debbugs.gnu.org>; Fri, 28 Oct 2022 21:37:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1666985855; bh=wSAuGXhyVge76ImZPw9xYRvGqIWkvXm0Q3GOqrYywE0=; h=From:To:Cc:Subject:Autocrypt:Date:From; b=YYFRJRu+NltH3M+X6eVW0XOC0DgENUYq+5HCWIwiI4OZQtzvCdTRY223y64D77MA4 g6E2r6t6EONTnDjzENVza8CwMgBs3EYwTa7nsZ/tIAgBitQnJ4x3blC70+wfmQgFsF KSW3znBEKMZMO6DMSuaj67HXVZ+NKqph+6YO0JcFWvAp1hktCrQg5NNzewAf0eeyFA OV3795YGd860xz1DAUisTatoze5KCAyJXZD297TrN8JKXFRboIJtISabf1t4cid7rO u0Rj2Kv/G0CxOfeI1BbZVqVsK3RHXN/2QRMYxEfwMddKhd51TAf8sRRFl3Y5H77hbC G+9M6sMqhzapQ== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4MzXrG6MRhz9rxM; Fri, 28 Oct 2022 21:37:33 +0200 (CEST) In-Reply-To: <838rkzkb99.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 28 Oct 2022 22:18:26 +0300") Autocrypt: addr=philipk@posteo.net; prefer-encrypt=nopreference; keydata= mDMEYHHqUhYJKwYBBAHaRw8BAQdAp3GdmYJ6tm5McweY6dEvIYIiry+Oz9rU4MH6NHWK0Ee0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiQBBMWCAA4FiEEDM2H44ZoPt9Ms0eHtVrAHPRh1FwFAmBx6lICGwMFCwkIBwIGFQoJ CAsCBBYCAwECHgECF4AACgkQtVrAHPRh1FyTkgEAjlbGPxFchvMbxzAES3r8QLuZgCxeAXunM9gh io0ePtUBALVhh9G6wIoZhl0gUCbQpoN/UJHI08Gm1qDob5zDxnIHuDgEYHHqUhIKKwYBBAGXVQEF AQEHQNcRB+MUimTMqoxxMMUERpOR+Q4b1KgncDZkhrO2ql1tAwEIB4h4BBgWCAAgFiEEDM2H44Zo Pt9Ms0eHtVrAHPRh1FwFAmBx6lICGwwACgkQtVrAHPRh1Fw1JwD/Qo7kvtib8jy7puyWrSv0MeTS g8qIxgoRWJE/KKdkCLEA/jb9b9/g8nnX+UcwHf/4VfKsjExlnND3FrBviXUW6NcB X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: "bug-gnu-emacs" Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:246451 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> From: Philip Kaludercic >> Date: Fri, 28 Oct 2022 18:24:58 +0000 >> >> Tags: patch >> >> >> When someone sends you rot13'ed text but the buffer is read-only, it >> seems the next best thing one can do is to print the decrypted text. I >> don't think it makes sense in general for `translate-region' to do the >> same, so I just modified the code in rot13.el. > > Thanks, but I see no patch in your message. I see a complete rot13.el > file. Oops, I must have selected the wrong file. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-lisp-rot13.el-rot13-region-Add-fallback-if-buffer-is.patch >From f97a27dcd06bafcb3ec6beaaf0f4d3b044f9fa64 Mon Sep 17 00:00:00 2001 From: Philip Kaludercic Date: Fri, 28 Oct 2022 19:44:47 +0200 Subject: [PATCH] * lisp/rot13.el (rot13-region): Add fallback if buffer is read-only --- lisp/rot13.el | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lisp/rot13.el b/lisp/rot13.el index c063725de8..5d1c46e483 100644 --- a/lisp/rot13.el +++ b/lisp/rot13.el @@ -85,9 +85,16 @@ rot13-string ;;;###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 () -- 2.37.3 --=-=-=--