-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Add auto hide tabs feature to tabs layer #14217
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
Add auto hide tabs feature to tabs layer #14217
Conversation
I think this is better to be merged to upstream. Also, you need to use the naming convention, public function should start with "spacemacs/" |
1f340f1
to
6376f98
Compare
I agree it would be better to merge this upstream, and I proposed this before (incl a code example), but I was asked to implement the code myself. However, that was a little more tricky than just adding it as a Spacemacs feature. Therefore I simply added this code to my private centaur-tabs layer and sending this PR now was trivial. Anyway, I have created a PR upstream now. Let's see what is the reaction. |
Thats a nice addition @dalanicolai and that's why I also think this is something to be implemented on the package level to benefit the entire emacs community and not only us. If your fix is not going to get merged upstream I would consider merging this feature into the layer, but I would like to wait till there is a definitive answer from upstream. |
6376f98
to
2cec66f
Compare
Just saw that you pushed a commit to your branch, given that your PR is now waiting for 22 days in centaur-tabs-repo please give me a hint whether your PR is finished. In this case I would do a review and merge it into the layer @dalanicolai. |
As far as I remember this PR was finished and ready for merge. However, I also found the draft in #13995, to implement tab functionality in Spacemacs core. Of course this PR could still get merged so users can test/review it. (And possibly get implemented later in Spacemacs core or separate pacakge/layer?) Additionally I created another PR (#14287) to add |
layers/+emacs/tabs/funcs.el
Outdated
;; (if arg | ||
;; (centaur-tabs-backward) | ||
;; (centaur-tabs-forward)) | ||
(cond ((equal arg 'backward) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can simplify the cond
form by using pcase
instead.
(pcase arg
('backward (centaur-tabs-backward))
;; etc
)
Also, you probably can wrap the pcase
from in a let
form, and don't need to set the value of centaur-tabs-local-mode
:
(let ((centaur-tabs-local-mode 1))
(pcase arg
;; etc
))
But this assumes that centaur-tabs-local-mode
is off by default. I'm not sure about this but usually this should be true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review and the suggestions. Nice to get reminded about the pcase, I probably will remember its existence this time.
But I do not understand the suggestion about setting the centaur-tabs-local-mode 1
in the let
form. I don't remember exactly why I set this, but it looks that I just want to enable the mode, i.e. hide the tabs, before switching the buffer. Probably so that the tabs will be hidden when you switch back to it via e.g. SPC b b
. This setting should be persistent, instead of enabled only during evaluation of the let
form.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see my comments.
2cec66f
to
34cce90
Compare
So I have updated this PR with the pcase suggestion. Also I noticed that in my last previous force-push, I accidentally replaced the version that implemented the spacemacs conventions, to the older one that di not have them implemented (I probably forgot that I switched from my Ubuntu to Fedora installation, so I did not sync before the push). Anyway, I have now pushed the version including that follows the spacemacs conventions, and I think this should be ready for merge. As I mentioned in my previous comment, I do not use this functionality myself. I prefer to use the switch by |
I think this PR is very well done. @smile13241324 Is there any policy on |
Hmm good question, I think not, basically it seems it was never used within spacemacs context, I'll ask the others. |
Turns out defcustom is even prefered to defvar in modern lisp :), so feel free to use it for layer variables. |
Yes it is! We then need to redeclare all those layer variables with defcustom. Well, the only one concern is if these variables are declared as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just reviewed your PR and found two smaller issues you should fix before this can be merged.
layers/+emacs/tabs/funcs.el
Outdated
(when spacemacs-tabs-auto-hide | ||
(add-hook 'window-setup-hook 'spacemacs//tabs-timer-hide) | ||
(add-hook 'find-file-hook 'spacemacs//tabs-timer-hide) | ||
(add-hook 'change-major-mode-hook 'spacemacs//tabs-timer-hide)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No batch processing in funcs files please. This needs to be wrapped into a defun or into a specific init function. Otherwise it will cause side effects during the multi-phase loading process which expects to only find side effect free function definitions.
0c039a1
to
3c3790a
Compare
Thanks again guys for the useful feedback! So I have implemented the requested changes. Also, to keep it consistent I have converted all BUT!!! I have noticed that those variables are only created to set To solve this I think either this layer should be renamed to Let me know which approach has your preference. |
Ideally it would be great to implement tabs switch with C-tab (or C-}) that shows the tabs as long as C is pressed. However Emacs does not support key release events so this function uses a timer as a workaround. To me Emacs looks better when tabs are hidden, and also packages like pdf-continuous-scroll-mode break when tabs are shown.
3c3790a
to
e70ce2d
Compare
Okay, I have just created the aliases (to see if/how it works out). I think this has my preference. Also, I have removed most of the original I guess this is the recommended way to do it; put the I hope, regarding #13995, that this work was useful. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now.
Ideally it would be great to implement tabs switch with C-tab (or C-}) that
shows the tabs as long as C is pressed. However Emacs does not support key
release events so this function uses a timer as a workaround.
To me Emacs looks better when tabs are hidden, and also packages like
pdf-continuous-scroll-mode break when tabs are shown.