Fix 'diff-font-lock-prettify' breaking display of outline headers
* lisp/vc/diff-mode.el (diff-outline-level): Make hunk headers be at level 2. (diff-mode): Use prettified line as outline header. (diff--outline-level): New function (bug#51016). * lisp/vc/vc.el (vc-diff-internal): Fix diff mode being set before content inserted (bug#51016).
This commit is contained in:
parent
48af19c1f0
commit
f0768d3145
2 changed files with 20 additions and 10 deletions
|
|
@ -893,6 +893,9 @@ data such as \"Index: ...\" and such."
|
|||
;; 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
|
||||
|
|
@ -1493,7 +1496,6 @@ a diff with \\[diff-reverse-direction].
|
|||
|
||||
(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
|
||||
|
|
@ -1542,7 +1544,12 @@ a diff with \\[diff-reverse-direction].
|
|||
(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
|
||||
|
|
@ -2602,13 +2609,15 @@ fixed, visit it in a buffer."
|
|||
(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
|
||||
|
|
|
|||
|
|
@ -1793,7 +1793,6 @@ Return t if the buffer had changes, nil otherwise."
|
|||
(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 @@ Return t if the buffer had changes, nil otherwise."
|
|||
;; 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)))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue