;; 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
(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
(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
(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
(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
;; 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)))