Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT] add: the :jumps ex-command for vi-mode. #1675

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions extensions/vi-mode/commands.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
:vi-append-line
:vi-open-below
:vi-open-above
:vi-jumps
:vi-jump-back
:vi-jump-next
:vi-a-word
Expand Down Expand Up @@ -402,10 +403,10 @@ Move the cursor to the first non-blank character of the line."
(max 0
(min (1- (length (line-string (current-point)))) pos))))
(:block
(move-to-line (current-point) (min (line-number-at-point start)
(line-number-at-point end)))
(move-to-column (current-point) (min column-start
column-end))))
(move-to-line (current-point) (min (line-number-at-point start)
(line-number-at-point end)))
(move-to-column (current-point) (min column-start
column-end))))
;; After 'dw' or 'dW', move to the first non-blank char
(when (and (this-motion-command)
(member (command-name (this-motion-command))
Expand Down Expand Up @@ -506,10 +507,10 @@ Move the cursor to the first non-blank character of the line."
(yank-region start end :type type)
(case type
(:block
(move-to-line (current-point) (min (line-number-at-point start)
(line-number-at-point end)))
(move-to-column (current-point) (min (point-column start)
(point-column end))))
(move-to-line (current-point) (min (line-number-at-point start)
(line-number-at-point end)))
(move-to-column (current-point) (min (point-column start)
(point-column end))))
(:line
(move-to-column start (point-charpos (current-point)))
(move-point (current-point) start))
Expand Down Expand Up @@ -797,9 +798,9 @@ on the same line or at eol if there are none."
(move-point point p)))
(lambda (point regex &optional limit-point)
(lem/isearch::search-forward-regexp
point
(ignore-errors (ppcre:create-scanner regex :case-insensitive-mode case-insensitive))
limit-point))
point
(ignore-errors (ppcre:create-scanner regex :case-insensitive-mode case-insensitive))
limit-point))
(lambda (point regex &optional limit-point)
(lem/isearch::search-backward-regexp
point
Expand Down Expand Up @@ -924,7 +925,7 @@ on the same line or at eol if there are none."
(string c)
limit)
unless result
do (return nil)
do (return nil)
finally (return t))
(character-offset p offset)
(move-point (current-point) p)))))
Expand Down Expand Up @@ -1015,6 +1016,11 @@ on the same line or at eol if there are none."
(line-start p))))))
(move-to-column (current-point) column t)))

(define-command vi-jumps () ()
(line-end (current-point))
(lem:message-buffer (with-output-to-string (s)
(lem-vi-mode/jumplist::print-jumplist (current-jumplist) s))))

(define-command vi-jump-back (&optional (n 1)) (:universal)
(dotimes (i n)
(jump-back)))
Expand Down
16 changes: 10 additions & 6 deletions extensions/vi-mode/ex-command.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@
(ex-write range filename t)))

(define-ex-command "^bn$" (range argument)
(declare (ignore range argument))
(lem:next-buffer))
(declare (ignore range argument))
(lem:next-buffer))

(define-ex-command "^bp$" (range argument)
(declare (ignore range argument))
(lem:previous-buffer))
(declare (ignore range argument))
(lem:previous-buffer))

(define-ex-command "^wq$" (range filename)
(ex-write-quit range filename nil t))
Expand Down Expand Up @@ -190,8 +190,8 @@
(declare (ignore range))
(lem:pipe-command
(format nil "~A ~A"
(subseq lem-vi-mode/ex-core:*command* 1)
command)))
(subseq lem-vi-mode/ex-core:*command* 1)
command)))

(define-ex-command "^(buffers|ls|files)$" (range argument)
(declare (ignore range argument))
Expand Down Expand Up @@ -259,3 +259,7 @@
(define-ex-command "^pwd?$" (range argument)
(declare (ignore range argument))
(lem:current-directory))

(define-ex-command "^jumps?$" (range argument)
(declare (ignore range argument))
(lem-vi-mode/commands:vi-jumps))
Loading