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

Enhances vi-mode ex :edit command to be able to revert the buffer. #1222

Merged
merged 1 commit into from
Jan 3, 2024
Merged
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
16 changes: 13 additions & 3 deletions extensions/vi-mode/ex-command.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
:expand-filename-modifiers))
(in-package :lem-vi-mode/ex-command)

(defun ex-edit (filename force)
(if (string= filename "")
(lem:revert-buffer force)
(with-jumplist
(lem:find-file (merge-pathnames (expand-filename-modifiers filename)
(uiop:getcwd))))))

(defun ex-write (range filename touch)
(case (length range)
(0 (if (string= filename "")
Expand All @@ -28,10 +35,13 @@
(ex-write range filename touch)
(lem-vi-mode/commands:vi-quit force))

(define-ex-command "^e$" (range filename)
(define-ex-command "^e(?:dit)?$" (range filename)
(declare (ignore range))
(with-jumplist
(lem:find-file (merge-pathnames (expand-filename-modifiers filename) (uiop:getcwd)))))
(ex-edit filename nil))

(define-ex-command "^e(?:dit)?!$" (range filename)
(declare (ignore range))
(ex-edit filename t))

(define-ex-command "^(w|write)$" (range filename)
(ex-write range filename t))
Expand Down