dandavison / delta

A syntax-highlighting pager for git, diff, grep, and blame output
https://dandavison.github.io/delta/
MIT License
24.62k stars 395 forks source link

🚀 Syntax highlight for git patches frontmatter #1863

Open OJarrisonn opened 2 months ago

OJarrisonn commented 2 months ago

Delta currently has an amazing support for git patch files (generated with git format-patch). But it would be nice if delta had some level of syntax highlight also in the patch frontmatter just like some terminal text editors do when one's writting a commit.

Fields like Subject, From, Date, etc could be colored with some special color, and also email strings like <me@mymail.com>

Example

Helix editor: the signed-off-by and other markers in the footer of a commit message are highlighted.

image

dandavison commented 2 months ago

Hi @OJarrisonn, could you post an example plain text snippet that you'd like delta to syntax highlight?

OJarrisonn commented 2 months ago

Sure thing

From git@z Thu Jan  1 00:00:00 1970
Subject: [PATCH v1 1/2] accel-config/test: Add parameter for specifying dev
 and wq
From: Rex Zhang <rex.zhang@intel.com>
Date: Wed, 25 Oct 2023 16:52:58 +0800
Message-Id: <20231025085259.2958695-1-rex.zhang@intel.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit

About the script iaa_user_test_runner.sh, previously, the only one behavior
is to enable dev and wq firstly than invoke iaa_test, then the iaa_test
will find which dev and wq are enabled automatically.
For enabling the dev and wq outside the script, the script indentify the
enabled dev and wq, then pass the dev and wq into iaa_test as a parameter.

Signed-off-by: Rex Zhang <rex.zhang@intel.com>
---
 test/iaa_user_test_runner.sh | 149 +++++++++++++++++++----------------
 1 file changed, 83 insertions(+), 66 deletions(-)

diff --git a/test/iaa_user_test_runner.sh b/test/iaa_user_test_runner.sh
index e3a6663..d85d043 100755
--- a/test/iaa_user_test_runner.sh
+++ b/test/iaa_user_test_runner.sh
@@ -6,7 +6,18 @@

 rc="$EXIT_SKIP"

-IAA=iax1
+DEV_OPT=""
+input1=$1
+if [ "$input1" == "--skip-config" ]; then
+   DEV=`ls /dev/iax/ | sed -ne 's|wq\([^.]\+\)\(.*\)|iax\1/wq\1\2|p'`
+   DEV=`echo $DEV | cut -f1 -d' '`
+   IAA=`echo $DEV | cut -f1 -d/`
+   DEV_OPT="-d $DEV"
+   echo "$DEV"
+else
+   IAA=iax1
+fi
+echo "$IAA"
 WQ0=wq1.4
 WQ1=wq1.1
 DBDF=`ls -l /sys/bus/dsa/devices/iax3 | awk -F '/' '{print $(NF - 1)}'`
@@ -149,10 +160,10 @@ test_op()
            if [ "$extra_flag" != "" ]
            then
                "$IAATEST" -w "$wq_mode_code" -l "$xfer_size" -o "$opcode" \
-                   -f "$flag" -1 "$extra_flag" -t 5000 -v

This is part of a patch from lore.kernel.org. It would be cool if delta could both render the diff part at the bottom and highlight the fields (like Date:, Message-Id:, [PATCH v1 1/2], etc) at the frontmatter (before the ---)