Emacs和符号链接 [英] Emacs and symbolic links

查看:120
本文介绍了Emacs和符号链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我在 /home/.bashrc 中有一个符号链接,指向其他地方的实际.bashrc文件: / some / other /路径/ .bashrc



如果我打开 /home/.bashrc 在Emacs,它提示我:

 符号链接到Git控制的源文件;跟随链接? (y或n)

我通常输入 y ,因为我想编辑实际的文件。但是,稍后,如果我执行 buffer-file-name Emacs返回 /some/other/path/.bashrc ,而不是 /home/.bashrc )。



我希望Emacs 记住,我访问此文件的方式是通过一个符号链接。



换句话说,我希望我的符号链接对Emacs是透明的。部分原因是因为我有几个依赖于当前文件路径的Emacs宏,这些宏认为我正在使用位于 / some / other / path 而不在 / home /



我该怎么做?

解决方案

当提示与

 符号链接Git控制的源文件;跟随链接? (y或n)

类型 n 。不需要遵循符号链接并直接打开符号链接指向的文件,emacs将根据需要使用符号链接本身。



警告:这样做可以防止emacs'版本控制功能可以在目的地检测和与存储库进行交互(如果有)。



如果您要更改默认行为,请查看文档 vc-follow-symlinks 自定义变量。 ( C-h v vc-follow-symlinks


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 repository.

If I open /home/.bashrc in Emacs, it prompts me with:

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

I usually type y, since I want to edit the actual file. However, later on, if I do buffer-file-name Emacs returns /some/other/path/.bashrc, and not /home/.bashrc).

I would like Emacs to remember that the way I accessed this file was through a symbolic link.

In other words, I would like my symbolic links to be transparent to Emacs. Part of the reason is because I have several Emacs macros that depend on the path of the current file, and these macros think that I am working with a file located in /some/other/path and not in /home/.

How can I do this?

解决方案

When it prompts with

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

type n. Instead of following the symlink and directly opening the file that the symlink points to, emacs will use the symlink itself, as you desire.

A warning: doing this prevents emacs' version control features from detecting and interacting with the repository at the destination, if there is one.

If you'd like to change the default behaviour, check out the documentation of the vc-follow-symlinks customization variable. (C-h v vc-follow-symlinks)

这篇关于Emacs和符号链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆