-
-
Notifications
You must be signed in to change notification settings - Fork 179
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
Introduce Vim's options feature, and add :set
& :cd
#908
Conversation
… file in vi-mode. Related ex commands are :e, :vs, and :sp.
We may need filename modifiers, too, like |
8a7f79d
to
1ca2a33
Compare
1ca2a33
to
1756e7b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR.
I made a few petty comments, but it seems like a very good change.
extensions/vi-mode/ex-command.lisp
Outdated
(let ((lem-core::*message-timeout* 10)) | ||
(if (and isset | ||
(not (equal option-value old-value))) | ||
(lem:message "~A: ~S => ~S" option-name old-value option-value) | ||
(lem:message "~A: ~S" option-name option-value))))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about using show-message instead of message and message-timeout?
(lem:show-message (format ...) :timeout ...)
extensions/vi-mode/core.lisp
Outdated
@@ -3,6 +3,7 @@ | |||
:lem | |||
:lem/universal-argument) | |||
(:import-from :cl-package-locks) | |||
(:import-from #:cl-ppcre) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we use keywords for package-designator in this project, so it would be nice to see it unified.
(lem:add-hook lem:*find-file-hook* 'auto-change-directory) | ||
(dolist (window (lem:window-list)) | ||
(lem:add-hook (lem-core::window-switch-to-buffer-hook window) 'auto-change-directory) | ||
(lem:add-hook (lem-core:window-leave-hook window) 'auto-change-directory))) | ||
(progn | ||
(lem:remove-hook lem:*find-file-hook* 'auto-change-directory) | ||
(dolist (window (lem:window-list)) | ||
(lem:remove-hook (lem-core::window-switch-to-buffer-hook window) 'auto-change-directory) | ||
(lem:remove-hook (lem-core:window-leave-hook window) 'auto-change-directory)))))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps there is an issue that does not apply to windows that are split after this.
It might be a good idea to have the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried some cases on my machine, but it seems to be working. I don't know why.
extensions/vi-mode/options.lisp
Outdated
(gethash name *options*) | ||
(when (and (null exists) | ||
error-if-not-exists) | ||
(error "Unknown option: ~A" name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error is handled as an internal error.
Instead of treating user input as an internal error, it may be better to use editor-error or a condition that inherits from it.
Please let me know when you are done making changes. |
I think it's good. |
Also, stop defining functions for each options, because 'number' conflicts with the 'cl' package. (ref lem-project#908)
Also, stop defining functions for each option, because 'number' conflicts with the 'cl' package. (ref lem-project#908)
Quick troubleshooting
Q. Why does the
:e
command no longer complete from the directory of the file being edited?It is to make Lem's vi-mode closer to Vim's behavior. If you prefer the previous behavior, there's 2 options to achieve:
A1. Turn
autochdir
option onSet
autochdir
tot
in yourinit.lisp
:To change the option temporarily, just execute
:set autochdir
(and:set noautochdir
to turn off).A2. Change the current directory manually
Use
:cd
command to change the directory manually:Changes
autochdir
is implemented:e
(find-file
) or switching the buffer/window:e
to the current directory:cd
:cd %:h
moves to the current buffer's directory (See "filename modifiers" below)autochdir
option on:e
,:vs
,:sp
, and:cd
%
: The current buffer's file path%:p
: The absolute pathname of the current buffer's file path%:h
: The current buffer's directory%:e
: The file extension of the current buffer's file%:t
: The filename of the current buffer's file%:r
: The root of the filename:cd
for changing the current directory:cd <dir>
moves to the<dir>
:cd
moves to the home directory:cd -
moves to the previous directory:set
(also:se
works):set autochdir
,:set acd
,:set acd=t
:set noautochdir
,:set noacd
,:set acd=nil
:set invautochdir
,:set autochdir!
,:set invacd
,:set acd!
:set autochdir
,:set acd?
:set autochdir&
,:set acd&
init.lisp
(setf (lem-vi-mode:autochdir) t)