Commit 645c6c1f authored by Jonas Bernoulli's avatar Jonas Bernoulli

sections: Define magit-{file,hunk}-section classes

parent 798a4cd9
......@@ -138,7 +138,7 @@ so causes the change to be applied to the index as well."
(when (string-match "^diff --cc" (magit-section-value section))
(user-error "Cannot un-/stage resolution hunks. Stage the whole file"))
(magit-apply-patch section args
(concat (magit-section-diff-header section)
(concat (oref section header)
(mapconcat 'magit-apply--section-content
sections "")))))
......@@ -1783,8 +1783,8 @@ section or a child thereof."
'face 'magit-diff-file-heading))
(unless (equal orig file)
(setf (magit-section-source section) orig))
(setf (magit-section-diff-header section) header)
(oset section source orig))
(oset section header header)
(when modes
(magit-insert-section (hunk)
(insert modes)))
......@@ -2516,10 +2516,10 @@ are highlighted."
(if section
(unless (magit-section-hidden section)
(pcase (list magit-diff-refine-hunk
(magit-section-refined section)
(oref section refined)
(eq section (magit-current-section)))
((or `(all nil ,_) `(t nil t))
(setf (magit-section-refined section) t)
(oset section refined t)
(goto-char (magit-section-start section))
;; `diff-refine-hunk' does not handle combined diffs.
......@@ -2528,7 +2528,7 @@ are highlighted."
(let ((write-region-inhibit-fsync t))
((or `(nil t ,_) `(t t nil))
(setf (magit-section-refined section) nil)
(oset section refined nil)
(remove-overlays (magit-section-start section)
(magit-section-end section)
'diff-mode 'fine))))
......@@ -2665,7 +2665,7 @@ for more details)."
(when (eq (magit-section-type section) 'hunk)
(setq section (magit-section-parent section)))
(when (eq (magit-section-type section) 'file)
(magit-section-diff-header section)))
(oref section header)))
(defun magit-diff-hunk-region-header (section)
(let ((patch (magit-diff-hunk-region-patch section)))
......@@ -151,10 +151,14 @@ hardcoded section specific default (see `magit-insert-section')."
(washer :initform nil :accessor magit-section-washer)
(process :initform nil :accessor magit-section-process)
(parent :initform nil :accessor magit-section-parent :initarg :parent)
(children :initform nil :accessor magit-section-children)
(source :initform nil :accessor magit-section-source)
(diff-header :initform nil :accessor magit-section-diff-header)
(refined :initform nil :accessor magit-section-refined)))
(children :initform nil :accessor magit-section-children)))
(defclass magit-file-section (magit-section)
((source :initform nil :accessor magit-section-source)
(header :initform nil :accessor magit-section-header)))
(defclass magit-hunk-section (magit-section)
((refined :initform nil :accessor magit-section-refined)))
(defvar-local magit-root-section nil
"The root section in the current buffer.
......@@ -706,7 +710,9 @@ anything this time around.
(cadr type)
(,s (funcall (pcase ,tp
(_ 'magit-section))
(`file 'magit-file-section)
(`hunk 'magit-hunk-section)
(_ 'magit-section))
:type ,tp
:value ,(nth 1 (car args))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment