-
Notifications
You must be signed in to change notification settings - Fork 156
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
Show workspace name in doom-modeline #1049
Show workspace name in doom-modeline #1049
Conversation
Testing locally, get the following. I think there's some more things that need catching @sebastiaanspeck
|
I also tested it by patching my local treemacs - it behaves still the same (no output all) when using natively compiled. |
Same here. EDIT: Actually, for some reason I ignored the last commit (sorry!) and with that commit it works on my machine. |
Ahh! I’ve also pushed a new workaround. Can some people test it? |
#1050 solves it for me. |
Latest push produces
The commit prior seems to have worked at first blush, but switching workspaces throws up the same error. |
Yep.. that's just the code how it was prior my proposed change to show the current workspace name in the modeline. Sad to see that my workarounds doesn't fix the issues. I've opened a issue on doom-modeline as the issue is purely related to the name you have to give to the segment and you can't use a string or symbol.. Maybe we need to merge #1050 for now and search for a good, clean and working solution together? |
Sad to hear it only works for the first time ::/ |
edited: edited 2: (with-no-warnings
(eval-and-compile
(doom-modeline-def-segment treemacs
... |
Revert until #1049 has a working solution that also works with native compilation
After a few tries I found a solution (use ((fboundp 'doom-modeline)
(eval-and-compile
(require 'doom-modeline)
(doom-modeline-def-segment treemacs
"Display treemacs."
(propertize (format " %s " (treemacs-workspace->name (treemacs-current-workspace)))
'face (doom-modeline-face 'doom-modeline-buffer-minor-mode)))
(doom-modeline-def-modeline 'treemacs '(bar " " major-mode) '(treemacs))
(doom-modeline 'treemacs))) It works without any warning in various cases. Please have a try! |
This needs to be tested by others before merging another breaking change. It works on my machine :) Needs to be tested without doom-modeline installed as well, since the GitHub Actions fail on line |
Should load |
src/elisp/treemacs-mode.el
Outdated
(doom-modeline 'treemacs)) | ||
((fboundp 'doom-modeline) | ||
(eval-and-compile | ||
(require 'doom-modeline) |
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.
Should use with-eval-after-load
instead of require
since doom-modeline
is not a dependency.
I think eval-and-compile
is not necessary.
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.
((and (fboundp 'doom-modeline)
(fboundp 'doom-modeline-def-segment)
(fboundp 'doom-modeline-face)
(fboundp 'doom-modeline-def-modeline))
(with-eval-after-load 'doom-modeline)
(doom-modeline-def-segment treemacs-workspace-name
"Display treemacs workspace name."
(propertize (format " %s " (treemacs-workspace->name (treemacs-current-workspace)))
'face (doom-modeline-face 'doom-modeline-buffer-minor-mode)))
(doom-modeline-def-modeline 'treemacs '(bar " " major-mode) '(treemacs-workspace-name))
(doom-modeline 'treemacs))
This triggers reference to free variable 'treemacs-workspace-name'
again...
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.
((fboundp 'doom-modeline)
(with-eval-after-load 'doom-modeline
(doom-modeline-def-segment treemacs
"Display treemacs."
(propertize (format " %s " (treemacs-workspace->name (treemacs-current-workspace)))
'face (doom-modeline-face 'doom-modeline-buffer-minor-mode)))
(doom-modeline-def-modeline 'treemacs '(bar " " major-mode) '(treemacs))
(doom-modeline 'treemacs))
)
Got this error
Debugger entered--Lisp error: (void-variable treemacs)
#<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_8>()
eval-after-load(doom-modeline #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_8>)
treemacs--setup-mode-line()
#f(compiled-function () (interactive nil) #<bytecode -0x1b2d643fdaa15b7>)()
treemacs--mode-check-advice(#f(compiled-function () (interactive nil) #<bytecode -0x1b2d643fdaa15b7>))
apply(treemacs--mode-check-advice #f(compiled-function () (interactive nil) #<bytecode -0x1b2d643fdaa15b7>) nil)
treemacs-mode()
I think we need eval-and-compile
and require
because we need expand doom-modeline-def-segment
macro.
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.
If doom-modeline
is byte-compiled and loaded before treemacs
, no such errors occur, I think.
Oh yes, I forgot this, and we should ignore warnings if doom-modeline is not installed. ((fboundp 'doom-modeline)
(eval-and-compile
(require 'doom-modeline nil 'noerror))
(with-no-warnings
(doom-modeline-def-segment treemacs
"Display treemacs."
(propertize (format " %s " (treemacs-workspace->name (treemacs-current-workspace)))
'face (doom-modeline-face 'doom-modeline-buffer-minor-mode)))
(doom-modeline-def-modeline 'treemacs '(bar " " major-mode) '(treemacs)))
(doom-modeline 'treemacs)) |
Latest commit works for me (and GitHub Actions), so please test and review 🙌 |
Try this: ((eval-and-compile (require 'doom-modeline nil 'noerror))
(doom-modeline-def-segment treemacs
"Display treemacs."
(propertize (format " %s " (treemacs-workspace->name (treemacs-current-workspace)))
'face (doom-modeline-face 'doom-modeline-buffer-minor-mode)))
(doom-modeline-def-modeline 'treemacs '(bar " " major-mode) '(treemacs))
(doom-modeline 'treemacs)) |
I've updated the snippet. Try it. |
|
It does for me as well, but the |
Looks to be working fine for me :) |
Thank you for testing, let's launch the 🚀 and merge this! |
All right, let's do this 🤞 |
8be5913
into
Alexander-Miller:master
The current `doom-modeline` shows the current workspace name in `treemacs` since Alexander-Miller/treemacs#1049, thus making the `doom-modeline` useful again.
Fixes #1047 and #1048