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: Thu, 18 Apr 2024 12:00:21 +0300 Message-ID: <86bk67f3kq.fsf@gnu.org> References: <87wmpuouay.fsf@tilde.club> <87y1a952gf.fsf@tilde.club> <86sf0hzb5c.fsf@gnu.org> <874jcxmfzh.fsf@tilde.club> <86bk75z1un.fsf@gnu.org> <864jce50ju.fsf@gnu.org> 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="12807"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 69920@debbugs.gnu.org, alcor@tilde.club To: eric@ericabrahamsen.net Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Apr 18 11:01:15 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 1rxNdr-000354-8Y for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 18 Apr 2024 11:01:15 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rxNdY-0005qi-9K; Thu, 18 Apr 2024 05:00:56 -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 1rxNdS-0005oM-Jf for bug-gnu-emacs@gnu.org; Thu, 18 Apr 2024 05:00:50 -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 1rxNdS-0000O1-B9 for bug-gnu-emacs@gnu.org; Thu, 18 Apr 2024 05:00:50 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rxNdf-00081i-M0 for bug-gnu-emacs@gnu.org; Thu, 18 Apr 2024 05:01:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 18 Apr 2024 09:01:03 +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.171343085830805 (code B ref 69920); Thu, 18 Apr 2024 09:01:03 +0000 Original-Received: (at 69920) by debbugs.gnu.org; 18 Apr 2024 09:00:58 +0000 Original-Received: from localhost ([127.0.0.1]:51162 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rxNdW-00080O-JO for submit@debbugs.gnu.org; Thu, 18 Apr 2024 05:00:57 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41222) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rxNdR-0007z6-68 for 69920@debbugs.gnu.org; Thu, 18 Apr 2024 05:00:53 -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 1rxNd6-0000Kw-FS; Thu, 18 Apr 2024 05:00:28 -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=hZg/LdjXGEjuBj6t+ZM12uasA697sf2ngLNF23sNc9M=; b=ctVfqYRkv3V7iJVZy/z2 CNPa2+oX3OdDZm7r7b+030+bGGBHLIW+jrkjfsqeiMxdB2KnYYqbKyLB9gyVRXa+g6DGueYvf+YeO 4LYx/aF0T2ZPNtPRx+ACeSNv0LKmLczGf9IM2QVXV+iAxJRzVGDudYYbAeW0LlWCjbbWOos3vvkzN 7ews+hqCNPf3XdD8cDbCDns7DEhytFNDvcajn/XqyY6Xyi8LFt+7ABL2koFACZvM/N2PvqFv78v1v eDZDGhp1yJS+oUsGqCD11SbaBXTQlIyWn3jPwlF/lyn4ZgNwi+aJbREMWDZ3WJF8SNKb4+M9feIbw xjwFKKEOXjCx0A==; In-Reply-To: <864jce50ju.fsf@gnu.org> (message from Eli Zaretskii on Sat, 06 Apr 2024 11:59:33 +0300) 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:283533 Archived-At: Ping! Ping! Eric, please chime in. > Cc: 69920@debbugs.gnu.org, alcor@tilde.club > Date: Sat, 06 Apr 2024 11:59:33 +0300 > From: Eli Zaretskii > > Ping! Eric, can you please chime in? > > > Cc: 69920@debbugs.gnu.org > > Date: Sat, 23 Mar 2024 12:20:16 +0200 > > From: Eli Zaretskii > > > > > 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. > > > > > > > > > > > >