diff --git a/extensions/vi-mode/ex-core.lisp b/extensions/vi-mode/ex-core.lisp index f80c2a79e..c1d9cb381 100644 --- a/extensions/vi-mode/ex-core.lisp +++ b/extensions/vi-mode/ex-core.lisp @@ -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 @@ -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))) diff --git a/extensions/vi-mode/ex-parser.lisp b/extensions/vi-mode/ex-parser.lisp index 36c87724b..c111917e7 100644 --- a/extensions/vi-mode/ex-parser.lisp +++ b/extensions/vi-mode/ex-parser.lisp @@ -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))) diff --git a/extensions/vi-mode/ex.lisp b/extensions/vi-mode/ex.lisp index e73cf01d2..b3549d0b2 100644 --- a/extensions/vi-mode/ex.lisp +++ b/extensions/vi-mode/ex.lisp @@ -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 @@ -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)))) diff --git a/extensions/vi-mode/lem-vi-mode.asd b/extensions/vi-mode/lem-vi-mode.asd index f27768835..4c441f017 100644 --- a/extensions/vi-mode/lem-vi-mode.asd +++ b/extensions/vi-mode/lem-vi-mode.asd @@ -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"))