Skip to content

Commit

Permalink
Adds vi-mode ex command :read.
Browse files Browse the repository at this point in the history
  • Loading branch information
mychris committed Jan 2, 2024
1 parent d3aa2e6 commit 6d6b433
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions extensions/vi-mode/ex-command.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,26 @@
(lem:show-message (format nil "~A: ~S" option-name (encode-value option-value))
:timeout 10))))))

(define-ex-command "^r(?:e|ead)?$" (range filename)
;; TODO: range currently does not distinguish between :0 and :1.
;; This makes it impossible to insert at the beginning of the file
(cond
((string= "" filename)
(lem:message "No file name"))
((char= #\! (char filename 0))
(lem:message "Command execution not supported"))
(t
(let ((insert-point (case (length range)
(0 (lem:current-point))
(1 (first range))
(2 (lem:point-max (first range) (second range))))))
(lem:move-point (lem:current-point) insert-point)
(lem:line-start (lem:current-point))
(unless (lem:line-offset (lem:current-point) 1)
(lem:line-end (lem:current-point))
(lem:newline))
(lem:insert-file-contents (lem:current-point) filename)))))

(define-ex-command "^cd$" (range new-directory)
(declare (ignore range))
(let ((new-directory (change-directory (expand-filename-modifiers new-directory))))
Expand Down

0 comments on commit 6d6b433

Please sign in to comment.