Skip to content

Commit

Permalink
When using block selection in evil, check if numbers are in region.
Browse files Browse the repository at this point in the history
  • Loading branch information
therockmandolinist committed Jan 19, 2017
1 parent 2668d1f commit dc21864
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions evil-numbers.el
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,31 @@ applying the regional features of `evil-numbers/inc-at-point'.
((and (not no-region) (or (evil-visual-state-p) (region-active-p)))
(let (deactivate-mark
(rb (region-beginning))
(re (region-end)))
(re (region-end))
(cc (- (point-max) (point-min))))
(save-excursion
(save-match-data
(goto-char rb)
(while (re-search-forward "\\(?:0\\(?:[Bb][01]+\\|[Oo][0-7]+\\|[Xx][0-9A-Fa-f]+\\)\\|-?[0-9]+\\)" re t)
(evil-numbers/inc-at-pt amount 'no-region)
(cond ((and (featurep 'evil)
evil-visual-block-overlays
(-some-p 'evil-numbers--point-in-overlay-p evil-visual-block-overlays))
(evil-numbers/inc-at-pt amount 'no-region)
(setq old-cc cc)
(setq cc (- (point-max) (point-min)))
(setq re (+ re (- cc old-cc))))
((and (featurep 'evil)
evil-visual-block-overlays)
nil)
(t
(evil-numbers/inc-at-pt amount 'no-region)
(setq old-cc cc)
(setq cc (- (point-max) (point-min)))
(setq re (+ re (- cc old-cc)))))
;; (if (and (boundp 'evil-visual-block-overlays) evil-visual-block-overlays)
;; (and (-some-p 'evil-numbers--point-in-overlay-p evil-visual-block-overlays)
;; (evil-numbers/inc-at-pt amount 'no-region))
;; (evil-numbers/inc-at-pt amount 'no-region))
;; Undo vim compatability.
(forward-char 1)))))
(setq deactivate-mark evil-numbers-deactivate-mark))
Expand Down Expand Up @@ -241,5 +260,14 @@ representation of `NUMBER' is smaller."
"")
nums))))

;; (defun evil-numbers--point-in-overlay-p (overlay)
;; "Return t if point is in OVERLAY."
;; (and (<= (point) (+ 1 (overlay-end overlay)))
;; (>= (point) (overlay-start overlay))))
(defun evil-numbers--point-in-overlay-p (overlay)
"Return t if point is in OVERLAY."
(and (<= (point) (overlay-end overlay))
(>= (point) (overlay-start overlay))))

(provide 'evil-numbers)
;;; evil-numbers.el ends here

0 comments on commit dc21864

Please sign in to comment.