Advertisement
mark-naylor-1701

magit ehancements

Dec 16th, 2024
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.87 KB | None | 0 0
  1. (defun magit-jump-to-section (jump-fn)
  2.   "Generic jump magit jump function."
  3.   (magit-section-show-level-3-all)
  4.   (with-suppressed-warnings ((interactive-only))
  5.     (unless (funcall jump-fn)
  6.       (forward-line 2)
  7.       (magit-section-show (magit-current-section))
  8.       (recenter-top-bottom 2))))
  9.  
  10. (defun magit-jump-to-unstaged+ ()
  11.   "Better jump command. Closes the hunks, jumps to the section head, moves that
  12. header to the top of the screen."
  13.   (interactive)
  14.   (magit-jump-to-section #'magit-jump-to-unstaged))
  15.  
  16. (defun magit-jump-to-staged+ ()
  17.   "Better jump command. Closes the hunks, jumps to the section head, moves that
  18. header to the top of the screen."
  19.   (interactive)
  20.   (magit-jump-to-section #'magit-jump-to-staged))
  21.  
  22. (define-key magit-mode-map (kbd "C-c m u") #'magit-jump-to-unstaged+)
  23. (define-key magit-mode-map (kbd "C-c m s") #'magit-jump-to-staged+)
  24.  
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement