From: Matthias Meulien <orontee@gmail.com>
To: 51016@debbugs.gnu.org
Subject: bug#51016: 28.0.50; 'diff-font-lock-prettify' breaks display of outline headers
Date: Wed, 13 Oct 2021 22:30:04 +0200 [thread overview]
Message-ID: <87wnmgk6r7.fsf@gmail.com> (raw)
In-Reply-To: <87bl44qz5o.fsf@gmail.com> (Matthias Meulien's message of "Mon, 04 Oct 2021 23:05:07 +0200")
[-- Attachment #1: Type: text/plain, Size: 145 bytes --]
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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-outline-headers-of-diff-buffers-when-using-Git-b.patch --]
[-- Type: text/x-diff, Size: 4104 bytes --]
From 67ef81b503b2529e28fcdca35912bf5c9ce54d8e Mon Sep 17 00:00:00 2001
From: Matthias Meulien <orontee@gmail.com>
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
next prev parent reply other threads:[~2021-10-13 20:30 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-04 21:05 bug#51016: 28.0.50; 'diff-font-lock-prettify' breaks display of outline headers Matthias Meulien
2021-10-09 0:26 ` bug#51016: Status: " Matthias Meulien
2021-10-09 0:37 ` Matthias Meulien
2021-10-13 20:30 ` Matthias Meulien [this message]
2021-11-05 2:51 ` bug#51016: " Lars Ingebrigtsen
2021-11-06 16:40 ` Juri Linkov
2021-11-06 18:30 ` Lars Ingebrigtsen
2021-11-08 22:38 ` Matthias Meulien
2021-11-09 3:47 ` Lars Ingebrigtsen
2021-11-09 8:19 ` Juri Linkov
2021-11-18 18:06 ` Juri Linkov
2021-11-19 7:22 ` Lars Ingebrigtsen
2021-11-19 8:31 ` Juri Linkov
2021-11-20 8:37 ` Lars Ingebrigtsen
2021-11-20 19:17 ` Juri Linkov
2021-11-21 17:02 ` Lars Ingebrigtsen
2021-11-21 17:26 ` Matthias Meulien
2021-11-21 17:41 ` Juri Linkov
2021-11-21 17:54 ` Matthias Meulien
2021-11-22 22:11 ` Matthias Meulien
2021-11-22 23:03 ` Matthias Meulien
2021-11-24 6:54 ` Lars Ingebrigtsen
2021-11-24 18:48 ` Juri Linkov
2021-12-15 17:08 ` Juri Linkov
2021-12-16 5:50 ` Lars Ingebrigtsen
2021-12-16 17:22 ` Juri Linkov
2021-12-16 17:48 ` Eli Zaretskii
2021-12-16 19:04 ` Juri Linkov
2021-12-16 20:06 ` Eli Zaretskii
2021-12-16 21:02 ` Kévin Le Gouguec
2021-12-17 6:36 ` Eli Zaretskii
2021-12-17 7:07 ` Kévin Le Gouguec
2021-12-17 7:55 ` Eli Zaretskii
2021-12-17 21:27 ` Kévin Le Gouguec
2021-12-18 6:23 ` Eli Zaretskii
2021-12-18 9:18 ` Kévin Le Gouguec
2021-12-18 17:05 ` Juri Linkov
2021-12-18 17:52 ` Eli Zaretskii
2021-12-18 19:43 ` Kévin Le Gouguec
2021-12-18 20:03 ` Eli Zaretskii
2021-12-18 23:30 ` Kévin Le Gouguec
2021-12-19 11:00 ` Lars Ingebrigtsen
2021-12-19 11:27 ` Eli Zaretskii
2021-12-17 4:25 ` Richard Stallman
2021-11-21 17:49 ` Juri Linkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87wnmgk6r7.fsf@gmail.com \
--to=orontee@gmail.com \
--cc=51016@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).