Change the behavior to close the window when q is pressed during read-only.
The M-q is responsible for exiting the mode or closing the window depending on the context.
We would also like to have the same behavior by pressing q during read-only.
Perhaps it would be better to bind to delete-active-window.
buffer-read-only-p: Returns true if the buffer of the argument is read-only.
process-input-character: A method that processes input characters. The first argument is a character, which can be dispatched with the eql method specializer for specific processing.
I think I have a solution for this: using the functions you provided and some others from the same package, I was able to define the following in my config (but I imagine it could be included in src/commands/buffer.lisp):
(define-command close-buffer-if-read-only () ()
(let* ((current (lem/buffer/internal::current-buffer))
(is-read-only (buffer-read-only-p current)))
(if is-read-only
(delete-active-window)
(self-insert))))
(define-key lem:*global-keymap* "q" 'close-buffer-if-read-only)
I figured that to try to implement this at any level lower than this would be more work for more problems. By implementing it as a command and a keybinding, users can change the keybind as they would with other commands. I saw no reason to treat this functionality as unique from other commands, but let me know if you want something a bit different. If such a specialized command is not something you want, you could implement the functionality of the command as a function that won't get exposed to the user in the command popup.
I've tried to open a pull request, But it says I have to be a collaborator to do so, so I'm posting my code here.
I figured that to try to implement this at any level lower than this would be more work for more problems
I would like this solution, re-use the keymap facility and pre-define a new command for this purpose.
The keymap just dispatch the input message from the user devices, and the commands do the actual things.
This issue has been inactive for {days} days. If there is no activity within the next 14 days, it will be automatically closed. Please add a comment if it is still relevant.
Closing this issue due to inactivity. Please reopen or create a new issue if the problem persists.