From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#69920: Proposed fix - Toggling MIME inline attachment previews adds superfluous newlines Date: Sat, 23 Mar 2024 12:20:16 +0200 Message-ID: <86bk75z1un.fsf@gnu.org> References: <87wmpuouay.fsf@tilde.club> <87y1a952gf.fsf@tilde.club> <86sf0hzb5c.fsf@gnu.org> <874jcxmfzh.fsf@tilde.club> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31598"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 69920@debbugs.gnu.org To: Alcor , Eric Abrahamsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Mar 23 11:37:38 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 1rnyks-00083o-Ka for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 23 Mar 2024 11:37:38 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rnykc-0007RP-PO; Sat, 23 Mar 2024 06:37:22 -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 1rnykb-0007R8-Ow for bug-gnu-emacs@gnu.org; Sat, 23 Mar 2024 06:37: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 1rnykb-0008Tp-EP for bug-gnu-emacs@gnu.org; Sat, 23 Mar 2024 06:37:21 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rnylG-0003GW-By for bug-gnu-emacs@gnu.org; Sat, 23 Mar 2024 06:38:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 23 Mar 2024 10:38: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.171119025512497 (code B ref 69920); Sat, 23 Mar 2024 10:38:02 +0000 Original-Received: (at 69920) by debbugs.gnu.org; 23 Mar 2024 10:37:35 +0000 Original-Received: from localhost ([127.0.0.1]:45111 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rnyko-0003FU-LH for submit@debbugs.gnu.org; Sat, 23 Mar 2024 06:37:35 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:57772) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rnykm-0003FE-3L for 69920@debbugs.gnu.org; Sat, 23 Mar 2024 06:37:33 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rnyU9-0005WI-UX; Sat, 23 Mar 2024 06:20:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=GEIPIsgdTa2B4NqqPIMOVeWqGZ79Hbbq1vzaOanw8Jo=; b=LYtFRzFG7BRp8NW6Gz+x a9eJvYIbjLqC2ye8/flWU2py5iumXeItT6fl37oCeTz6JgBt/Au60LhsqzsKBmFeOtMWvcqi4jFye ANWVeYeOUBjBlcoUGeNKyFNEMK0pi9WFI+qYQiBU8D+7q9GmwQgRO//SNJhD5siba7iMUdXgtz9/U +MFNZZdqQxd5SR+n9H+JBuHbpHQnB+9zSQjvCIGKQu+dFcRSNQ4o/9Nz+/pJX4VujAXtQ7zgfZp2G K3TbH70M+2t91lBlp99wJ5OPXvULRye+APFggtTcZXI+Z5bAr6i5JKMokBZd1kFig3ZZv+CWeyWbT uV5XahQ2vRpdww==; In-Reply-To: <874jcxmfzh.fsf@tilde.club> (message from Alcor on Sat, 23 Mar 2024 10:53:22 +0100) 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:281977 Archived-At: > From: Alcor > Cc: 69920@debbugs.gnu.org > Date: Sat, 23 Mar 2024 10:53:22 +0100 > > 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)) – note that 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 purpose). I prefer #2. Eric, WDYT? > 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. Yes, I think so.