Skip to content

Remove default modes #4

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

Open
fictitiousexistence opened this issue Mar 23, 2023 · 1 comment
Open

Remove default modes #4

fictitiousexistence opened this issue Mar 23, 2023 · 1 comment

Comments

@fictitiousexistence
Copy link

Hi @aartaka !

Thanks for posting your config.

I was able to use the part in your config to define certain modes to be enabled by default like blocker and reduce tracking.

Is there a way to disable certain modes globally? There's alot I don't need like annotate, hint, bookmarks, password. But they are always enabled. I was hoping setting the default-modes would only have the ones specified enabled.

Thanks :)

@aartaka
Copy link
Owner

aartaka commented Mar 23, 2023

You can try to redefine the default-modes :around method to remove the modes added on top of the pre-defined ones by some Nyxt modes. The definition of the default-modes :around is (as part of defgeneric default-modes):

(:method :around ((buffer buffer))
  "Remove the duplicates from the `default-modes' and bring them all to a proper form.
This allows setting modes as :DARK-MODE or 'EMACS-MODE in whatever package, and
Nsymbols will find the proper symbol, unless duplicate."
  (mapcar (alex:rcurry #'resolve-user-symbol :mode (list-all-packages))
          (remove-duplicates (call-next-method)
                             ;; Modes at the beginning of the list have higher priority.
                             :from-end t)))

We can preserve most of it and remove the unneeded modes from the result:

(defmethod nyxt:default-modes :around ((buffer buffer))
  (remove-if
   #'(lambda (mode)
       ;; Adjust the list of modes here:
       (member mode '(nyxt/annotate-mode:annotate-mode
                      nyxt/bookmark-mode:bookmark-mode
                      nyxt/password-mode:password-mode)))
   (mapcar (alex:rcurry #'resolve-user-symbol :mode (list-all-packages))
           (remove-duplicates (call-next-method)
                              ;; Modes at the beginning of the list have higher priority.
                              :from-end t))))

Alternatively, you can use buffer-after-make-hook to remove the modes after they were enabled.


I believe you can go from there on your own, but feel free to ask if something's unclear :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants