Skip to content

Commit

Permalink
slight improvements & initial work to fix mark-previous-like-this
Browse files Browse the repository at this point in the history
  • Loading branch information
Book-reader committed Sep 10, 2024
1 parent 44bdc5e commit 8cbbb0d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions extensions/multiple-cursors/multiple-cursors.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
:point-line
:point-change-line)
(:import-from :lem/buffer/line
:line-previous)
:line-previous
:line-next)
(:export :add-cursors-to-next-line
:add-cursors-to-previous-line
:mark-next-like-this)
Expand All @@ -31,16 +32,14 @@
(define-command mark-next-like-this () ()
""
(if (buffer-mark-p (current-buffer))
(mark-like-this-direction (region-beginning-using-global-mode (current-global-mode))
(region-end-using-global-mode (current-global-mode))
(mark-like-this-direction (region-beginning (current-buffer)) (region-end (current-buffer))
#'search-forward)
(add-cursors-to-next-line)))

(define-command mark-previous-like-this () ()
""
(if (buffer-mark-p (current-buffer))
(mark-like-this-direction (region-beginning-using-global-mode (current-global-mode))
(region-end-using-global-mode (current-global-mode))
(mark-like-this-direction (region-beginning (current-buffer)) (region-end (current-buffer))
#'search-backward)
(add-cursors-to-previous-line)))

Expand Down Expand Up @@ -75,7 +74,9 @@
(progn
(setf cursor (make-fake-cursor point))
(dotimes (_ (- (point-linum end) (point-linum start)))
(point-change-line point (- (point-linum point) 1) (line-previous (point-line point))))
(if (equal direction #'search-forward)
(point-change-line point (- (point-linum point) 1) (line-previous (point-line point)))
(point-change-line point (+ (point-linum point) 1) (line-next (point-line point)))))
(setf (point-charpos point) (- (point-charpos point) (- (point-charpos end) (point-charpos start))))
(set-cursor-mark cursor point))
(message "No more matches"))))
Expand Down

0 comments on commit 8cbbb0d

Please sign in to comment.