nyxt
nyxt copied to clipboard
Add window-local modes and global modes?
Currently our modes are buffer-local. What about window-local modes, or global modes?
For instance, say we want to have a way to change all the paths of bookmarks, cookies, etc. We could do this in the command, but this would not save any state and it would not allow us to revert the change.
With modes, we essentially create of a list of states which are all reversible.
Thoughts?
See #874 for a discussion.
I think it will get confusing to have window-local modes. I would suggest buffer, and global.
I think it will get confusing to have window-local modes. I would suggest buffer, and global.
I agree, but just in case someone would decide to have several windows for different purposes, I would say why hinder that use case? If you don't need it you don't use it.
We've refactored our mode API dramatically for 3.0, so we will keep playing with what we have for a while until we get a better picture of how we can generalize it to windows. Something for 4.0 then!
For the time being, we have hooks and we can leverage those to automatically toggle modes on a per-window basis.
I consider the idea of window-local modes to be a wild experiment. It can be done, but that doesn't mean that Nyxt should provide or maintain that functionality out of the box.
With regards to local and global modes, note all of our mode togglers are local. Setting modes globally (meaning, for all instances of a buffer type), requires adding statements to the config file as shown below. Note that a truly "global" mode is rather exotic and odd notion in Nyxt, in the sense that there are very few modes that would make sense to be enabled for all "UI buffers" (message, status, prompt, web).
Could we have commands that toggle modes "globally"? Yes, but "global" is a tricky notion as explained above. For example, what would be target buffer when enabling emacs-mode
? input-buffer
s or web-buffer
s? Therefore, I think the best way would be for each mode to define it's own "global" toggler command, e.x. global-emacs-mode
, when sensible. The modes that have no local toggler most likely don't need a global one either.
(define-configuration buffer-class-foo
((default-modes (append '(foo-mode
bar-mode)
%slot-value%))))
(define-configuration buffer-class-bar
((default-modes (append '(foo-mode
bar-mode)
%slot-value%))))
Regardless, this is rather low priority right now.
Also note that globally shared state (vital for "global" modes) is possible via CLOS :allocation :class
slot option.