Emacs,更改$ PWD变量 [英] Emacs, change of $PWD variable

查看:203
本文介绍了Emacs,更改$ PWD变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$ b我总是在Gake内部没有windows模式(emacs -nw)的emacs下工作,而且我已经设置好了,在同一个目录中打开一个新的标签页。
$ b

我的目的是:




  • 如果我在emacs中使用某个文件,而且我打开一个新的选项卡,我想要路径( PWD变量)与文件相同。

  • 当我关闭emacs时,PWD变量是恢复其原始值。



如何设置我的 .emacs 文件

解决方案

借助wvxvw的回答:



(defvar pwd-orig(getenvPWD))



(add- hook'find-file-hook
(lambda()(setenvPWDdefault-directory)))



(add-hook'kill-emacs-hook(lambda()(setenvPWDpwd-orig)))


I do always work with emacs in no windows mode (emacs -nw) inside Guake, and I have set guake to open a new tab in the same directory on which I'm in that moment.

My purpose is:

  • If I work with a certain file in emacs, and I open a new tab, I want the path (PWD variable) is the same of the file.
  • When I close emacs, the PWD variable is restored with its original value.

How can I set my .emacs file to achieve that?

解决方案

With the help of wvxvw's answer:

(defvar pwd-orig (getenv "PWD"))

(add-hook 'find-file-hook (lambda () (setenv "PWD" default-directory)))

(add-hook 'kill-emacs-hook (lambda () (setenv "PWD" pwd-orig)))

这篇关于Emacs,更改$ PWD变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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