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

Treemacs window is not resizable (gui) #41

Closed
ambihelical opened this issue Sep 6, 2017 · 41 comments
Closed

Treemacs window is not resizable (gui) #41

ambihelical opened this issue Sep 6, 2017 · 41 comments

Comments

@ambihelical
Copy link

Although the mouse changes when over the border between the treemacs window and others, dragging doesn't do anything. There is a message "No resizable window to left of this one" when I attempt this.
I looked for a configuration to enable resizing, but didn't find one. I'm assuming it doesn't exist.

I'm using current master (580cffb).

@Alexander-Miller
Copy link
Owner

The treemacs window has a fixed width to prevent it from changing sizes when other windows get deleted.

The width can still be changed by calling treemacs-reset-width with a prefix arg (bound to w). You can also make the window's width fully changeable, including with the mouse, by calling treemacs-toggle-fixed-width (bound to tw).

Manually resetting the width is something from the very early days of treemacs, when I didn't yet know how to freeze the width of the treemacs window, so I suppose I could flip the prefix arg behaviour to make things slightly more convenient, but the width should stay fixed. Unfreezing it will resize the treemacs window on any horizontal window configuration change.

@ambihelical
Copy link
Author

Doesn't (window-preserve-size) do this without such a lock mode? I tried it on an unlocked treemacs window, and closing a vertical split window to the right did not change its size. I could still resize with the mouse (and probably other ways), but window management did not affect it. Here are the functions I used for the experiment:

(defun me:preserve-size()
  (interactive)
  (window-preserve-size (get-buffer-window treemacs--buffer-name) t t))

(defun me:no-preserve-size()
  (interactive)
  (window-preserve-size (get-buffer-window treemacs--buffer-name) t nil))

@Alexander-Miller
Copy link
Owner

I've had a different result, the size was preserved, but only as long as I did not change the window size with the mouse. Then it's back to the old behaviour. That might be an emacs version thing - I am using a self-compiled emacs26. The preservation is also done with window parameters, which is a compatibility nightmare with packages like persp and eyebrowse (this is why I dropped treemacs' side-window status).

It may be possible to make things to make things work by advising the drag with mouse functions, but I'm reluctant to get into something this complex. How about a compromise? I could add additional keybinds to quickly/slowly change the size of the treemacs window, bount to something like C-+/M-+ & C--/M--.

@ambihelical
Copy link
Author

The setting is reset on any resizing, so some hook would need to restore it. But it sounds like there are other complications. On the compromise topic, 'tw' was the missing functionality I was looking for but couldn't find (even though I know how to look). I don't how you can improve that situation.

@Alexander-Miller
Copy link
Owner

If you tell me what terms you did look for I can at least add some aptly names aliases.

@ambihelical
Copy link
Author

ambihelical commented Sep 7, 2017

I looked for resize and enable if I remember correctly. Width didn't occur to me, but it probably should have. After thinking on it, it occurs to me that some kind of help popup could have helped if it was organized well. Something like magit's ? key or the org buffer shown when C-h m is used with ivy's mini-buffer.

@Alexander-Miller
Copy link
Owner

A hydra seems like a good fit. I'll get to making one when I'm done with #42.

@sw9
Copy link
Contributor

sw9 commented Sep 13, 2017

It appears that balance-windows is also broken by using the fixed width. Isn't is also possible to advice the delete window, split window and so on, so that the width didn't change? I vaguely recall some other packages taking this approach. Though looking at neotree, looks like they took the approach of defadvice mouse-drag-vertical-line and balance-windows instead.

@Alexander-Miller
Copy link
Owner

Now with these kind of issues I definitely need a new approach. Judging by a quick test window-configuration-change-hook seems like a good place to go. Setting treemacs up there means it's generally compatible with whatever functions delete or create windows, though width still needs to be changed manually.
I'll make pushing a patch for this a priority.

@Alexander-Miller
Copy link
Owner

Patch is pushed. Behaviour should be the same, except without the problems with functions like balance-windows.

@Alexander-Miller
Copy link
Owner

Hydra is pushed now as well. It's bound to H and it should show you the most important keybinds, including any changed you made (and be probably aligned as well).

@sw9
Copy link
Contributor

sw9 commented Sep 14, 2017

Need to require hydra. Also, I think you need to add a couple more spaces so that the columns line up properly. Dunno if it's just me.

@Alexander-Miller
Copy link
Owner

It's supposed to look like this. Can you post a screenshot of what it looks like for you?

@sw9
Copy link
Contributor

sw9 commented Sep 15, 2017

screen shot 2017-09-15 at 2 58 50 pm

@sw9
Copy link
Contributor

sw9 commented Sep 15, 2017

Ah, I see the problem, I changed the keybinding for moving root. Nevermind.

@Alexander-Miller
Copy link
Owner

Well I mind anyway. It should still look properly aligned, unless you go for some overly long C-x M-y z combination, which I hope no one is crazy enough to do.

I've now pushed a patch that'll abridge <left> & <right> to LEFT & RIGHT.

@sw9
Copy link
Contributor

sw9 commented Sep 15, 2017

Long term though, I think using columns is a cleaner way: https://github.com/abo-abo/hydra/wiki/internals#column

@Alexander-Miller
Copy link
Owner

Can't believe I missed that part. Thanks, I'll look into it.

@Alexander-Miller
Copy link
Owner

Tried the columns now, but they were misaligned, had empty filler entries in the shorter columns and lack the nice looking unicode bars and propertized strings I use. Guess I'll stick with the status quo for now.

@ambihelical What do you think, would you have quickly found how to change the window size if the helpful hydra had been around when you started looking?

@sw9
Copy link
Contributor

sw9 commented Sep 16, 2017

Do you have a screenshot of it using columns and what that looks like? Not sure what you mean by empty filler entries. Kinda interested in playing around with that code as well.

Personally, I'm just used to describe-mode since that works everywhere, but maybe it's helpful for new users? Also, I guess I see hydras as more of way to enter and exit modes/states that saves you keystrokes as opposed to feature discovery.

@ambihelical
Copy link
Author

If I had found the hydra, I think I would have found the toggle. I think ? would be more discoverable then H though, and consistent with magit, dired and probably others, even if evil users would lose their backward search binding (not a huge loss for this mode). BTW, M-k description has a typo.

@Alexander-Miller
Copy link
Owner

Do you have a screenshot of it using columns and what that looks like?

Here's what the example from the wiki looks like. All columns but the first have at least one filler entry.

Also, I guess I see hydras as more of way to enter and exit modes/states that saves you keystrokes as opposed to feature discovery.

Yeah, I'm putting the hydra on its head here. I just want a nice menu to quickly look up keybinds and features, like resizing the window. Just like describe-mode, but in a pretty table that fits into the minibuffer. Spacemacs does that quite often, but calls it a transient state.

and consistent with magit, dired and probably others

I put in on H because of evil, but everyone else going with ? is good enough an argument for me, so I'll change it.

M-k description has a typo.

Fixed.

@sw9
Copy link
Contributor

sw9 commented Sep 17, 2017

That's weird, here's how it looks for me: . Maybe there's something wrong with your version of hydra?

That said, I'm really digging the unicode table, looks so much cleaner, even though having to manually align everything feels kinda hacky.

@Alexander-Miller
Copy link
Owner

Maybe there's something wrong with your version of hydra?

Just tried pulling a new version. I'm at hydra-20170903.218 now, and it's still misaligned. It does work correctly with emacs -Q, so it's probably some spacemacs interference.

That said, I'm really digging the unicode table, looks so much cleaner, even though having to manually align everything feels kinda hacky.

Lucky for you all the hacky manual alignment falls on me. And I think the good looks are worth some manual corrections from time to time. I don't think I'll be adding that many new keybound features that this'll become a serious annoyance. Treemacs doesn't lack in features, but it could use some better UX and discoverability, and a nice looking comprehensive help window is great for both.

@Alexander-Miller
Copy link
Owner

The hydra's taken care of the issue of discoverability now, so I'll close up here.

@didibus
Copy link

didibus commented Jan 24, 2019

I'm not sure I understand what treemacs-toggle-fixed-width does? In my case, no matter if it is locked or unlocked, I still can't resize its width using the mouse, and I can always resize the width using treemacs-set-width?

@Alexander-Miller
Copy link
Owner

Looks like that feature didn't work for a while, you're just the first to tell me about it. Should be fixed with 82ba951.

@andreyorst
Copy link

Looks like that feature didn't work for a while, you're just the first to tell me about it. Should be fixed with 82ba951.

Seems that it doesn't work for me. Unlocking width with tw and trying to resize resize another window, but treemacs stays the same width:

Before resize:
image

After resize:
image

Rightmost window increased it's size, and treemacs is the same as before.

@Alexander-Miller
Copy link
Owner

Alexander-Miller commented May 27, 2019 via email

@andreyorst
Copy link

andreyorst commented May 27, 2019

Unlocking the width means that you can change the size of treemacs
directly with the mouse

Which I can't do actually, as shown above. When I resize Treemacs with mouse, it doesn't get resized, but another window does. And enlarge-window-horizontally doesn't do anything, since Treemacs goes back to it's defined width immediately.

One more question. Is there any command that could temporarily increase Treemacs width to maximum? Our project has deeply nested structure and pretty much all the time filenames are not visible with sensible width of Treemacs.

@Alexander-Miller
Copy link
Owner

Alexander-Miller commented May 27, 2019 via email

@andreyorst
Copy link

Does it work if you run this:

(with-selected-window (treemacs-get-local-window)
  (setq treemacs--width-is-locked nil
        window-size-fixed nil))

No.

This is what it like for me: https://imgur.com/a/JKgZjyi

Interesting. This is what it looks like on my PC: https://imgur.com/a/SEEvT1v
I was dragging borders with mouse but pointer didn't recorded for some reason.

My configuration is simple:

(use-package treemacs
  :commands (treemacs
             treemacs-follow-mode
             treemacs-filewatch-mode
             treemacs-fringe-indicator-mode)
  :bind (("<f8>" . treemacs)
         ("<f9>" . treemacs-select-window))
  :init
  (when window-system
    (setq treemacs-width 27
          treemacs-is-never-other-window t
          treemacs-indentation 0
          treemacs-space-between-root-nodes nil)
    (treemacs-follow-mode t)
    (treemacs-filewatch-mode t)
    (treemacs-fringe-indicator-mode nil)
    (treemacs)
    (other-window 1)))

@andreyorst
Copy link

andreyorst commented May 27, 2019

Found it. Which Key configuration causing this issue:

(use-package which-key
  :commands which-key-mode
  :init
  (which-key-mode))

Removing this snippet, or disabling which-key-mode fixes issue for me. But I don't want to loose which-key functionality. Perhaps fix for this issue is related to my problem #376

@Alexander-Miller
Copy link
Owner

Alexander-Miller commented May 27, 2019 via email

@bk138
Copy link

bk138 commented Aug 15, 2019

@Alexander-Miller Is there a possible configuration that makes the Treemacs window resizable per default from emacs' start on?
I played around with treemacs-toggle-fixed-width in my init file: the Treemacs window is resizable with the mouse then, but takes up half of the frame width no matter what size is configured.

@andreyorst
Copy link

It also would be nice if treemacs could become re-sizable when user attempts to resize, but after resize it will use fixed size, so treemacs couldn't be resized by resizing the frame.

@Alexander-Miller
Copy link
Owner

I'll take it up in #514.

@hongyi-zhao
Copy link

Found it. Which Key configuration causing this issue:

(use-package which-key
  :commands which-key-mode
  :init
  (which-key-mode))

Removing this snippet, or disabling which-key-mode fixes issue for me. But I don't want to loose which-key functionality. Perhaps fix for this issue is related to my problem #376

I can't reproduce this problem with the latest versions of which-key and treemacs.

@goldfita
Copy link

I also can't get treemacs-toggle-fixed-width to work (version 0.4). The function treemacs-set-width only seems to work when the treemacs window is selected. How can you make it work from use-package?

@goldfita
Copy link

goldfita commented Sep 6, 2022

Now that I've looked at the code, I see that treemacs-set-width does not take a parameter to set the size; it only reads from input. The correct way to do this is with the customizations:

  (treemacs-width-is-initially-locked nil)
  (treemacs-width 40)

You can also adjust the size in increments with 'shift-<' and 'shift->'.

@Alexander-Miller
Copy link
Owner

Another potentially useful feature is treemacs-fit-window-width, bound to =. It'll make sure that the treemacs window is large (or small) enough to exactly fit its entire content.

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

8 participants