Skip to content
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

How to set default zoom level #151

Closed
intuser opened this issue Dec 3, 2018 · 13 comments
Closed

How to set default zoom level #151

intuser opened this issue Dec 3, 2018 · 13 comments

Comments

@intuser
Copy link

intuser commented Dec 3, 2018

Given my eyesight the default zoom level is much too low for me. How can I permanently set a higher one in init.lisp?

As I thought I could overwrite variable definitions, I tried to put things like the following into my init.lisp, but to no effect:

(defvar current-zoom-ratio 1.6)
(defvar zoom-ratio-default 1.6)

I also tried (setq zoom-ratio-default 1.6), again no effect.

General comment: Shouldn't things like this explained with simple examples in the documentation for simple users like me?

@Ambrevar
Copy link
Member

Ambrevar commented Dec 4, 2018 via email

@Ambrevar
Copy link
Member

Ambrevar commented Dec 4, 2018 via email

@intuser
Copy link
Author

intuser commented Dec 4, 2018

How then can I customize next so that every page is opened with the desired zoom level? Or is there any place to customize font sizes?

@jmercouris
Copy link
Member

Right, so basically what you'd have to do (since we haven't figured out minor modes yet), is define a new mode called something like zoomed-mode, and extend document-mode. From there you'd write a defmethod did-commit-navigation, and go ahead and zoom in the page whenever that happens. To retain all the functionality of document-mode's history, after you did you did-commit-navigation operations you would have to write (call-next-method).

If that doesn't make sense I can show you a brief code example :)

thanks for being so patient with us! We have a lot of bugs to solve :D

@jmercouris
Copy link
Member

The right line is (setf zoom-ratio-default 1.6) - defvar is to declare a new variable, but this is already done, so there is no need to call defvar again. - In Common Lisp, we use setf to set general variables. - Note the surrounding *: it's a naming convention for global variables. All that said, the above will only work if you press C-x C=0 (unzoom-page), not right after you load the page. @jmercouris: should we add unzoom-page to an after-load hook?

it should be possible within the current system to add a hook anywhere. So you could add a hook to did-commit-navigation, the problem is, that it would not contain any context, we would need a closure (around the hook) to know who loaded what. I think this is a problem we'll have to spend some more time thinking about before implementing a solution.

@intuser
Copy link
Author

intuser commented Dec 4, 2018

If that doesn't make sense I can show you a brief code example :)

That would be very nice.

@triclops200
Copy link

Would also like this, as I'm using a high-dpi display and everything is very small in next.

@Ambrevar
Copy link
Member

Ambrevar commented Aug 5, 2019 via email

@triclops200
Copy link

will do

@Ambrevar
Copy link
Member

At last, since ffaae9c we've got more configuration options thanks to hooks!

So now you can set the default zoom with something like

(in-package :next)

(defun my-buffer-defaults (buffer)
  (setf (zoom-ratio-default buffer) 1.1)
  (unzoom-page :buffer buffer))          ; Needed for non-web-mode buffers.

(defun my-interface-defaults ()
  (hooks:add-to-hook (hooks:object-hook *interface* 'buffer-make-hook)
                     #'my-buffer-defaults))

(hooks:add-to-hook '*after-init-hook* #'my-interface-defaults)

The hook manipulation might feel a bit cumbersome, but note that

Feel free to re-open if you have more requests regarding zooming.

@Ambrevar
Copy link
Member

For the minibuffer:

(defun my-minibuffer-defaults (minibuffer)
  (setf
   (minibuffer-line-height minibuffer) "1.0em"
   (minibuffer-font-size minibuffer) "1.0em"))

(defun my-interface-defaults ()
  (hooks:add-to-hook (hooks:object-hook *interface* 'minibuffer-make-hook)
                     #'my-minibuffer-defaults))

(hooks:add-to-hook '*after-init-hook* #'my-interface-defaults)

@aadcg
Copy link
Member

aadcg commented Sep 11, 2020

So now you can set the default zoom with something like

(in-package :next)

(defun my-buffer-defaults (buffer)
  (setf (zoom-ratio-default buffer) 1.1)
  (unzoom-page :buffer buffer))          ; Needed for non-web-mode buffers.

(defun my-interface-defaults ()
  (hooks:add-to-hook (hooks:object-hook *interface* 'buffer-make-hook)
                     #'my-buffer-defaults))

(hooks:add-to-hook '*after-init-hook* #'my-interface-defaults)

Thanks for this code snippet. This isn't working for me though. It complains about the object-hook. Can you give me hand?

I have the following hack but I'm looking for a more robust solution.

(define-configuration buffer
  ((default-modes (append '(emacs-mode my-mode) %slot-default))
   (current-zoom-ratio 2.5)))

@jmercouris
Copy link
Member

I think your solution is pretty OK actually. It zooms every time we make a new buffer. :-)

You could use the hook system indeed, but I don't believe it gets you anything in this case.

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

No branches or pull requests

5 participants