From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Matthias Meulien Newsgroups: gmane.emacs.bugs Subject: bug#54034: 29.0.50; Diff prettify broken for empty files Date: Thu, 07 Apr 2022 09:19:02 +0200 Message-ID: <87o81dnyxl.fsf@gmail.com> 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> 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="2500"; 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 To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Apr 07 09:20:28 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 1ncMRQ-0000VH-Bs for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 07 Apr 2022 09:20:28 +0200 Original-Received: from localhost ([::1]:50322 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ncMRO-00037K-BO for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 07 Apr 2022 03:20:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49862) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ncMR1-000379-Gm for bug-gnu-emacs@gnu.org; Thu, 07 Apr 2022 03:20:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:37462) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ncMR0-0007k1-3o for bug-gnu-emacs@gnu.org; Thu, 07 Apr 2022 03:20:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ncMQz-0004ab-VX for bug-gnu-emacs@gnu.org; Thu, 07 Apr 2022 03:20:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Matthias Meulien Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 07 Apr 2022 07:20:01 +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.164931595317580 (code B ref 54034); Thu, 07 Apr 2022 07:20:01 +0000 Original-Received: (at 54034) by debbugs.gnu.org; 7 Apr 2022 07:19:13 +0000 Original-Received: from localhost ([127.0.0.1]:59592 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ncMQD-0004ZS-HX for submit@debbugs.gnu.org; Thu, 07 Apr 2022 03:19:13 -0400 Original-Received: from mail-wr1-f54.google.com ([209.85.221.54]:41479) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ncMQB-0004ZE-Q8 for 54034@debbugs.gnu.org; Thu, 07 Apr 2022 03:19:13 -0400 Original-Received: by mail-wr1-f54.google.com with SMTP id k23so6437703wrd.8 for <54034@debbugs.gnu.org>; Thu, 07 Apr 2022 00:19:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=cRCN8sKF+W7ddbtgJO24jrtFvtkvfuLZ9a8F0Vzxsow=; b=IM7ZlO16aC4paCynfHXUy2k9TJgdBuLWya4pu1lXwWnzJmvTlyDkdva/zT2Gp37w9K /Viq/ubtmQp2vZr5mJKCMRdaas7Wj5ZO+uX6HPt5CxpU6k+wqhX/u4b87lO7MQoUiPIq ec8Q6c+AVfwWc0OrGKU4HkM/NjppX24AuHw684pjt920KWTmN9UnPWvDqtIE6Bm6Hjwy YxfKAWj+/TSLLsCxyyepdjajAeeypzNjI2HKNMbYKazrDAG6oj3//TtTqIEEkA42vUlm tEFQIc9H7J70EB6lrQWx0KOuk6KAGVRwKl9mfFSe3WNqEXhV1EDOvtyqYcOaUHwgSwCL 2yJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=cRCN8sKF+W7ddbtgJO24jrtFvtkvfuLZ9a8F0Vzxsow=; b=tX8GvdPV5ZM504pPqF3Pf5VWQ0qoTSmWTrsJXt/6pYQUfjSFG5WXwUflZqlwQugdt6 a+uKI2wl9lZLpeFYEWkswvWHMVt0/iRliYGBME3yoypjPyWaFuTF32UtxsGPkVqG6kWR 8T9H4qYXKhcnvIv/90YfjCL/2pnJeW8j5/ZE/MIuG+8RS0+HYjUqzDdiFx+AX0ediDbx rktv5JYw3xIVodALNB6NvO6JAIBESF41QkWLEjsb0tfa+S+xvzWJIoHebuFG4TJBdFCq I/PzI4E7rn5XcMdfKkQ7N3XFJZjxqxLDw2XqKea5KFkczUy4rDN5MfVEv7N1YKMDRfN4 mHuw== X-Gm-Message-State: AOAM533ny5lPrx2cR+26VkmKbwrHgHwf3kHG5WGnw6WEhP+Ojg73IR/x PSPz6Vgj5fE9uFAbPVsMXIWyDRhTbbY= X-Google-Smtp-Source: ABdhPJwfHco6H7xXRocyNJ3VN2NzszSqbmd0ugS1wtf0hJ9dMLVdegdXy3/QwAQ2Mo1iifPllbgeZQ== X-Received: by 2002:a5d:6487:0:b0:205:7c2b:b6ba with SMTP id o7-20020a5d6487000000b002057c2bb6bamr9185248wri.283.1649315946043; Thu, 07 Apr 2022 00:19:06 -0700 (PDT) Original-Received: from carbon.localdomain ([2a01:e0a:245:c850:98f5:429a:aa8e:95bb]) by smtp.gmail.com with ESMTPSA id p8-20020a5d59a8000000b00204178688d3sm18766058wrr.100.2022.04.07.00.19.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 00:19:05 -0700 (PDT) In-Reply-To: <87sfqpnzar.fsf@gmail.com> (Matthias Meulien's message of "Thu, 07 Apr 2022 09:11:08 +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" Xref: news.gmane.io gmane.emacs.bugs:229512 Archived-At: --=-=-= Content-Type: text/plain Matthias Meulien writes: > Here is an updated patch with a small display improvement: File name > doesn't appear in the middle of the line anymore. Arfff... Forgot that I had a work in progress commit on the head of my branch... Here is a complete patch. Sorry for the noise. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Display-file-mode-information-when-diff-font-lock-pr.patch >From fc7a87d739877368227ab5c6206e771e0044b45e Mon Sep 17 00:00:00 2001 From: Matthias Meulien Date: Thu, 7 Apr 2022 00:11:55 +0200 Subject: [PATCH] Display file mode information when diff font lock prettify enabled * lisp/vc/diff-mode.el (diff--font-lock-prettify): Make regexp capture file mode information. --- lisp/vc/diff-mode.el | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index 511cc89778..c6409d1677 100644 --- a/lisp/vc/diff-mode.el +++ b/lisp/vc/diff-mode.el @@ -2634,42 +2634,55 @@ diff--font-lock-prettify (binary (concat "Binary files " file4 " and " file5 " \\(?7:differ\\)\n")) - (horb (concat "\\(?:" header "\\|" binary "\\)"))) + (horb (concat "\\(?:" header "\\|" binary "\\)?"))) (concat "diff.*?\\(?: a/\\(.*?\\) b/\\(.*\\)\\)?\n" - "\\(?:\\(?:old\\|new\\) mode .*\n\\)*" "\\(?:" ;; For new/deleted files, there might be no ;; header (and no hunk) if the file is/was empty. - "\\(?3:new\\(?6:\\)\\|deleted\\) file.*\n" - index "\\(?:" horb "\\)?" - ;; Normal case. - "\\|" index horb "\\)"))))) + "\\(?3:new\\(?6:\\)\\|deleted\\) file mode \\(?10:[0-9]\\{6\\}\\)\n" + index horb + ;; Normal case. There might be no header + ;; (and no hunk) if only the file mode + ;; changed. + "\\|" + "\\(?:old mode \\(?8:[0-9]\\{6\\}\\)\n\\)?" + "\\(?:new mode \\(?9:[0-9]\\{6\\}\\)\n\\)?" + index horb "\\)"))))) ;; The file names can be extracted either from the `diff' line ;; or from the two header lines. Prefer the header line info if ;; available since the `diff' line is ambiguous in case the ;; file names include " b/" or " a/". ;; FIXME: This prettification throws away all the information - ;; about file modes (and the index hashes). + ;; about the index hashes. (let ((oldfile (or (match-string 4) (match-string 1))) (newfile (or (match-string 5) (match-string 2))) (kind (if (match-beginning 7) " BINARY" - (unless (or (match-beginning 4) (match-beginning 5)) - " empty")))) + (unless (or (match-beginning 4) + (match-beginning 5) + (not (match-beginning 3))) + " empty"))) + (filemode + (cond + ((match-beginning 10) + (concat " file with mode " (match-string 10) " ")) + ((and (match-beginning 8) (match-beginning 9)) + (concat " file (mode changed from " + (match-string 8) " to " (match-string 9) ") ")) + (t " file ")))) (add-text-properties (match-beginning 0) (1- (match-end 0)) (list 'display (propertize (cond ((match-beginning 3) - (concat (capitalize (match-string 3)) kind " file" - " " + (concat (capitalize (match-string 3)) kind filemode (if (match-beginning 6) newfile oldfile))) - ((null (match-string 4)) - (concat "New" kind " file " newfile)) + ((and (null (match-string 4)) (match-string 5)) + (concat "New " kind filemode newfile)) ((null (match-string 2)) - (concat "Deleted" kind " file " oldfile)) + (concat "Deleted" kind filemode oldfile)) (t - (concat "Modified" kind " file " oldfile))) + (concat "Modified" kind filemode oldfile))) 'face '(diff-file-header diff-header)) 'font-lock-multiline t)))))) nil) -- 2.30.2 --=-=-=--