takaxp / moom

A Moom port to Emacs - Make your dominant hand FREE from your mouse
GNU General Public License v3.0
79 stars 3 forks source link

window fill shifts off screen; toggle needs an option; missing moom-fill-height #17

Closed notuntoward closed 3 years ago

notuntoward commented 3 years ago

Thanks for distributing moom-- it's a much needed replacement for the now deprecated frame-cmds package.

Here are some thing I've discovered about it:

  1. M-x moom-fill-height is missing. It's in the documentation, though. This is very the function I was looking for.
  2. M-x moom-move-frame-to-edge-left moves the frame slightly off the screen. The screenshot is of the left edge of the screen after running this command.
  3. M-x moom-fill-screen does expand the frame but doesn't position it so that it fills the screen
  4. Commands that change the frame size change fonts unpredicatable, so you don't know ahead of time if you should run M-x moom-toggle-font-module. A customization that always turned font scaling off would solve this problem.

This is with emacs 27.1 on Windows 10

image

takaxp commented 3 years ago

As a quick response to No.2, could you try to use moom-user-margin to remove the offset in your environment, probably (setq moom-user-margin '(0 0 16 0)). Supporting w32 needs still improvement.

If you use '(0 0 16 -16) for the value, I think No.3 will also be resolved.

Additionally, version 1.4.3 now supports moom-fill-height as you requested.

Also I added moom-use-font-module to disable font module even if moom-font.el exisits from version 1.4.8.

So, I fixed an issue you reported regarding No. 1 and 2. Could you try version 1.4.9 without moom-user-margin configuration that I mentioned above. Note: If you use dual monitors, you may have to configure moom-user-margin for some adjustments.

notuntoward commented 3 years ago

Thanks for the changes.

  1. I can now run M-x moom-fill-height, and it does increase the frame to (close to) full height, but it still doesn't position it so that the top edge of the screen is at the top edge of the monitor. It seems that anybody who calls this command would want the positioning to happen when you run it.
  2. moom-user-margin doesn't seem to have an effect. I left it at the default customization (t), and my understanding is that then, M-x moom-fill-screen should fill the screen with the frame without changing the font. But it does change the font. I tried customizing moom-user-margin to nil but this didn't change the behavior.
  3. running (setq moom-user-margin '(0 0 16 0)) does do something. But now M-x moom-move-frame-to-edge-left undershoots the frame edge (screenshot)

image

takaxp commented 3 years ago

I believe the latest version 1.4.9 will do correct at least in my test environment (Windows 10, 27.1 installed from zip). So I need some clarifications to resolve your issue.

Could you try the following configurations in your init.el?

(when (require 'moom nil t)
  (setq moom-verbose t)
  (setq moom-use-font-module nil)
  (setq moom-user-margin '(0 0 0 0)) ;; FYI, the default value is '(0 0 0 0), not t
  (moom-mode 1))

A. M-x moom-move-frame

This will bring the frame to the top left corner of your screen. If you see some spaces between top edge and left edge, then moom-user-margin should be adjusted in your init.el. The last image that you kindly provided, it seems that it requires '(-56 0 -16 0) but this adjustment highly depends on user environments, so each value would be incorrect. Note: the 4 values represent the margin from {top, bottom, left, right} in order.

B. M-x moom-fill-screen

After the attempt of "A" described above, then please try to call moom-fill-screen. If the adjustment of moom-user-margin is good, then the screen will be filled as you expected. If not, please change the user margin again in terms of margins from bottom and right edge. M-x moom-reset will help you to avoid restart your Emacs.

Now I understand the confusion on moom-fill-screen. The command will expand the frame to fill the screen but actually the position will not be changed. I'll release updated version after resolving the margin adjustment issue in this thread. If you want to use such feature now, please add the following code to your init.el.

(add-hook 'moom-before-fill-screen-hook #'moom-move-frame)

C. M-: (moom-check-user-margin '(0 0 0 0))

moom-check-user-margin could help you to find the appropriate values of moom-user-margin. The command is NOT interactive so please eval the command in minibuffer.

D. moom-use-font-module

If you configure moom-use-font-module to nil before calling (moom-mode 1) in you init.el as I described above. I believe font size will never be changed. If the font size is changed in your side, please give me information in detail so that I will try to reproduce it.

takaxp commented 3 years ago

FYI: You can also use M-x moom-toggle-frame-maximized instead of M-x moom-fill-screen.

notuntoward commented 3 years ago

Thanks, are you planning to put 1.49 on melpa?

takaxp commented 3 years ago

Yeap, 1.4.9 is already downloadable as 20210216.1044 from MELPA. Normally the latest version will automatically be registered in MELPA with a delay about half a day.

notuntoward commented 3 years ago

moom-toggle-frame-maximizedis great -- with your suggestions, the margins are correct and the fonts don't change. It's a really nice way to quickly open up the emacs view and then when I've found what I'm looking for, to shrink the frame back to exactly where it was before.

Would it be possible to have a moom-fill-height-toggle? By that I mean, "set the height to vertically fill the screen and set the position to the top screen edge. And then be able to toggle it back to where it was."

This is the operation I'd use the most, if it was available.

The below almost works -- the only problem is that moom-fill-height makes the frame a few pixels too tall (the screenshot below shows result of M-x moom-fill-height. Any suggestions? Does this code break anything?

(setq moom--height-maximized nil)

(defun moom-toggle-frame-height-maximized ()
  "Toggle frame height maximized."
  (interactive)
  (let ((moom--print-status nil))
    (if (setq moom--height-maximized (not moom--height-maximized))
        (progn
          (moom--save-last-status)
          (moom-move-frame-to-edge-top)
          (moom-fill-height))
      (moom-restore-last-status)))
  (moom-print-status))

image

takaxp commented 3 years ago

I think the code seems good and now it is a time to configure moom-user-margin but if do so it would break a covered screen area when togging moom-toggle-frame-maximized. But I'm not sure, could you just try to customize moom-user-magrin?

I'm currently little bit nervous to add toggle commands as you suggested because I'm planning to provide an undo feature for each command in a unified way.

BTW, I use moom-cycle-frame-height to fill height. The command will change frame height in 4 steps as default like {1/4, 1/2, 3/4, 4/4}. You can change the number of steps by M-: (moom-update-height-steps 2) but currently the minimum step is limited to greater than 1. Honestly speaking I like this command.

notuntoward commented 3 years ago

Yes, if you're planning a general undo mechanism, then it certainly doesn't make sense to add more toggles.

About the need to set pixel user-margins, though, this can be problematic across multiple machines. For example, I directly use or remotely log into four different computers, each with different screen sizes, resolutions and fonts.

Somehow, standard emacs handles this without me setting pixel margins for each new machine. The instance where this is most clear is frame handling on startup. In my emacs config file, I have the line:

(add-to-list 'default-frame-alist '(fullscreen . fullheight)) ; startup at full height

This vertically maximizes and perfectly positions the initial startup frame without any other parameters. But unfortunately, after startup, there is no similar interactive function for vertical frame maximization. Emacs must have the interface to do this, but I haven't been able to find it. `

takaxp commented 3 years ago

I have checked the moom-toggle-frame-height-maximized in my environment. It performed as I expected and I found a few pixel space between bottom edge, i.e. 3 pixel I think. Moreover, moom-toggle-frame-maximized has also same a few pixel space. So I believe it is good idea to add the default margins for Windows 10, i.e. '(0 -3 0 0). Actually I'm using the margin as moom-user-margin for my machine.

If it is integrated as the default margins for Windows 10, then I believe you don't need any adjustments in every machine at least Windows 10. What do you think? If you agree this idea, I'll make this change in the next release but before to do so I need some comments from you to clarify.

A. bottom margin

According to your report, the margin, a few pixel between bottom edge, appears in moom-toggle-frame-height-maximized but not for moom-toggle-frame-height-maximized. When I tested that moom-toggle-frame-height-maximized had the same a few pixel space between bottom edge. Could you verify again?

B. appropriate value for the margin

In my environment, 3 pixel is the best value to integrate as the default value for Windows 10. If you think it should be 4 or other value, please let me know. I'll adopt the value because you are the best Moom user :)

takaxp commented 3 years ago

FYI: version 1.4.10 is released at 2021-02-21 05:00(UTC). The release includes some updates on moom-fill-screen and moom-fill-height. Both commands now automatically move to the top edge of screen as we discussed in this thread. Thank you for remarkable catch up.

takaxp commented 3 years ago

'(0 -3 0 0) is selected as the new default margin for w32. If you have further comments, please create a new issue.