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

Fix to work Ex command for visual range. #1061

Merged
merged 1 commit into from
Sep 6, 2023
Merged
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
13 changes: 12 additions & 1 deletion extensions/vi-mode/ex-core.lisp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
(defpackage :lem-vi-mode/ex-core
(:use :cl)
(:import-from :lem-vi-mode/visual
:visual-p
:visual-range)
(:export :*point*
:syntax-error
:search-forward
Expand Down Expand Up @@ -45,7 +48,15 @@
(lem:buffer-end *point*))

(defun marker (char)
(declare (ignore char)))
(ecase char
(#\<
(unless (visual-p)
(lem:editor-error "Mark not set"))
(first (visual-range)))
(#\>
(unless (visual-p)
(lem:editor-error "Mark not set"))
(second (visual-range)))))

(defun offset-line (offset)
(declare (ignore offset)))
Expand Down
6 changes: 5 additions & 1 deletion extensions/vi-mode/ex-parser.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,12 @@
(- (second list))
(second list)))))

(defrule visual-start (and #\' #\<))
(defrule visual-end (and #\' #\>))

(defrule ex-line (and whitespace (or goto-line current-line last-line marker
forward-pattern backward-pattern offset-line))
forward-pattern backward-pattern offset-line
visual-start visual-end))
(:lambda (list)
(second list)))

Expand Down
9 changes: 5 additions & 4 deletions extensions/vi-mode/ex.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
(with-main-window (lem:current-window)
(execute-ex
(prompt-for-string
(if in-visual ":'<,'>" ":")
":"
:initial-value (if in-visual "'<,'>" "")
:completion-function
(lambda (str)
(cond
Expand Down Expand Up @@ -77,10 +78,10 @@
(lem/completion-mode::completion-buffer
comp-str))))))
:history-symbol 'vi-ex
:special-keymap *ex-keymap*))))))
:special-keymap *ex-keymap*))))
(vi-visual-end)))

(defun execute-ex (string)
(let ((lem-vi-mode/ex-core:*point* (current-point)))
(prog1 (eval (parse-ex string))
(setf *last-ex-command* string)
(vi-visual-end))))
(setf *last-ex-command* string))))
2 changes: 1 addition & 1 deletion extensions/vi-mode/lem-vi-mode.asd
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
:depends-on ("core" "jump-motions" "visual" "states")
:components ((:file "utils")))
(:file "commands" :depends-on ("core" "commands-utils" "word" "visual" "jump-motions" "states" "registers"))
(:file "ex-core")
(:file "ex-core" :depends-on ("visual"))
(:file "ex-parser" :depends-on ("ex-core"))
(:file "ex-command" :depends-on ("ex-core" "options" "utils"))
(:file "ex" :depends-on ("core" "ex-parser" "visual" "registers"))
Expand Down