Skip to content

Commit

Permalink
Move code that updates the region to magit-section.el
Browse files Browse the repository at this point in the history
  • Loading branch information
tarsius committed Dec 20, 2019
1 parent f66ace9 commit 83fcc31
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 25 deletions.
24 changes: 0 additions & 24 deletions lisp/magit-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -589,30 +589,6 @@ Magit is documented in info node `(magit)'."

;;; Highlighting

(defvar-local magit-region-overlays nil)

(defun magit-delete-region-overlays ()
(mapc #'delete-overlay magit-region-overlays)
(setq magit-region-overlays nil))

(defun magit-highlight-region (start end window rol)
(magit-delete-region-overlays)
(if (and (run-hook-with-args-until-success 'magit-region-highlight-hook
(magit-current-section))
(not magit-keep-region-overlay)
(not (= (line-number-at-pos start)
(line-number-at-pos end)))
;; (not (eq (car-safe last-command-event) 'mouse-movement))
)
(funcall (default-value 'redisplay-unhighlight-region-function) rol)
(funcall (default-value 'redisplay-highlight-region-function)
start end window rol)))

(defun magit-unhighlight-region (rol)
(setq magit-section-highlighted-section nil)
(magit-delete-region-overlays)
(funcall (default-value 'redisplay-unhighlight-region-function) rol))

;;; Local Variables

(defvar-local magit-buffer-arguments nil)
Expand Down
28 changes: 27 additions & 1 deletion lisp/magit-section.el
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,7 @@ evaluated its BODY. Admittedly that's a bit of a hack."
(insert (format " (%s)" count))
(delete-char 1)))))

;;; Update
;;; Highlight

(defvar-local magit-section-highlight-overlays nil)
(defvar-local magit-section-highlighted-section nil)
Expand Down Expand Up @@ -1361,6 +1361,32 @@ invisible."
(or (magit-get-section (magit-section-ident it))
(magit-section-goto-successor-1 it)))))

;;; Region

(defvar-local magit-region-overlays nil)

(defun magit-delete-region-overlays ()
(mapc #'delete-overlay magit-region-overlays)
(setq magit-region-overlays nil))

(defun magit-highlight-region (start end window rol)
(magit-delete-region-overlays)
(if (and (run-hook-with-args-until-success 'magit-region-highlight-hook
(magit-current-section))
(not magit-keep-region-overlay)
(not (= (line-number-at-pos start)
(line-number-at-pos end)))
;; (not (eq (car-safe last-command-event) 'mouse-movement))
)
(funcall (default-value 'redisplay-unhighlight-region-function) rol)
(funcall (default-value 'redisplay-highlight-region-function)
start end window rol)))

(defun magit-unhighlight-region (rol)
(setq magit-section-highlighted-section nil)
(magit-delete-region-overlays)
(funcall (default-value 'redisplay-unhighlight-region-function) rol))

;;; Visibility

(defvar-local magit-section-visibility-cache nil)
Expand Down

0 comments on commit 83fcc31

Please sign in to comment.