为mac ruby开发设置.emacs文件。

时间:2021-11-07 11:07:03

I am having a difficult time loading ruby-mode in emacs on my mac.

我在mac上加载emacs的ruby模式非常困难。

The .emacs file is located at ~/.emacs I've added several commands to it (many pasted from this site) and none seem to get loaded. Any advise? I"m not sure if the file isn't loading or I have the command syntax wrong.

emacs文件位于~/。我已经向它添加了几个命令(许多来自这个站点的粘贴),但是似乎没有一个被加载。任何建议吗?我不知道是文件没有加载,还是命令语法错误。

All I need is the following

我所需要的就是下面这些

  • 4 space indent (auto-intedent would be great as well)
  • 4空间缩进(自动整进也不错)
  • ruby mode loaded for .rb files.
  • 为.rb文件加载ruby模式。

Thanks!

谢谢!

2 个解决方案

#1


2  

Put the line (warn "Loading .emacs") as the first line of .emacs. When you start emacs does it show you that message in a warning buffer? If so, it at least started loading the file.

将行(警告“装入.emacs”)作为.emacs的第一行。当您启动emacs时,它会在警告缓冲区中显示该消息吗?如果是这样,它至少开始加载文件。

If this does nothing, try opening the file in emacs, and running M-x eval-buffer.

如果这不起作用,请尝试在emacs中打开文件,并运行M-x事件缓冲区。

Also, at startup, does the Messages buffer indicate any errors in your .emacs? This is the most common reason for a .emacs not to take effect.

同样,在启动时,消息缓冲区是否表示.emacs中有任何错误?这是.emacs无法生效的最常见原因。

#2


1  

This is how emacs finds the .emacs file.

这就是emacs如何查找.emacs文件。

57.6.4 How Emacs Finds Your Init File

57.6.4 Emacs如何找到您的Init文件

Normally Emacs uses the environment variable HOME (see HOME) to find .emacs; that's what ‘~’ means in a file name. If .emacs is not found inside ~/ (nor .emacs.el), Emacs looks for ~/.emacs.d/init.el (which, like ~/.emacs.el, can be byte-compiled).

通常,Emacs使用环境变量HOME(参见HOME)查找.emacs;这就是“~”在文件名中的意思。如果. Emacs没有在~/(或.emac .el)中找到,则Emacs寻找~/.emac .d/init。埃尔(像~ / . emacs。埃尔,可以byte-compiled)。

However, if you run Emacs from a shell started by su, Emacs tries to find your own .emacs, not that of the user you are currently pretending to be. The idea is that you should get your own editor customizations even if you are running as the super user.

但是,如果您从由su启动的shell中运行Emacs,则Emacs试图找到您自己的. Emacs,而不是您目前假装的用户的。其思想是,即使您作为超级用户运行,也应该获得自己的编辑器定制。

More precisely, Emacs first determines which user's init file to use. It gets your user name from the environment variables LOGNAME and USER; if neither of those exists, it uses effective user-ID. If that user name matches the real user-ID, then Emacs uses HOME; otherwise, it looks up the home directory corresponding to that user name in the system's data base of users.

更准确地说,Emacs首先确定要使用哪个用户的init文件。它从环境变量LOGNAME和user获取用户名;如果两者都不存在,则使用有效的用户id。如果用户名与实际用户id匹配,则Emacs使用HOME;否则,它将在系统的用户数据库中查找与该用户名对应的主目录。

From http://www.gnu.org/software/emacs/manual/html_node/emacs/Find-Init.html#Find-Init

从http://www.gnu.org/software/emacs/manual/html_node/emacs/Find-Init.html Find-Init

#1


2  

Put the line (warn "Loading .emacs") as the first line of .emacs. When you start emacs does it show you that message in a warning buffer? If so, it at least started loading the file.

将行(警告“装入.emacs”)作为.emacs的第一行。当您启动emacs时,它会在警告缓冲区中显示该消息吗?如果是这样,它至少开始加载文件。

If this does nothing, try opening the file in emacs, and running M-x eval-buffer.

如果这不起作用,请尝试在emacs中打开文件,并运行M-x事件缓冲区。

Also, at startup, does the Messages buffer indicate any errors in your .emacs? This is the most common reason for a .emacs not to take effect.

同样,在启动时,消息缓冲区是否表示.emacs中有任何错误?这是.emacs无法生效的最常见原因。

#2


1  

This is how emacs finds the .emacs file.

这就是emacs如何查找.emacs文件。

57.6.4 How Emacs Finds Your Init File

57.6.4 Emacs如何找到您的Init文件

Normally Emacs uses the environment variable HOME (see HOME) to find .emacs; that's what ‘~’ means in a file name. If .emacs is not found inside ~/ (nor .emacs.el), Emacs looks for ~/.emacs.d/init.el (which, like ~/.emacs.el, can be byte-compiled).

通常,Emacs使用环境变量HOME(参见HOME)查找.emacs;这就是“~”在文件名中的意思。如果. Emacs没有在~/(或.emac .el)中找到,则Emacs寻找~/.emac .d/init。埃尔(像~ / . emacs。埃尔,可以byte-compiled)。

However, if you run Emacs from a shell started by su, Emacs tries to find your own .emacs, not that of the user you are currently pretending to be. The idea is that you should get your own editor customizations even if you are running as the super user.

但是,如果您从由su启动的shell中运行Emacs,则Emacs试图找到您自己的. Emacs,而不是您目前假装的用户的。其思想是,即使您作为超级用户运行,也应该获得自己的编辑器定制。

More precisely, Emacs first determines which user's init file to use. It gets your user name from the environment variables LOGNAME and USER; if neither of those exists, it uses effective user-ID. If that user name matches the real user-ID, then Emacs uses HOME; otherwise, it looks up the home directory corresponding to that user name in the system's data base of users.

更准确地说,Emacs首先确定要使用哪个用户的init文件。它从环境变量LOGNAME和user获取用户名;如果两者都不存在,则使用有效的用户id。如果用户名与实际用户id匹配,则Emacs使用HOME;否则,它将在系统的用户数据库中查找与该用户名对应的主目录。

From http://www.gnu.org/software/emacs/manual/html_node/emacs/Find-Init.html#Find-Init

从http://www.gnu.org/software/emacs/manual/html_node/emacs/Find-Init.html Find-Init