-
Notifications
You must be signed in to change notification settings - Fork 158
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
buffer-list-update-hook misbehaves when selecting file via treemacs #1076
Comments
Difficult to say. buffer-list-update-hook is called in a lot of places and treemacs does a lot of context switching to move around. You can try adding a call to If you're only setting read-only mode at the start you can also try using find-file-hook instead. |
I've used post-command-hook specific for this instead, though it's not performance-wise, after trying lots of other hooks, this is the only one that works. And thanks for the replay and patience, thank you |
Problem solved!!! I just set the Here's what I did after tons of attempts:
Heck, I really don't know what happened, but it worked. Could someone possibly explain this? Edit: Not acutally, solving this problem created another problem, now, switching between two windows that two are not and are in read-only-mode, cursor color cannot change according to it... Edit2: In addition to the above premise, adding the function to 'add-hook 'window-state-change-hook' now works for switching between windows.
That's so weird, since I've used |
It is more complex than I thought. Without adding my defined function Today, I encountered another package that caused cursor unable to switch color based on read-only-mode, unless I added the function to So, Could you please explain how to use |
Just add a call to backtrace anywhere into your code, all it does is print a full stack trace that lead to it being called, so you know what caused the hook to be run. You'll also want to get rid of it again after the first time it was triggered in the instance you want to investigate, otherwise it'll keep spamming stack traces as you're navigating around. |
This issue has been automatically marked as stale because it has not had recent activity (this bot only works as a reminder, it will not close issues). |
I have a function to change cursor color red/blue when read-only-mode is enabled/disabled in a buffer, and have it added to the hooks "buffer-list-update-hook", also a defind hook for (load-theme) and "read-only-mode-hook".
So, each time when I enter/leave read-only-mode or switch to a buffer thtat's enabled with read-only-mode or not, I'll have the cursor color changed respectively.
Also, the "read-only-mode" is added to the hooks "org-mode-hook" & "prog-mode-hook", which makes, org and source code files open with read-only-mode by default.
Now, while it works fine with (find-file)/C-x-f to open all the org/source-code files with red cursor color, but when I use treemacs to hit enter for some org/source coe files, the cursor once turns to red, but soon, it turns back to blue?? And treemacs works fine for most org file and source codef files, though.
After that file has been first time opened, when I select it again via treemacs, it works fine now even to open it again after it's closed.
Here's the config:
A demo: Pay attention to 0:03 to 0:06 when the file was opened, the cursor changed from red to blue.
treemacs-issue2.mp4
Any ideas?
The text was updated successfully, but these errors were encountered: