Keep point where it was across a refresh.
* magit.el: Don't move point in refresh functions. (magit-refresh): Try to keep point where it was. (magit-run*): Call magit-refresh outside of the save-excursion so that it can move point.
This commit is contained in:
parent
9214dccd6f
commit
f34fee9759
1 changed files with 68 additions and 60 deletions
128
magit.el
128
magit.el
|
@ -123,6 +123,7 @@ Many Magit faces inherit from this one by default."
|
||||||
;;; Utilities
|
;;; Utilities
|
||||||
|
|
||||||
(defun magit-goto-line (line)
|
(defun magit-goto-line (line)
|
||||||
|
;; Like goto-line but doesn't set the mark.
|
||||||
(save-restriction
|
(save-restriction
|
||||||
(widen)
|
(widen)
|
||||||
(goto-char 1)
|
(goto-char 1)
|
||||||
|
@ -688,10 +689,11 @@ Many Magit faces inherit from this one by default."
|
||||||
(t
|
(t
|
||||||
(setq successp
|
(setq successp
|
||||||
(equal (apply 'call-process cmd nil buf nil args) 0))
|
(equal (apply 'call-process cmd nil buf nil args) 0))
|
||||||
(magit-set-mode-line-process nil)
|
(magit-set-mode-line-process nil))))
|
||||||
(when (not norefresh)
|
(when (and (not nowait)
|
||||||
(magit-revert-buffers)
|
(not norefresh))
|
||||||
(magit-refresh magit-process-client-buffer)))))
|
(magit-revert-buffers)
|
||||||
|
(magit-refresh magit-process-client-buffer))
|
||||||
(or successp
|
(or successp
|
||||||
noerror
|
noerror
|
||||||
(error "Git failed."))
|
(error "Git failed."))
|
||||||
|
@ -879,9 +881,27 @@ Please see the manual for a complete description of Magit.
|
||||||
(defun magit-refresh (&optional buffer)
|
(defun magit-refresh (&optional buffer)
|
||||||
(interactive)
|
(interactive)
|
||||||
(with-current-buffer (or buffer (current-buffer))
|
(with-current-buffer (or buffer (current-buffer))
|
||||||
(if magit-refresh-function
|
(let* ((old-line (line-number-at-pos))
|
||||||
(apply magit-refresh-function
|
(old-section (magit-current-section))
|
||||||
magit-refresh-args))))
|
(old-path (and old-section
|
||||||
|
(magit-section-path (magit-current-section))))
|
||||||
|
(section-line (and old-section
|
||||||
|
(count-lines
|
||||||
|
(magit-section-beginning old-section)
|
||||||
|
(point)))))
|
||||||
|
(if magit-refresh-function
|
||||||
|
(apply magit-refresh-function
|
||||||
|
magit-refresh-args))
|
||||||
|
(magit-refresh-marked-commits-in-buffer)
|
||||||
|
(let ((s (and old-path (magit-find-section old-path magit-top-section))))
|
||||||
|
(cond (s
|
||||||
|
(goto-char (magit-section-beginning s))
|
||||||
|
(forward-line section-line))
|
||||||
|
(t
|
||||||
|
(magit-goto-line old-line)))
|
||||||
|
(dolist (w (get-buffer-window-list (current-buffer)))
|
||||||
|
(set-window-point w (point)))
|
||||||
|
(magit-highlight-section)))))
|
||||||
|
|
||||||
(defun magit-refresh-all ()
|
(defun magit-refresh-all ()
|
||||||
(interactive)
|
(interactive)
|
||||||
|
@ -1102,8 +1122,7 @@ Please see the manual for a complete description of Magit.
|
||||||
(magit-create-buffer-sections
|
(magit-create-buffer-sections
|
||||||
(magit-insert-section 'commitbuf nil
|
(magit-insert-section 'commitbuf nil
|
||||||
'magit-wash-commit nil
|
'magit-wash-commit nil
|
||||||
"git" "log" "--max-count=1" "--cc" "-p" commit))
|
"git" "log" "--max-count=1" "--cc" "-p" commit)))
|
||||||
(goto-char (point-min)))
|
|
||||||
|
|
||||||
(defun magit-show-commit (commit &optional scroll)
|
(defun magit-show-commit (commit &optional scroll)
|
||||||
(let ((dir default-directory)
|
(let ((dir default-directory)
|
||||||
|
@ -1168,49 +1187,43 @@ Please see the manual for a complete description of Magit.
|
||||||
;;; Status
|
;;; Status
|
||||||
|
|
||||||
(defun magit-refresh-status ()
|
(defun magit-refresh-status ()
|
||||||
(let ((old-line (line-number-at-pos)))
|
(magit-create-buffer-sections
|
||||||
(magit-create-buffer-sections
|
(magit-with-section 'status nil
|
||||||
(magit-with-section 'status nil
|
(let* ((branch (magit-get-current-branch))
|
||||||
(let* ((branch (magit-get-current-branch))
|
(remote (and branch (magit-get "branch" branch "remote"))))
|
||||||
(remote (and branch (magit-get "branch" branch "remote"))))
|
(if remote
|
||||||
(if remote
|
(insert (format "Remote: %s %s\n"
|
||||||
(insert (format "Remote: %s %s\n"
|
remote (magit-get "remote" remote "url"))))
|
||||||
remote (magit-get "remote" remote "url"))))
|
(insert (format "Local: %s %s\n"
|
||||||
(insert (format "Local: %s %s\n"
|
(propertize (or branch "(detached)")
|
||||||
(propertize (or branch "(detached)")
|
'face 'magit-branch)
|
||||||
'face 'magit-branch)
|
(abbreviate-file-name default-directory)))
|
||||||
(abbreviate-file-name default-directory)))
|
(insert
|
||||||
(insert
|
(format
|
||||||
(format
|
"Head: %s\n"
|
||||||
"Head: %s\n"
|
(magit-shell
|
||||||
(magit-shell
|
"git log --max-count=1 --abbrev-commit --pretty=oneline")))
|
||||||
"git log --max-count=1 --abbrev-commit --pretty=oneline")))
|
(let ((merge-heads (magit-file-lines ".git/MERGE_HEAD")))
|
||||||
(let ((merge-heads (magit-file-lines ".git/MERGE_HEAD")))
|
(if merge-heads
|
||||||
(if merge-heads
|
(insert (format "Merging: %s\n"
|
||||||
(insert (format "Merging: %s\n"
|
(magit-concat-with-delim
|
||||||
(magit-concat-with-delim
|
", "
|
||||||
", "
|
(mapcar 'magit-name-rev merge-heads))))))
|
||||||
(mapcar 'magit-name-rev merge-heads))))))
|
(let ((rebase (magit-rebase-info)))
|
||||||
(let ((rebase (magit-rebase-info)))
|
(if rebase
|
||||||
(if rebase
|
(insert (apply 'format "Rebasing: %s (%s of %s)\n" rebase))))
|
||||||
(insert (apply 'format "Rebasing: %s (%s of %s)\n" rebase))))
|
(insert "\n")
|
||||||
(insert "\n")
|
(magit-insert-pending-changes)
|
||||||
(magit-insert-pending-changes)
|
(magit-insert-pending-commits)
|
||||||
(magit-insert-pending-commits)
|
(when remote
|
||||||
(when remote
|
(magit-insert-unpulled-commits remote branch))
|
||||||
(magit-insert-unpulled-commits remote branch))
|
(let ((staged (magit-anything-staged-p)))
|
||||||
(let ((staged (magit-anything-staged-p)))
|
(magit-insert-unstaged-changes
|
||||||
(magit-insert-unstaged-changes
|
(if staged "Unstaged changes:" "Changes:"))
|
||||||
(if staged "Unstaged changes:" "Changes:"))
|
(if staged
|
||||||
(if staged
|
(magit-insert-staged-changes)))
|
||||||
(magit-insert-staged-changes)))
|
(when remote
|
||||||
(when remote
|
(magit-insert-unpushed-commits remote branch))))))
|
||||||
(magit-insert-unpushed-commits remote branch)))))
|
|
||||||
(magit-goto-line old-line)
|
|
||||||
(when (bobp)
|
|
||||||
(magit-goto-section '(unstaged)))
|
|
||||||
(magit-highlight-section)
|
|
||||||
(magit-refresh-marked-commits-in-buffer)))
|
|
||||||
|
|
||||||
(defun magit-status (dir)
|
(defun magit-status (dir)
|
||||||
(interactive (list (magit-read-top-dir current-prefix-arg)))
|
(interactive (list (magit-read-top-dir current-prefix-arg)))
|
||||||
|
@ -1731,9 +1744,7 @@ Please see the manual for a complete description of Magit.
|
||||||
(magit-rev-range-describe range "Commits")
|
(magit-rev-range-describe range "Commits")
|
||||||
'magit-wash-log nil
|
'magit-wash-log nil
|
||||||
"git" "log" "--graph" "--max-count=10000"
|
"git" "log" "--graph" "--max-count=10000"
|
||||||
"--pretty=oneline" args))
|
"--pretty=oneline" args)))
|
||||||
(magit-refresh-marked-commits-in-buffer)
|
|
||||||
(goto-char (point-min)))
|
|
||||||
|
|
||||||
(defun magit-log (range)
|
(defun magit-log (range)
|
||||||
(interactive (list (magit-read-rev-range "Log" (magit-get-current-branch))))
|
(interactive (list (magit-read-rev-range "Log" (magit-get-current-branch))))
|
||||||
|
@ -1756,9 +1767,7 @@ Please see the manual for a complete description of Magit.
|
||||||
'magit-wash-log nil
|
'magit-wash-log nil
|
||||||
"git" "log" "--walk-reflogs"
|
"git" "log" "--walk-reflogs"
|
||||||
"--max-count=10000"
|
"--max-count=10000"
|
||||||
"--pretty=oneline" args))
|
"--pretty=oneline" args)))
|
||||||
(magit-refresh-marked-commits-in-buffer)
|
|
||||||
(goto-char (point-min)))
|
|
||||||
|
|
||||||
(defun magit-reflog (head)
|
(defun magit-reflog (head)
|
||||||
(interactive (list (magit-read-rev "Reflog of" "HEAD")))
|
(interactive (list (magit-read-rev "Reflog of" "HEAD")))
|
||||||
|
@ -1780,8 +1789,7 @@ Please see the manual for a complete description of Magit.
|
||||||
(magit-insert-section 'diffbuf
|
(magit-insert-section 'diffbuf
|
||||||
(magit-rev-range-describe range "Changes")
|
(magit-rev-range-describe range "Changes")
|
||||||
'magit-wash-diffs nil
|
'magit-wash-diffs nil
|
||||||
"git" "diff" args))
|
"git" "diff" args)))
|
||||||
(goto-char (point-min)))
|
|
||||||
|
|
||||||
(defun magit-diff (range)
|
(defun magit-diff (range)
|
||||||
(interactive (list (magit-read-rev-range "Diff")))
|
(interactive (list (magit-read-rev-range "Diff")))
|
||||||
|
|
Loading…
Reference in a new issue