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#51016: 28.0.50; 'diff-font-lock-prettify' breaks display of outline headers Date: Wed, 13 Oct 2021 22:30:04 +0200 Message-ID: <87wnmgk6r7.fsf@gmail.com> References: <87bl44qz5o.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="7303"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) To: 51016@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Oct 13 22:31:48 2021 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 1makuh-0001ho-Ae for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 13 Oct 2021 22:31:47 +0200 Original-Received: from localhost ([::1]:45900 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1makug-0002J2-8B for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 13 Oct 2021 16:31:46 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59236) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1makty-0002Hc-L3 for bug-gnu-emacs@gnu.org; Wed, 13 Oct 2021 16:31:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:50374) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1makty-00057z-Bz for bug-gnu-emacs@gnu.org; Wed, 13 Oct 2021 16:31:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1makty-0006pL-84 for bug-gnu-emacs@gnu.org; Wed, 13 Oct 2021 16:31:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Matthias Meulien Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 13 Oct 2021 20:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51016 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 51016-submit@debbugs.gnu.org id=B51016.163415701426184 (code B ref 51016); Wed, 13 Oct 2021 20:31:02 +0000 Original-Received: (at 51016) by debbugs.gnu.org; 13 Oct 2021 20:30:14 +0000 Original-Received: from localhost ([127.0.0.1]:33686 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1maktB-0006oG-Pj for submit@debbugs.gnu.org; Wed, 13 Oct 2021 16:30:14 -0400 Original-Received: from mail-wr1-f50.google.com ([209.85.221.50]:44907) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1makt9-0006my-Ea for 51016@debbugs.gnu.org; Wed, 13 Oct 2021 16:30:12 -0400 Original-Received: by mail-wr1-f50.google.com with SMTP id e3so12184861wrc.11 for <51016@debbugs.gnu.org>; Wed, 13 Oct 2021 13:30:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:references:date:in-reply-to:message-id:user-agent :mime-version; bh=o2qYVXvxAA4MJXDymD3lQdFHPu5tkwZhJiWH+l5qmBk=; b=fRiT5Wy02+qpmt25akuGnIAiji3eP8QnRqdTnRAUFe1pRMiuJ1SfGE7eZso8xJXlQQ CTJCp6Zxd5OZuzGm7XkZr14MTMShdcjksqML46sMxfpmxkznEzCK/Rz6aYY3ORh2z6Sb 8slr1kL9+zXDH1AzFjAGP6kjTbujfDnC9v+sEBGKDaEkFOEau9cYYBDahw5rOzoOekV/ buh5XKqBlwGIngkYJ2GMnoviNpnkmyjmyUniP++dOJGVr3eS/AExbTrDCK6I3YpZQLTB SGgMCEEL4grKu+bdvcB2/paWg21/dMAVREO4UJiw559oaLRBy6YHSQ3ZzQSIJdrc0h5K DrqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=o2qYVXvxAA4MJXDymD3lQdFHPu5tkwZhJiWH+l5qmBk=; b=cDEz4Ei8tt3eb3mMdwVZhbF+JNWwoaulVKsMijWa92wqhSRJbQdIxusoKHeQxNVC64 xHDm9qOLyXN9roE+vA9kQI2AQJ2p7ZeB6g2F+L50VX8B1rH/4S5rcjiWj5GkoJXmM5MR /dWCp/VgKa0iq1Eoh5myHdfYJxe0zW4eeoE3DEv853MRKSX2emDo9irrwL9r1wwHa15k 5paCyj8EfvlpkiZA4gXCEdXXbimblyyMU2VQe1FpfYmRy9fKEAi7ktLbT1uRSBAc1ErG kMErYQkasXFdc/qhMG4t0XxouMLYDn7G6ifz2m0OwRS3/0zMJ7LwgRjTuPhSv4AELeZT 3tIA== X-Gm-Message-State: AOAM5302PNunuNf3FjaetNCW/FrnrYVgtU8oVhDCiSb2EBu5W4DhjDDo NPolCLOWqgWt9YaobFVZSmwxH1ahO8c= X-Google-Smtp-Source: ABdhPJxZ4E1tJK6puLkoMxtkkRxFsWAV/OkVy3k1Hiz/mfK0/p5YDbNm44Vc6k7ULBN0DVAwKLjH2A== X-Received: by 2002:a1c:9dcb:: with SMTP id g194mr15490245wme.174.1634157005393; Wed, 13 Oct 2021 13:30:05 -0700 (PDT) Original-Received: from carbon.localdomain ([2a01:e0a:245:c850:98f5:429a:aa8e:95bb]) by smtp.gmail.com with ESMTPSA id o12sm514925wrv.78.2021.10.13.13.30.04 for <51016@debbugs.gnu.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Oct 2021 13:30:04 -0700 (PDT) In-Reply-To: <87bl44qz5o.fsf@gmail.com> (Matthias Meulien's message of "Mon, 04 Oct 2021 23:05:07 +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:217175 Archived-At: --=-=-= Content-Type: text/plain I updated the patch after a week using it. Outlines headers are now updated for diff comming from Git even when diff-font-lock-prettify is nil. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Fix-outline-headers-of-diff-buffers-when-using-Git-b.patch >From 67ef81b503b2529e28fcdca35912bf5c9ce54d8e Mon Sep 17 00:00:00 2001 From: Matthias Meulien Date: Sat, 9 Oct 2021 00:36:11 +0200 Subject: [PATCH] Fix outline headers of diff buffers when using Git (bug#51016) * lisp/vc/diff-mode.el (diff-outline-level): Make hunk headers be at level 2 (diff-mode): Use prettified line as outline header * lisp/vc/vc.el (vc-diff-internal): Fix diff mode being set before content inserted --- lisp/vc/diff-mode.el | 28 ++++++++++++++++++++-------- lisp/vc/vc.el | 5 +++-- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index 057ffcd06e..f0a6cb7b15 100644 --- a/lisp/vc/diff-mode.el +++ b/lisp/vc/diff-mode.el @@ -894,6 +894,10 @@ diff-split-hunk ;; Fix the original hunk-header. (diff-fixup-modifs start pos)))) +(defun diff-outline-level () + (if (string-match-p diff-hunk-header-re (match-string 0)) + 2 1)) + ;;;; ;;;; jump to other buffers @@ -1494,7 +1498,6 @@ diff-mode (setq-local font-lock-defaults diff-font-lock-defaults) (add-hook 'font-lock-mode-hook #'diff--font-lock-cleanup nil 'local) - (setq-local outline-regexp diff-outline-regexp) (setq-local imenu-generic-expression diff-imenu-generic-expression) ;; These are not perfect. They would be better done separately for @@ -1543,7 +1546,17 @@ diff-mode (setq-local diff-buffer-type (if (re-search-forward "^diff --git" nil t) 'git - nil)))) + nil))) + (when (eq diff-buffer-type 'git) + (setq diff-outline-regexp + (concat + "\\(" + "^diff --git.*\n" + "\\|" + diff-hunk-header-re + "\\)")) + (setq-local outline-level #'diff-outline-level)) + (setq-local outline-regexp diff-outline-regexp)) ;;;###autoload (define-minor-mode diff-minor-mode @@ -2603,13 +2616,12 @@ diff--font-lock-prettify (or (match-beginning 2) (match-beginning 1)) 'display (propertize (cond - ((null (match-beginning 1)) "new file ") - ((null (match-beginning 2)) "deleted ") - (t "modified ")) + ((null (match-beginning 1)) (concat "new file " (match-string 2))) + ((null (match-beginning 2)) (concat "deleted " (match-string 1))) + (t (concat "modified " (match-string 1)))) 'face '(diff-file-header diff-header))) - (unless (match-beginning 2) - (put-text-property (match-end 1) (1- (match-end 0)) - 'display ""))))) + (put-text-property (match-end 1) (1- (match-end 0)) + 'display "")))) nil) ;;; Syntax highlighting from font-lock diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 5b259fcdb3..c82110274b 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -1793,7 +1793,6 @@ vc-diff-internal (setq files (nreverse filtered)))) (vc-call-backend (car vc-fileset) 'diff files rev1 rev2 buffer async) (set-buffer buffer) - (diff-mode) (setq-local diff-vc-backend (car vc-fileset)) (setq-local diff-vc-revisions (list rev1 rev2)) (setq-local revert-buffer-function @@ -1815,7 +1814,9 @@ vc-diff-internal ;; after `pop-to-buffer'; the former assumes the diff buffer is ;; shown in some window. (let ((buf (current-buffer))) - (vc-run-delayed (vc-diff-finish buf (when verbose messages)))) + (vc-run-delayed (progn + (vc-diff-finish buf (when verbose messages)) + (diff-mode)))) ;; In the async case, we return t even if there are no differences ;; because we don't know that yet. t))) -- 2.30.2 --=-=-=--