From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alcor via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#69920: Proposed fix - Toggling MIME inline attachment previews adds superfluous newlines Date: Sat, 23 Mar 2024 10:53:22 +0100 Message-ID: <874jcxmfzh.fsf@tilde.club> References: <87wmpuouay.fsf@tilde.club> <87y1a952gf.fsf@tilde.club> <86sf0hzb5c.fsf@gnu.org> Reply-To: Alcor Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33098"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 69920@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Mar 23 10:56:03 2024 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 1rny6c-0008Kt-QR for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 23 Mar 2024 10:56:02 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rny5z-0008Mm-6C; Sat, 23 Mar 2024 05:55:23 -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 1rny5x-0008Lx-Hh for bug-gnu-emacs@gnu.org; Sat, 23 Mar 2024 05:55:21 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rny5x-00014K-99 for bug-gnu-emacs@gnu.org; Sat, 23 Mar 2024 05:55:21 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rny6c-0001DC-2h for bug-gnu-emacs@gnu.org; Sat, 23 Mar 2024 05:56:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alcor Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 23 Mar 2024 09:56:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69920 X-GNU-PR-Package: emacs Original-Received: via spool by 69920-submit@debbugs.gnu.org id=B69920.17111877254557 (code B ref 69920); Sat, 23 Mar 2024 09:56:02 +0000 Original-Received: (at 69920) by debbugs.gnu.org; 23 Mar 2024 09:55:25 +0000 Original-Received: from localhost ([127.0.0.1]:42183 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rny61-0001BL-2s for submit@debbugs.gnu.org; Sat, 23 Mar 2024 05:55:25 -0400 Original-Received: from tilde.club ([142.44.150.184]:43224 ident=postfix) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rny5P-00019W-Lg for 69920@debbugs.gnu.org; Sat, 23 Mar 2024 05:54:48 -0400 Original-Received: from topazii.tilde.club (unknown [IPv6:2001:9e8:7d5:6500:2748:b86f:523a:558c]) by tilde.club (Postfix) with ESMTPSA id DB034221B617F; Sat, 23 Mar 2024 09:53:34 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 tilde.club DB034221B617F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tilde.club; s=mail; t=1711187615; bh=Wp1Kscnkemra0HHK4qchg1zEnbYxvsc7ld592YkFRDQ=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=ta5IwnWKLasHWXFrekHpV6Ybgd5AZgFNMZ3Q8kabtFEZpfpCAhY2HtDGJ7l3Uh4tO fK6sr3ohp8FSzZZpBoxsli94CgnRQbKC04cw5AnAdzwGyukg/mBsM5rlOpYGeJuFQI l7Rh2n24O5uYIMMOtg/ZJdox7JMC8icuGtkLnVXQ= In-Reply-To: <86sf0hzb5c.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 23 Mar 2024 08:59:27 +0200") 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: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:281976 Archived-At: Eli Zaretskii writes: > Are you saying that the problem is with the function that > "un-displays" the inline image, in that it fails to remove the > inserted newline? (AFAIU, the code before the above commit also had > the same issue.) That wasn't clear from the description of the > problem, and the Subject is ambiguous wrt what newlines are deemed > "superfluous". So please clarify what is the problem you are flagging > here. The problem is that the undisplayer does not correctly undo what the displayer does. The undisplayer (as it is right now) just removes the image. That can be confirmed by stepping through the code with edebug or by inspecting the "b" variable. I think we can agree that (delete-region b (1+ b)) will always delete _exactly one_ character, and in that case that would be the propertized "x" with the image. That would leave a dangling newline. There are two ways to solve this: 1. Do not add the extra newline (this is what the patch does). 2. Remove the extra newline via (delete-region b (+ b 2)) =E2=80=93 note th= at I have not tried this, but it would make sense to me. I happen to prefer option #1 as the extra newline does not seem to have any meaningful function. But this is just my own preference (Emacs/gnus maintainers may wish to retain the extra newline if it serves a valid purpo= se). If it helps clarify things, I'm okay with renaming the bug report to something like "MIME inline image preview undisplayer does not clean up displayed image correctly" or something along these lines. When I filed the report, I wasn't sure about the cause so I described the user-facing issue instead of the actual technical problem. Cheers, -A. PS: I'm not sure the original code from before 14ff920dc885636a763d6ab7f256cc9981c24781 was correct either. It used to insert "x\n\n" (3 characters) on display (x being the propertized image) and removed via (delete-region b (+ b 2)) exactly 2 characters. The new code after that revision inserted "x\n" (2 characters, x being the propertized image) and removed via (delete-region b (1+ b)) exactly 1 character. So it might be possible that this off-by-one error in `mm-inline-image' has always existed.