Introduce Vim's options feature, and add :set & :cd#908
Introduce Vim's options feature, and add :set & :cd#908cxxxr merged 13 commits intolem-project:mainfrom
:set & :cd#908Conversation
… 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
cxxxr
left a comment
There was a problem hiding this comment.
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.
What about using show-message instead of message and message-timeout?
(lem:show-message (format ...) :timeout ...)
extensions/vi-mode/core.lisp
Outdated
| :lem | ||
| :lem/universal-argument) | ||
| (:import-from :cl-package-locks) | ||
| (:import-from #:cl-ppcre) |
There was a problem hiding this comment.
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.
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.
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.
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
:ecommand 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
autochdiroption onSet
autochdirtotin yourinit.lisp:To change the option temporarily, just execute
:set autochdir(and:set noautochdirto turn off).A2. Change the current directory manually
Use
:cdcommand to change the directory manually:Changes
autochdiris implemented:e(find-file) or switching the buffer/window:eto the current directory:cd:cd %:hmoves to the current buffer's directory (See "filename modifiers" below)autochdiroption 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:cdfor changing the current directory:cd <dir>moves to the<dir>:cdmoves to the home directory:cd -moves to the previous directory:set(also:seworks):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)