Emacs and symbolic links

后端 未结 4 877
忘掉有多难
忘掉有多难 2021-01-31 07:44

Say I have a symbolic link at /home/.bashrc that points to an actual .bashrc file somewhere else: /some/other/path/.bashrc that is under a git reposito

4条回答
  •  情话喂你
    2021-01-31 08:15

    Just for completeness, for someone who has a question about

    Symbolic link to Git-controlled source file; follow link? (y or n)

    but doesn't necessarily want what the OP wants, this is the documentation from C-h v vc-follow-symlinks (as of my Emacs version — look up your own Emacs for details):

    vc-follow-symlinks is a variable defined in vc-hooks.el. Its value is ask

    Documentation: What to do if visiting a symbolic link to a file under version control. Editing such a file through the link bypasses the version control system, which is dangerous and probably not what you want.

    If this variable is t, VC follows the link and visits the real file, telling you about it in the echo area. If it is `ask', VC asks for confirmation whether it should follow the link. If nil, the link is visited and a warning displayed.

    You can customize this variable.

    The upshot is that to avoid being prompted each time, you can in your .emacs set either

    (setq vc-follow-symlinks t)
    

    to always follow the symlink (and edit the "actual" file directly), or

    (setq vc-follow-symlinks nil)
    

    to always edit the file as if it's at the symlink itself (this seems to work ok — it won't delete the symlink or anything — but it won't let you use version-control related stuff on the file). I prefer the former (unlike the OP).

提交回复
热议问题