nyxt icon indicating copy to clipboard operation
nyxt copied to clipboard

Add window-local modes and global modes?

Open Ambrevar opened this issue 3 years ago • 6 comments

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?

Ambrevar avatar Aug 08 '20 10:08 Ambrevar

See #874 for a discussion.

Ambrevar avatar Aug 08 '20 10:08 Ambrevar

I think it will get confusing to have window-local modes. I would suggest buffer, and global.

jmercouris avatar Aug 08 '20 11:08 jmercouris

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.

CorruptedVor avatar Jun 23 '22 20:06 CorruptedVor

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.

Ambrevar avatar Jun 24 '22 07:06 Ambrevar

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-buffers or web-buffers? 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.

aadcg avatar Dec 06 '23 12:12 aadcg

Also note that globally shared state (vital for "global" modes) is possible via CLOS :allocation :class slot option.

aartaka avatar Dec 06 '23 13:12 aartaka