From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#54034: 29.0.50; Diff prettify broken for empty files Date: Wed, 29 Jun 2022 11:47:33 -0400 Message-ID: References: <87iltex7bo.fsf@gmail.com> <87v8xakm0i.fsf@gmail.com> <87bkz1jxd9.fsf@gmail.com> <87sfsbakqo.fsf@gmail.com> <87ee3v9ylm.fsf@gmail.com> <87wng1omfa.fsf@gmail.com> <87sfqpnzar.fsf@gmail.com> <87o81dnyxl.fsf@gmail.com> <87fsmpm6n6.fsf@gmail.com> <87sfnvxb1c.fsf@tcd.ie> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26525"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: 54034@debbugs.gnu.org, Matthias Meulien To: "Basil L. Contovounesios" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jun 29 17:48:22 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 1o6ZvQ-0006cd-1r for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 29 Jun 2022 17:48:20 +0200 Original-Received: from localhost ([::1]:48370 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o6ZvP-00054I-2C for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 29 Jun 2022 11:48:19 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36082) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o6Zv8-000546-IZ for bug-gnu-emacs@gnu.org; Wed, 29 Jun 2022 11:48:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:37793) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o6Zv8-0003H0-7P for bug-gnu-emacs@gnu.org; Wed, 29 Jun 2022 11:48:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1o6Zv8-00075Y-69 for bug-gnu-emacs@gnu.org; Wed, 29 Jun 2022 11:48:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 29 Jun 2022 15:48:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54034 X-GNU-PR-Package: emacs Original-Received: via spool by 54034-submit@debbugs.gnu.org id=B54034.165651766427135 (code B ref 54034); Wed, 29 Jun 2022 15:48:02 +0000 Original-Received: (at 54034) by debbugs.gnu.org; 29 Jun 2022 15:47:44 +0000 Original-Received: from localhost ([127.0.0.1]:59923 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o6Zup-00073Z-N2 for submit@debbugs.gnu.org; Wed, 29 Jun 2022 11:47:44 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:3237) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o6Zuo-00072m-FO for 54034@debbugs.gnu.org; Wed, 29 Jun 2022 11:47:42 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id B71814410F0; Wed, 29 Jun 2022 11:47:36 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 4AF0F4410EB; Wed, 29 Jun 2022 11:47:35 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1656517655; bh=SZnQua7JhmyCjrqDYON9zyp8bZZp7peXssdBi6ZUgew=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=MXfk5nVzNCua/qVAN+recvz22SA5GcsdwEBwINNB7K5p7wwKntF6kSZNt7PEBuaBa FW7pUVLKOVtWoh+QfZsKvRFMf21Jpnp/LJh3YrzRATr3soKi/PMx5N0q+hsY9Q2m4r Aj0ojCRSO8c8xIKpevW3V/FzhwLpPt6vxgGmGmqQVYlG6Aa3tajqulJw66HDJd0OmE qdVkAyv5t4OU0WhVGjb9nVT36kbniqWIDXrc2kUEPhtqM2lTd+6QFlyW/2LNIXzTM6 Mn1fHBbYb+YwvSd16WhmNiDt2HteyWGZtKyERb3HAVbgUCpcOe8AITaM4ozTCYs8hx UIQkP1L0Zdy8w== Original-Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 14B85120312; Wed, 29 Jun 2022 11:47:35 -0400 (EDT) In-Reply-To: <87sfnvxb1c.fsf@tcd.ie> (Basil L. Contovounesios's message of "Fri, 24 Jun 2022 01:36:15 +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" Xref: news.gmane.io gmane.emacs.bugs:235648 Archived-At: Basil L. Contovounesios [2022-06-24 01:36:15] wrote: > I think this gave rise to the following regression in the header when > diff-font-lock-prettify is enabled: > > 0. emacs -Q > 1. M-x diff-buffers RET RET RET > [ Header now comprises 'diff -u ...'. ] > 2. (setq diff-font-lock-prettify t) C-x C-e > 3. C-x o g > [ Header is now 'Deleted file'. ] > > It's not particularly jarring to see a header like that when diffing > non-file-visiting buffers, but more importantly the same header appears > when diffing any regular files via M-x diff. [ It'd have been better to file a new bug report for this one, FWIW. ] I installed the patch below, which seems safe, but is probably not optimal. Matthias? Stefan diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index 0fd67422d55..3f3e503a3f3 100644 --- a/lisp/vc/diff-mode.el +++ b/lisp/vc/diff-mode.el @@ -2682,7 +2682,17 @@ diff--font-lock-prettify ((and (null (match-string 4)) (match-string 5)) (concat "New " kind filemode newfile)) ((null (match-string 2)) - (concat "Deleted" kind filemode oldfile)) + ;; We used to use + ;; (concat "Deleted" kind filemode oldfile) + ;; here but that misfires for `diff-buffers' + ;; (see 24 Jun 2022 message in bug#54034). + ;; AFAIK if (match-string 2) is nil then so is + ;; (match-string 1), so "Deleted" doesn't sound right, + ;; so better just let the header in plain sight for now. + ;; FIXME: `diff-buffers' should maybe try to better + ;; mimic Git's format with "a/" and "b/" so prettification + ;; can "just work!" + nil) (t (concat "Modified" kind filemode oldfile))) 'face '(diff-file-header diff-header))