Comments (21)
Well, I have to say it's as designed. You need this config.
(setq find-file-visit-truename t)
If the file is controlled by vc, refer to vc-follow-symlinks
, please.
from doom-modeline.
Thank you for the help!
from doom-modeline.
I realize that this issue was closed and that the solution find-file-vist-truename
worked for OP, but I do not want to change the behavior of my editor to fix the path in the modeline. Nearly every file I use is a symlink to a NFS so my modeline has become very long and cluttered. I want to visit the symlink and not the true path. I have a hacked the code in my doom-modeline repo to fix this, but I was wondering if you would be open to making this an optional feature that could be disabled to restore a saner path. I could put together a PR if that would be helpful.
from doom-modeline.
@CeleritasCelery Well, thank you for the comments. Can you please share your codes? PR is always welcome as long as it makes sense. I need to think over it and any ideas are also welcome.
from doom-modeline.
all my code does is swap buffer-file-name
and buffer-file-truename
this line.
it looks it would also require a conditional around this code. Does that seem like the best insertion points?
from doom-modeline.
@CeleritasCelery Thanks for sharing!
But I don't think it's the solution. The change may impact other scenarios. If you just want to visit the symlink while not the true files, why should show file true name in modeline? It doesn't make sense. My suggestion is change find-file-visit-truename
or use buffer-name
style, or manage the file via vcs.
More thoughts?
from doom-modeline.
If you visit the true name it changes your default-directory
. If I navigate to a file and chase it through a symlink with find-file-visit-true-name
I can no longer go back up a directory to where I was before. I may visit a file that has other files in the same directory, but since it is a symlink, when I open dired
or find-file
all those files are gone and I have to try and get back to the original directory.
The whole point of symlinks is to have a pointer to a remote file but have it act as though is is integrated into your file system. visiting the true name breaks that utility.
from doom-modeline.
I fully agree with what @CeleritasCelery has to say above. I marked this as resolved as it was partially resolved with the above. It shortened my path a little, but it's still a mess. Again the point of having symlinks for me is to shorten a long path. Not resolve it. Also using them with a NFS share.
from doom-modeline.
Can you try this on your env?
(defun doom-modeline-buffer-file-name ()
"Propertized variable `buffer-file-name' based on `doom-modeline-buffer-file-name-style'."
(let* ((buffer-file-name (file-local-name (or (buffer-file-name (buffer-base-buffer)) "")))
(buffer-file-truename (file-local-name (or buffer-file-truename (file-truename buffer-file-name) "")))
(buffer-file-name (expand-file-name buffer-file-truename)))
(propertize
(pcase doom-modeline-buffer-file-name-style
(`truncate-upto-project
(doom-modeline--buffer-file-name buffer-file-name buffer-file-truename 'shrink))
(`truncate-from-project
(doom-modeline--buffer-file-name buffer-file-name buffer-file-truename nil 'shrink))
(`truncate-with-project
(doom-modeline--buffer-file-name buffer-file-name buffer-file-truename 'shrink 'shink 'hide))
(`truncate-except-project
(doom-modeline--buffer-file-name buffer-file-name buffer-file-truename 'shrink 'shink))
(`truncate-upto-root
(doom-modeline--buffer-file-name-truncate buffer-file-name buffer-file-truename))
(`truncate-all
(doom-modeline--buffer-file-name-truncate buffer-file-name buffer-file-truename t))
(`relative-to-project
(doom-modeline--buffer-file-name-relative buffer-file-name buffer-file-truename))
(`relative-from-project
(doom-modeline--buffer-file-name-relative buffer-file-name buffer-file-truename 'include-project))
(style
(propertize
(pcase style
(`file-name (file-name-nondirectory buffer-file-name))
(`buffer-name (buffer-name)))
'face
(let ((face (or (and (buffer-modified-p)
'doom-modeline-buffer-modified)
(and (doom-modeline--active)
'doom-modeline-buffer-file))))
(when face `(:inherit ,face))))))
'help-echo (concat buffer-file-truename
(unless (string= (file-name-nondirectory buffer-file-truename)
(buffer-name))
(concat "\n" (buffer-name)))
"\nmouse-1: Previous buffer\nmouse-3: Next buffer")
'local-map mode-line-buffer-identification-keymap)))
from doom-modeline.
That did not make any difference for me. However this code worked
(defun doom-modeline-buffer-file-name ()
"Propertized variable `buffer-file-name' based on `doom-modeline-buffer-file-name-style'."
(let* ((buffer-file-name (file-local-name (or (buffer-file-name (buffer-base-buffer)) "")))
(buffer-file-truename buffer-file-name))
(propertize
(pcase doom-modeline-buffer-file-name-style
(`truncate-upto-project
(doom-modeline--buffer-file-name buffer-file-name buffer-file-truename 'shrink))
(`truncate-from-project
(doom-modeline--buffer-file-name buffer-file-name buffer-file-truename nil 'shrink))
(`truncate-with-project
(doom-modeline--buffer-file-name buffer-file-name buffer-file-truename 'shrink 'shink 'hide))
(`truncate-except-project
(doom-modeline--buffer-file-name buffer-file-name buffer-file-truename 'shrink 'shink))
(`truncate-upto-root
(doom-modeline--buffer-file-name-truncate buffer-file-name buffer-file-truename))
(`truncate-all
(doom-modeline--buffer-file-name-truncate buffer-file-name buffer-file-truename t))
(`relative-to-project
(doom-modeline--buffer-file-name-relative buffer-file-name buffer-file-truename))
(`relative-from-project
(doom-modeline--buffer-file-name-relative buffer-file-name buffer-file-truename 'include-project))
(style
(propertize
(pcase style
(`file-name (file-name-nondirectory buffer-file-name))
(`buffer-name (buffer-name)))
'face
(let ((face (or (and (buffer-modified-p)
'doom-modeline-buffer-modified)
(and (doom-modeline--active)
'doom-modeline-buffer-file))))
(when face `(:inherit ,face))))))
'help-echo (concat buffer-file-truename
(unless (string= (file-name-nondirectory buffer-file-truename)
(buffer-name))
(concat "\n" (buffer-name)))
"\nmouse-1: Previous buffer\nmouse-3: Next buffer")
'local-map mode-line-buffer-identification-keymap)))
from doom-modeline.
Hmm, but that codes do not make sense to me 😢
I'm curious whether the issue exists for the local symlinks? In my env, it looks right.
Which style are you using? Can you try truncate-upto-project
style with the latest version?
from doom-modeline.
I put @seagle0128 's code into my config.org after I loaded doom-mode line in my config and this is what my bar looks like currently.
config.org is in in ~/org/config.org and the ~org dir is a symlink to ~/dev/active/dotfiles/emacs/.emacs.d/ which I manage with gnu stow.
I'm also on Freebsd which has /home sym linked to /usr/home in the base system. So theirs a lot going on there.
from doom-modeline.
@gregf how about using the latest version without any changes? what does it look like?
from doom-modeline.
On doom-modeline-20190107.1829 form melpa
from doom-modeline.
This is how I have doom-modeline configured btw.
(use-package doom-modeline
:ensure t
:defer t
:config
(setq column-number-mode t)
(setq doom-modeline-major-mode-icon t)
:hook (after-init . doom-modeline-init))
from doom-modeline.
I realize that I did not start emacs, so perhaps the reason mine did change would be because the cached root value was unchanged.
from doom-modeline.
@seagle0128 one thing I want to point out about the code snippet you provided, is that although it makes the path look much cleaner, it is still using the truename, which does not match the default-directory
or buffer-file-name
and is therefore less useful.
from doom-modeline.
@CeleritasCelery Can you provide the detailed steps to reproduce your issue? I could't reproduce in my env. I need more info, e.g. which style of doom-modeline-buffer-file-name-style
, version of doom-modeline
, directory and symlinks information, etc.
In #51 (comment), you can see all look fine in my env.
from doom-modeline.
Is that a symlink in your example?
from doom-modeline.
Of course. test.txt
is a Sumlin. I also tried with directory symlinks.
from doom-modeline.
I think this issue has been resolved.
from doom-modeline.
Related Issues (20)
- [Feature Request] Support for Flycheck-status-emoji HOT 4
- Error using with latest eglot / jsonrpc packages HOT 4
- Can the 'which-function' be disabled? HOT 2
- [Bug] buffer-position formatting won't respect flags in format specifier for column HOT 4
- [Bug] Lightbulb symbol 01F4A1 not displaying in mode line HOT 3
- [Feature Request] display-all-git-branches HOT 2
- [Bug] Icons on modeline lack sufficient padding HOT 14
- [Bug] modeline fragments do not get updated correctly when a command that changes the current-buffer is running HOT 3
- [Bug] HOT 3
- [Bug] Setting a left window margin clips the modeline on the right HOT 4
- [Bug] Compiler warnings after 311a0c5 HOT 1
- Fix the few faces that don't inherit from doom-modeline HOT 1
- Symbol’s function definition is void: doom-modeline-check-icon HOT 4
- [Bug] Typo in commit 3f1d33a
- Differentiate error states for checker segment HOT 1
- [Bug] Error during redisplay HOT 1
- [Bug] Reference to free variable `keel-menu-map' after 1d0942d HOT 2
- [Feature Request] new doom-modeline-buffer-file-name-style project-and-filename
- help-echo text not showing when in lsp-mode[Bug] HOT 4
- [Bug] Space inconsistency between `buffer-position` and `selection-info` HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from doom-modeline.