Commit ddce6ce4 authored by Jonas Bernoulli's avatar Jonas Bernoulli

sections: Use oref instead of dedicated slot accessors

parent 645c6c1f
...@@ -113,10 +113,10 @@ so causes the change to be applied to the index as well." ...@@ -113,10 +113,10 @@ so causes the change to be applied to the index as well."
(`(,_ files) (magit-apply-diffs it args))))) (`(,_ files) (magit-apply-diffs it args)))))
(defun magit-apply--section-content (section) (defun magit-apply--section-content (section)
(buffer-substring-no-properties (if (eq (magit-section-type section) 'hunk) (buffer-substring-no-properties (if (eq (oref section type) 'hunk)
(magit-section-start section) (oref section start)
(magit-section-content section)) (oref section content))
(magit-section-end section))) (oref section end)))
(defun magit-apply-diffs (sections &rest args) (defun magit-apply-diffs (sections &rest args)
(setq sections (magit-apply--get-diffs sections)) (setq sections (magit-apply--get-diffs sections))
...@@ -134,8 +134,8 @@ so causes the change to be applied to the index as well." ...@@ -134,8 +134,8 @@ so causes the change to be applied to the index as well."
(magit-apply--section-content section)))) (magit-apply--section-content section))))
(defun magit-apply-hunks (sections &rest args) (defun magit-apply-hunks (sections &rest args)
(let ((section (magit-section-parent (car sections)))) (let ((section (oref (car sections) parent)))
(when (string-match "^diff --cc" (magit-section-value section)) (when (string-match "^diff --cc" (oref section value))
(user-error "Cannot un-/stage resolution hunks. Stage the whole file")) (user-error "Cannot un-/stage resolution hunks. Stage the whole file"))
(magit-apply-patch section args (magit-apply-patch section args
(concat (oref section header) (concat (oref section header)
...@@ -145,7 +145,7 @@ so causes the change to be applied to the index as well." ...@@ -145,7 +145,7 @@ so causes the change to be applied to the index as well."
(defun magit-apply-hunk (section &rest args) (defun magit-apply-hunk (section &rest args)
(when (string-match "^diff --cc" (magit-section-parent-value section)) (when (string-match "^diff --cc" (magit-section-parent-value section))
(user-error "Cannot un-/stage resolution hunks. Stage the whole file")) (user-error "Cannot un-/stage resolution hunks. Stage the whole file"))
(magit-apply-patch (magit-section-parent section) args (magit-apply-patch (oref section parent) args
(concat (magit-diff-file-header section) (concat (magit-diff-file-header section)
(magit-apply--section-content section)))) (magit-apply--section-content section))))
...@@ -154,14 +154,14 @@ so causes the change to be applied to the index as well." ...@@ -154,14 +154,14 @@ so causes the change to be applied to the index as well."
(user-error "Not enough context to apply region. Increase the context")) (user-error "Not enough context to apply region. Increase the context"))
(when (string-match "^diff --cc" (magit-section-parent-value section)) (when (string-match "^diff --cc" (magit-section-parent-value section))
(user-error "Cannot un-/stage resolution hunks. Stage the whole file")) (user-error "Cannot un-/stage resolution hunks. Stage the whole file"))
(magit-apply-patch (magit-section-parent section) args (magit-apply-patch (oref section parent) args
(concat (magit-diff-file-header section) (concat (magit-diff-file-header section)
(magit-diff-hunk-region-patch section args)))) (magit-diff-hunk-region-patch section args))))
(defun magit-apply-patch (section:s args patch) (defun magit-apply-patch (section:s args patch)
(let* ((files (if (atom section:s) (let* ((files (if (atom section:s)
(list (magit-section-value section:s)) (list (oref section:s value))
(mapcar 'magit-section-value section:s))) (--map (oref it value) section:s)))
(command (symbol-name this-command)) (command (symbol-name this-command))
(command (if (and command (string-match "^magit-\\([^-]+\\)" command)) (command (if (and command (string-match "^magit-\\([^-]+\\)" command))
(match-string 1 command) (match-string 1 command)
...@@ -182,18 +182,18 @@ so causes the change to be applied to the index as well." ...@@ -182,18 +182,18 @@ so causes the change to be applied to the index as well."
(defun magit-apply--get-selection () (defun magit-apply--get-selection ()
(or (magit-region-sections '(hunk file) t) (or (magit-region-sections '(hunk file) t)
(let ((section (magit-current-section))) (let ((section (magit-current-section)))
(pcase (magit-section-type section) (pcase (oref section type)
((or `hunk `file) section) ((or `hunk `file) section)
((or `staged `unstaged `untracked ((or `staged `unstaged `untracked
`stashed-index `stashed-worktree `stashed-untracked) `stashed-index `stashed-worktree `stashed-untracked)
(magit-section-children section)) (oref section children))
(_ (user-error "Cannot apply this, it's not a change")))))) (_ (user-error "Cannot apply this, it's not a change"))))))
(defun magit-apply--get-diffs (sections) (defun magit-apply--get-diffs (sections)
(magit-section-case (magit-section-case
([file diffstat] ([file diffstat]
(--map (or (magit-get-section (--map (or (magit-get-section
(append `((file . ,(magit-section-value it))) (append `((file . ,(oref it value)))
(magit-section-ident magit-root-section))) (magit-section-ident magit-root-section)))
(error "Cannot get required diff headers")) (error "Cannot get required diff headers"))
sections)) sections))
...@@ -228,7 +228,7 @@ at point, stage the file but not its content." ...@@ -228,7 +228,7 @@ at point, stage the file but not its content."
(`(unstaged file t) (magit-apply-diff it "--cached")) (`(unstaged file t) (magit-apply-diff it "--cached"))
(`(unstaged files t) (magit-apply-diffs it "--cached")) (`(unstaged files t) (magit-apply-diffs it "--cached"))
(`(unstaged list t) (magit-apply-diffs it "--cached")) (`(unstaged list t) (magit-apply-diffs it "--cached"))
(`(unstaged file nil) (magit-stage-1 "-u" (list (magit-section-value it)))) (`(unstaged file nil) (magit-stage-1 "-u" (list (oref it value))))
(`(unstaged files nil) (magit-stage-1 "-u" (magit-region-values nil t))) (`(unstaged files nil) (magit-stage-1 "-u" (magit-region-values nil t)))
(`(unstaged list nil) (magit-stage-modified)) (`(unstaged list nil) (magit-stage-modified))
(`(staged ,_ ,_) (user-error "Already staged")) (`(staged ,_ ,_) (user-error "Already staged"))
...@@ -279,7 +279,7 @@ ignored) files." ...@@ -279,7 +279,7 @@ ignored) files."
(defun magit-stage-untracked (&optional intent) (defun magit-stage-untracked (&optional intent)
(let* ((section (magit-current-section)) (let* ((section (magit-current-section))
(files (pcase (magit-diff-scope) (files (pcase (magit-diff-scope)
(`file (list (magit-section-value section))) (`file (list (oref section value)))
(`files (magit-region-values nil t)) (`files (magit-region-values nil t))
(`list (magit-untracked-files)))) (`list (magit-untracked-files))))
plain repos) plain repos)
...@@ -296,9 +296,9 @@ ignored) files." ...@@ -296,9 +296,9 @@ ignored) files."
(mapc #'magit-turn-on-auto-revert-mode-if-desired plain))) (mapc #'magit-turn-on-auto-revert-mode-if-desired plain)))
(dolist (repo repos) (dolist (repo repos)
(save-excursion (save-excursion
(goto-char (magit-section-start (goto-char (oref (magit-get-section
(magit-get-section `((file . ,repo) (untracked) (status)))
`((file . ,repo) (untracked) (status))))) start))
(let* ((topdir (magit-toplevel)) (let* ((topdir (magit-toplevel))
(package (package
(and (equal (bound-and-true-p borg-user-emacs-directory) (and (equal (bound-and-true-p borg-user-emacs-directory)
...@@ -341,7 +341,7 @@ ignored) files." ...@@ -341,7 +341,7 @@ ignored) files."
(`(staged file t) (magit-apply-diff it "--reverse" "--cached")) (`(staged file t) (magit-apply-diff it "--reverse" "--cached"))
(`(staged files t) (magit-apply-diffs it "--reverse" "--cached")) (`(staged files t) (magit-apply-diffs it "--reverse" "--cached"))
(`(staged list t) (magit-apply-diffs it "--reverse" "--cached")) (`(staged list t) (magit-apply-diffs it "--reverse" "--cached"))
(`(staged file nil) (magit-unstage-1 (list (magit-section-value it)))) (`(staged file nil) (magit-unstage-1 (list (oref it value))))
(`(staged files nil) (magit-unstage-1 (magit-region-values nil t))) (`(staged files nil) (magit-unstage-1 (magit-region-values nil t)))
(`(staged list nil) (magit-unstage-all)) (`(staged list nil) (magit-unstage-all))
(`(committed ,_ ,_) (if magit-unstage-committed (`(committed ,_ ,_) (if magit-unstage-committed
...@@ -414,8 +414,8 @@ without requiring confirmation." ...@@ -414,8 +414,8 @@ without requiring confirmation."
(if (eq (magit-diff-type section) 'unstaged) (if (eq (magit-diff-type section) 'unstaged)
(funcall apply section "--reverse") (funcall apply section "--reverse")
(if (magit-anything-unstaged-p (if (magit-anything-unstaged-p
nil (if (eq (magit-section-type section) 'file) nil (if (eq (oref section type) 'file)
(magit-section-value section) (oref section value)
(magit-section-parent-value section))) (magit-section-parent-value section)))
(progn (let ((inhibit-magit-refresh t)) (progn (let ((inhibit-magit-refresh t))
(funcall apply section "--reverse" "--cached") (funcall apply section "--reverse" "--cached")
...@@ -435,8 +435,8 @@ without requiring confirmation." ...@@ -435,8 +435,8 @@ without requiring confirmation."
(if (eq (magit-diff-type section) 'unstaged) (if (eq (magit-diff-type section) 'unstaged)
(funcall apply sections "--reverse") (funcall apply sections "--reverse")
(if (magit-anything-unstaged-p (if (magit-anything-unstaged-p
nil (if (eq (magit-section-type section) 'file) nil (if (eq (oref section type) 'file)
(magit-section-value section) (oref section value)
(magit-section-parent-value section))) (magit-section-parent-value section)))
(progn (let ((inhibit-magit-refresh t)) (progn (let ((inhibit-magit-refresh t))
(funcall apply sections "--reverse" "--cached") (funcall apply sections "--reverse" "--cached")
...@@ -453,7 +453,7 @@ without requiring confirmation." ...@@ -453,7 +453,7 @@ without requiring confirmation."
(status (magit-file-status)) (status (magit-file-status))
files delete resurrect rename discard discard-new resolve) files delete resurrect rename discard discard-new resolve)
(dolist (section sections) (dolist (section sections)
(let ((file (magit-section-value section))) (let ((file (oref section value)))
(push file files) (push file files)
(pcase (cons (pcase type (pcase (cons (pcase type
(`staged ?X) (`staged ?X)
...@@ -536,7 +536,7 @@ without requiring confirmation." ...@@ -536,7 +536,7 @@ without requiring confirmation."
(magit-call-git "reset" "--" orig)))))) (magit-call-git "reset" "--" orig))))))
(defun magit-discard-files--discard (sections new-files) (defun magit-discard-files--discard (sections new-files)
(let ((files (mapcar #'magit-section-value sections))) (let ((files (--map (oref it value) sections)))
(when (magit-confirm-files (when (magit-confirm-files
'discard (append files new-files) 'discard (append files new-files)
(format "Discard %s changes in" (magit-diff-type))) (format "Discard %s changes in" (magit-diff-type)))
...@@ -548,7 +548,7 @@ without requiring confirmation." ...@@ -548,7 +548,7 @@ without requiring confirmation."
(let ((binaries (magit-staged-binary-files))) (let ((binaries (magit-staged-binary-files)))
(when binaries (when binaries
(setq sections (setq sections
(--filter (not (member (magit-section-value it) binaries)) (--filter (not (member (oref it value) binaries))
sections))) sections)))
(cond ((= (length sections) 1) (cond ((= (length sections) 1)
(magit-discard-apply (car sections) 'magit-apply-diff)) (magit-discard-apply (car sections) 'magit-apply-diff))
...@@ -604,8 +604,9 @@ so causes the change to be applied to the index as well." ...@@ -604,8 +604,9 @@ so causes the change to be applied to the index as well."
(defun magit-reverse-files (sections args) (defun magit-reverse-files (sections args)
(-let [(binaries sections) (-let [(binaries sections)
(let ((bs (magit-staged-binary-files))) (let ((bs (magit-staged-binary-files)))
(--separate (member (magit-section-value it) bs) sections))] (--separate (member (oref it value) bs)
(when (magit-confirm-files 'reverse (mapcar #'magit-section-value sections)) sections))]
(when (magit-confirm-files 'reverse (--map (oref it value) sections))
(if (= (length sections) 1) (if (= (length sections) 1)
(magit-reverse-apply (car sections) 'magit-apply-diff args) (magit-reverse-apply (car sections) 'magit-apply-diff args)
(magit-reverse-apply sections 'magit-apply-diffs args))) (magit-reverse-apply sections 'magit-apply-diffs args)))
......
...@@ -51,8 +51,9 @@ This function will: ...@@ -51,8 +51,9 @@ This function will:
(when (derived-mode-p 'magit-mode) (when (derived-mode-p 'magit-mode)
(-when-let (hidden-sections (bookmark-prop-get bookmark (-when-let (hidden-sections (bookmark-prop-get bookmark
'magit-hidden-sections)) 'magit-hidden-sections))
(--each (magit-section-children magit-root-section) (--each (oref magit-root-section children)
(if (member (cons (magit-section-type it) (magit-section-value it)) (if (member (cons (oref it type)
(oref it value))
hidden-sections) hidden-sections)
(magit-section-hide it) (magit-section-hide it)
(magit-section-show it))))) (magit-section-show it)))))
...@@ -87,9 +88,10 @@ specifies additional properties to store in the bookmark." ...@@ -87,9 +88,10 @@ specifies additional properties to store in the bookmark."
(when (derived-mode-p 'magit-mode) (when (derived-mode-p 'magit-mode)
(bookmark-prop-set (bookmark-prop-set
bookmark 'magit-hidden-sections bookmark 'magit-hidden-sections
(--map (cons (magit-section-type it) (magit-section-value it)) (--map (cons (oref it type)
(-filter #'magit-section-hidden (oref it value))
(magit-section-children magit-root-section))))) (--filter (oref it hidden)
(oref magit-root-section children)))))
(when make-props (when make-props
(pcase-dolist (`(,prop . ,value) (apply make-props magit-refresh-args)) (pcase-dolist (`(,prop . ,value) (apply make-props magit-refresh-args))
(bookmark-prop-set bookmark prop value))) (bookmark-prop-set bookmark prop value)))
...@@ -340,12 +342,12 @@ specifies additional properties to store in the bookmark." ...@@ -340,12 +342,12 @@ specifies additional properties to store in the bookmark."
(magit-args . ,args) (magit-args . ,args)
(magit-files . ,files) (magit-files . ,files)
(magit-hidden-sections (magit-hidden-sections
. ,(--map `(,(magit-section-type it) . ,(--map `(,(oref it type)
. ,(replace-regexp-in-string (regexp-quote stash) . ,(replace-regexp-in-string (regexp-quote stash)
magit-buffer-revision-hash magit-buffer-revision-hash
(magit-section-value it))) (oref it value)))
(-filter #'magit-section-hidden (--filter (oref it hidden)
(magit-section-children magit-root-section)))))))) (oref magit-root-section children))))))))
;;; Submodules ;;; Submodules
......
This diff is collapsed.
...@@ -285,7 +285,7 @@ mind at all, then it asks the user for a command to run." ...@@ -285,7 +285,7 @@ mind at all, then it asks the user for a command to run."
(interactive) (interactive)
(magit-section-case (magit-section-case
(hunk (save-excursion (hunk (save-excursion
(goto-char (magit-section-start (magit-section-parent it))) (goto-char (oref (oref it parent) start))
(magit-ediff-dwim))) (magit-ediff-dwim)))
(t (t
(let ((range (magit-diff--dwim)) (let ((range (magit-diff--dwim))
......
...@@ -704,7 +704,7 @@ Sorted from longest to shortest CYGWIN name." ...@@ -704,7 +704,7 @@ Sorted from longest to shortest CYGWIN name."
(defun magit-file-at-point () (defun magit-file-at-point ()
(magit-section-case (magit-section-case
(file (magit-section-value it)) (file (oref it value))
(hunk (magit-section-parent-value it)))) (hunk (magit-section-parent-value it))))
(defun magit-current-file () (defun magit-current-file ()
...@@ -904,22 +904,22 @@ to, or to some other symbolic-ref that points to the same ref." ...@@ -904,22 +904,22 @@ to, or to some other symbolic-ref that points to the same ref."
(defun magit-branch-at-point () (defun magit-branch-at-point ()
(magit-section-case (magit-section-case
(branch (magit-section-value it)) (branch (oref it value))
(commit (magit-name-branch (magit-section-value it))))) (commit (magit-name-branch (oref it value)))))
(defun magit-local-branch-at-point () (defun magit-local-branch-at-point ()
(magit-section-case (magit-section-case
(branch (let ((branch (magit-ref-maybe-qualify (magit-section-value it)))) (branch (let ((branch (magit-ref-maybe-qualify (oref it value))))
(when (member branch (magit-list-local-branch-names)) (when (member branch (magit-list-local-branch-names))
branch))) branch)))
(commit (magit-name-local-branch (magit-section-value it))))) (commit (magit-name-local-branch (oref it value)))))
(defun magit-remote-branch-at-point () (defun magit-remote-branch-at-point ()
(magit-section-case (magit-section-case
(branch (let ((branch (magit-section-value it))) (branch (let ((branch (oref it value)))
(when (member branch (magit-list-remote-branch-names)) (when (member branch (magit-list-remote-branch-names))
branch))) branch)))
(commit (magit-name-remote-branch (magit-section-value it))))) (commit (magit-name-remote-branch (oref it value)))))
(defun magit-commit-at-point () (defun magit-commit-at-point ()
(or (magit-section-when commit) (or (magit-section-when commit)
...@@ -929,10 +929,10 @@ to, or to some other symbolic-ref that points to the same ref." ...@@ -929,10 +929,10 @@ to, or to some other symbolic-ref that points to the same ref."
(defun magit-branch-or-commit-at-point () (defun magit-branch-or-commit-at-point ()
(or magit-buffer-refname (or magit-buffer-refname
(magit-section-case (magit-section-case
(branch (magit-ref-maybe-qualify (magit-section-value it))) (branch (magit-ref-maybe-qualify (oref it value)))
(commit (let ((rev (magit-section-value it))) (commit (let ((rev (oref it value)))
(or (magit-get-shortname rev) rev))) (or (magit-get-shortname rev) rev)))
(tag (magit-ref-maybe-qualify (magit-section-value it) "tags/"))) (tag (magit-ref-maybe-qualify (oref it value) "tags/")))
(thing-at-point 'git-revision t) (thing-at-point 'git-revision t)
(and (derived-mode-p 'magit-revision-mode (and (derived-mode-p 'magit-revision-mode
'magit-merge-preview-mode) 'magit-merge-preview-mode)
...@@ -940,15 +940,15 @@ to, or to some other symbolic-ref that points to the same ref." ...@@ -940,15 +940,15 @@ to, or to some other symbolic-ref that points to the same ref."
(defun magit-tag-at-point () (defun magit-tag-at-point ()
(magit-section-case (magit-section-case
(tag (magit-section-value it)) (tag (oref it value))
(commit (magit-name-tag (magit-section-value it))))) (commit (magit-name-tag (oref it value)))))
(defun magit-stash-at-point () (defun magit-stash-at-point ()
(magit-section-when stash)) (magit-section-when stash))
(defun magit-remote-at-point () (defun magit-remote-at-point ()
(magit-section-case (magit-section-case
(remote (magit-section-value it)) (remote (oref it value))
(branch (magit-section-parent-value it)))) (branch (magit-section-parent-value it))))
(defun magit-get-current-branch () (defun magit-get-current-branch ()
......
...@@ -55,19 +55,19 @@ This function is used as a helper for functions set as ...@@ -55,19 +55,19 @@ This function is used as a helper for functions set as
(while (magit-section--backward-find (while (magit-section--backward-find
(lambda () (lambda ()
(let* ((section (magit-current-section)) (let* ((section (magit-current-section))
(type (magit-section-type section)) (type (oref section type))
(parent (magit-section-parent section)) (parent (oref section parent))
(parent-type (magit-section-type parent))) (parent-type (oref parent type)))
(and (-contains-p entry-types type) (and (-contains-p entry-types type)
(-contains-p menu-types parent-type))))) (-contains-p menu-types parent-type)))))
(let* ((section (magit-current-section)) (let* ((section (magit-current-section))
(name (buffer-substring-no-properties (name (buffer-substring-no-properties
(line-beginning-position) (line-beginning-position)
(line-end-position))) (line-end-position)))
(parent (magit-section-parent section)) (parent (oref section parent))
(parent-title (buffer-substring-no-properties (parent-title (buffer-substring-no-properties
(magit-section-start parent) (oref parent start)
(1- (magit-section-content parent))))) (1- (oref parent content)))))
(puthash parent-title (puthash parent-title
(cons (cons name (point)) (cons (cons name (point))
(gethash parent-title entries (list))) (gethash parent-title entries (list)))
...@@ -86,7 +86,7 @@ This function is used as a value for ...@@ -86,7 +86,7 @@ This function is used as a value for
(magit-section--backward-find (magit-section--backward-find
(lambda () (lambda ()
(-contains-p '(commit stash) (-contains-p '(commit stash)
(magit-section-type (magit-current-section)))))) (oref (magit-current-section) type)))))
;;;###autoload ;;;###autoload
(defun magit-imenu--log-extract-index-name-function () (defun magit-imenu--log-extract-index-name-function ()
...@@ -109,10 +109,10 @@ This function is used as a value for ...@@ -109,10 +109,10 @@ This function is used as a value for
`imenu-prev-index-position-function'." `imenu-prev-index-position-function'."
(magit-section--backward-find (magit-section--backward-find
(lambda () (lambda ()
(and (equal (magit-section-type (magit-current-section)) 'file) (let ((section (magit-current-section)))
(not (equal (magit-section-type (and (equal (oref section type) 'file)
(magit-section-parent (magit-current-section))) (not (equal (oref (oref section parent) type)
'diffstat)))))) 'diffstat)))))))
;;;###autoload ;;;###autoload
(defun magit-imenu--diff-extract-index-name-function () (defun magit-imenu--diff-extract-index-name-function ()
...@@ -204,9 +204,7 @@ This function is used as a value for ...@@ -204,9 +204,7 @@ This function is used as a value for
`imenu-prev-index-position-function'." `imenu-prev-index-position-function'."
(magit-section--backward-find (magit-section--backward-find
(lambda () (lambda ()
(eq (eq (oref (magit-current-section) type) 'process))))
(magit-section-type (magit-current-section))
'process))))
;;;###autoload ;;;###autoload
(defun magit-imenu--process-extract-index-name-function () (defun magit-imenu--process-extract-index-name-function ()
......
...@@ -773,9 +773,9 @@ is displayed in the current frame." ...@@ -773,9 +773,9 @@ is displayed in the current frame."
(interactive "p") (interactive "p")
(when (derived-mode-p 'magit-log-mode) (when (derived-mode-p 'magit-log-mode)
(magit-section-when commit (magit-section-when commit
(let ((parent-rev (format "%s^%s" (magit-section-value it) (or n 1)))) (let ((parent-rev (format "%s^%s" (oref it value) (or n 1))))
(-if-let (parent-hash (magit-rev-parse "--short" parent-rev)) (-if-let (parent-hash (magit-rev-parse "--short" parent-rev))
(-if-let (section (--first (equal (magit-section-value it) (-if-let (section (--first (equal (oref it value)
parent-hash) parent-hash)
(magit-section-siblings it 'next))) (magit-section-siblings it 'next)))
(magit-section-goto section) (magit-section-goto section)
...@@ -1019,8 +1019,8 @@ Do not add this to a hook variable." ...@@ -1019,8 +1019,8 @@ Do not add this to a hook variable."
(cl-return-from magit-log-wash-rev t)) (cl-return-from magit-log-wash-rev t))
(magit-insert-section section (commit hash) (magit-insert-section section (commit hash)
(pcase style (pcase style
(`stash (setf (magit-section-type section) 'stash)) (`stash (oset section type 'stash))
(`module (setf (magit-section-type section) 'module-commit)) (`module (oset section type 'module-commit))
(`bisect-log (setq hash (magit-rev-parse "--short" hash)))) (`bisect-log (setq hash (magit-rev-parse "--short" hash))))
(when cherry (when cherry
(when (and (derived-mode-p 'magit-refs-mode) (when (and (derived-mode-p 'magit-refs-mode)
...@@ -1098,7 +1098,7 @@ Do not add this to a hook variable." ...@@ -1098,7 +1098,7 @@ Do not add this to a hook variable."
(let ((limit (save-excursion (let ((limit (save-excursion
(and (re-search-forward non-graph-re nil t) (and (re-search-forward non-graph-re nil t)
(match-beginning 0))))) (match-beginning 0)))))
(unless (magit-section-content magit-insert-section--current) (unless (oref magit-insert-section--current content)
(magit-insert-heading)) (magit-insert-heading))
(delete-char (if (looking-at "\n") 1 4)) (delete-char (if (looking-at "\n") 1 4))
(magit-diff-wash-diffs (list "--stat") limit)) (magit-diff-wash-diffs (list "--stat") limit))
...@@ -1143,7 +1143,7 @@ having to press \"+\". ...@@ -1143,7 +1143,7 @@ having to press \"+\".
This function is called by `magit-section-movement-hook' and This function is called by `magit-section-movement-hook' and
exists mostly for backward compatibility reasons." exists mostly for backward compatibility reasons."
(when (and (eq (magit-section-type section) 'longer) (when (and (eq (oref section type) 'longer)
magit-log-auto-more) magit-log-auto-more)
(magit-log-double-commit-limit) (magit-log-double-commit-limit)
(forward-line -1) (forward-line -1)
...@@ -1204,13 +1204,12 @@ If there is no blob buffer in the same frame, then do nothing." ...@@ -1204,13 +1204,12 @@ If there is no blob buffer in the same frame, then do nothing."
(defun magit-log-goto-same-commit () (defun magit-log-goto-same-commit ()
(-when-let* ((prev magit-previous-section) (-when-let* ((prev magit-previous-section)
(rev (cond ((magit-section-match 'commit prev) (rev (cond ((magit-section-match 'commit prev)
(magit-section-value prev)) (oref prev value))
((magit-section-match 'branch prev) ((magit-section-match 'branch prev)
(magit-rev-format (magit-rev-format "%h" (oref prev value)))))
"%h" (magit-section-value prev))))) (same (--first (equal (oref it value) rev)
(same (--first (equal (magit-section-value it) rev) (oref magit-root-section children))))
(magit-section-children magit-root-section)))) (goto-char (oref same start))))
(goto-char (magit-section-start same))))
;;; Log Margin ;;; Log Margin
...@@ -1531,7 +1530,7 @@ then show the last `magit-log-section-commit-count' commits." ...@@ -1531,7 +1530,7 @@ then show the last `magit-log-section-commit-count' commits."
'((unpushed . "@{upstream}..") '((unpushed . "@{upstream}..")
(status)) (status))
magit-insert-section--oldroot)) magit-insert-section--oldroot))
(magit-section-hidden it) (oref it hidden)
nil)) nil))
(magit-insert-unpushed-to-upstream (magit-insert-unpushed-to-upstream
(--if-let (and magit-insert-section--oldroot (--if-let (and magit-insert-section--oldroot
...@@ -1540,7 +1539,7 @@ then show the last `magit-log-section-commit-count' commits." ...@@ -1540,7 +1539,7 @@ then show the last `magit-log-section-commit-count' commits."
magit-log-section-commit-count)) magit-log-section-commit-count))
(status)) (status))
magit-insert-section--oldroot)) magit-insert-section--oldroot))
(magit-section-hidden it) (oref it hidden)
t))))) t)))))
(defun magit-insert-unpushed-to-upstream (&optional collapse) (defun magit-insert-unpushed-to-upstream (&optional collapse)
......
...@@ -1034,10 +1034,10 @@ Run hooks `magit-pre-refresh-hook' and `magit-post-refresh-hook'." ...@@ -1034,10 +1034,10 @@ Run hooks `magit-pre-refresh-hook' and `magit-post-refresh-hook'."
(defun magit-refresh-get-relative-position () (defun magit-refresh-get-relative-position ()
(-when-let (section (magit-current-section)) (-when-let (section (magit-current-section))
(let ((start (magit-section-start section))) (let ((start (oref section start)))
(list (count-lines start (point)) (list (count-lines start (point))
(- (point) (line-beginning-position)) (- (point) (line-beginning-position))
(and (eq (magit-section-type section) 'hunk) (and (eq (oref section type) 'hunk)
(region-active-p) (region-active-p)
(progn (goto-char (line-beginning-position)) (progn (goto-char (line-beginning-position))
(when (looking-at "^[-+]") (forward-line)) (when (looking-at "^[-+]") (forward-line))
......
...@@ -286,7 +286,7 @@ optional NODISPLAY is non-nil also display it." ...@@ -286,7 +286,7 @@ optional NODISPLAY is non-nil also display it."
"Kill the process at point." "Kill the process at point."
(interactive) (interactive)
(magit-section-when process (magit-section-when process
(let ((process (magit-section-value it))) (let ((process (oref it value)))
(if (eq (process-status process) 'run) (if (eq (process-status process) 'run)
(when (magit-confirm 'kill-process) (when (magit-confirm 'kill-process)
(kill-process process)) (kill-process process))
...@@ -540,7 +540,7 @@ Magit status buffer." ...@@ -540,7 +540,7 @@ Magit status buffer."
(process-put process 'default-dir default-directory) (process-put process 'default-dir default-directory)
(when inhibit-magit-refresh (when inhibit-magit-refresh
(process-put process 'inhibit-refresh t)) (process-put process 'inhibit-refresh t))
(setf (magit-section-process section) process) (oset section process process)
(with-current-buffer process-buf (with-current-buffer process-buf
(set-marker (process-mark process) (point))) (set-marker (process-mark process) (point)))
(when input (when input
...@@ -548,7 +548,7 @@ Magit status buffer." ...@@ -548,7 +548,7 @@ Magit status buffer."
(process-send-region process (point-min) (point-max)) (process-send-region process (point-min) (point-max))
(process-send-eof process))) (process-send-eof process)))
(setq magit-this-process process) (setq magit-this-process process)
(setf (magit-section-value section) process) (oset section value process)
(magit-process-display-buffer process) (magit-process-display-buffer process)
process)) process))
...@@ -599,23 +599,23 @@ Magit status buffer." ...@@ -599,23 +599,23 @@ Magit status buffer."
(defun magit-process-truncate-log () (defun magit-process-truncate-log ()
(let* ((head nil) (let* ((head nil)
(tail (magit-section-children magit-root-section)) (tail (oref magit-root-section children))
(count (length tail))) (count (length tail)))
(when (> (1+ count) magit-process-log-max) (when (> (1+ count) magit-process-log-max)
(while (and (cdr tail) (while (and (cdr tail)
(> count (/ magit-process-log-max 2))) (> count (/ magit-process-log-max 2)))
(let* ((inhibit-read-only t) (let* ((inhibit-read-only t)
(section (car tail)) (section (car tail))
(process (magit-section-process section))) (process (oref section process)))
(cond ((not process)) (cond ((not process))
((memq (process-status process) '(exit signal)) ((memq (process-status process) '(exit signal))
(delete-region (magit-section-start section) (delete-region (oref section start)
(1+ (magit-section-end section))) (1+ (oref section end)))
(cl-decf count)) (cl-decf count))
(t (t
(push section head)))) (push section head))))
(pop tail)) (pop tail))
(setf (magit-section-children magit-root-section) (oset magit-root-section children
(nconc (reverse head) tail))))) (nconc (reverse head) tail)))))
(defun magit-process-sentinel (process event) (defun magit-process-sentinel (process event)
...@@ -654,7 +654,7 @@ Magit status buffer." ...@@ -654,7 +654,7 @@ Magit status buffer."
((or "rebase" "am") 'rebase-sequence) ((or "rebase" "am") 'rebase-sequence)
((or "cherry-pick" "revert") 'sequence)))