如何在 Windows 上的 emacs 中禁用哔声 [英] How to disable the beep in emacs on Windows

查看:14
本文介绍了如何在 Windows 上的 emacs 中禁用哔声的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Emacs 的新手,我在 Windows 机器上下载了 GNU emacs.我刚刚完成了简短的教程,但我发现每当我点击文件的开头/结尾以及在许多其他情况下都会发出哔声,这让我有点不安.

Hi I'm new to Emacs and I downloaded GNU emacs on my windows machine. I just finished the short tutorial but I found there's a beep sound whenever I hit the beginning/end of a file and in many other cases, which is a little disturbing to me.

我在网上搜索,发现有人说把这个

I searched online and I found people saying putting this

(setq visible-bell 1)

在我的 .emacs 文件中,但我不知道该怎么做.首先,我的 .emacs 文件在哪里,它是什么?或者有其他方法可以做到吗?我的意思是在 emacs 窗口菜单中有 Options -> Customize Emacs 但我找不到设置的位置.我觉得在那里很难找到东西,除非你已经知道它在哪里.

in my .emacs file, but I don't know how to do that. First, where is my .emacs file and what is it? Or is there another way to do it? I mean in the emacs window menu there is Options -> Customize Emacs but I couldn't find where the setting is. I feel like it's kind of hard to find things in there unless you already know where it is.

推荐答案

您有两个选项,其中之一不需要您知道文件在哪里;但是在适当的时候,您几乎肯定会想要对文件进行更改,所以让我们从那里开始.

You have a couple of options, one of which doesn't require you to know where the file is; however in due course you're almost certainly going to want to make changes to the file, so let's start there.

首先,我的 .emacs 文件在哪里?它是什么?

First, where is my .emacs file and what is it?

您还可以选择该文件的名称.~/.emacs 是默认值,但也可以是 ~/.emacs.el~/.emacs.d/init.el>.(我个人更喜欢后者,以便将所有与 Emacs 相关的文件保存在同一个 .emacs.d 目录下,但我们将使用默认值,以后您可以随时重命名文件.)

You also have some options for the name of that file. ~/.emacs is the default, but it could also be ~/.emacs.el or ~/.emacs.d/init.el. (Personally I prefer the latter, so as to keep all Emacs related files under that same .emacs.d directory, but we'll go with the default, and you can always rename the file later.)

首先,检查您是否有现有文件.

So first, check to see if you have an existing file.

C-hv user-init-file RET

默认情况下,它会显示一个以 /.emacs 结尾的文件路径(即使该文件不存在),但在(不太可能,在你的情况下)它以/.emacs.el/.emacs.d/init.el 那么这意味着您在该位置有一个现有的 init 文件.

By default it will show you a file path ending in /.emacs (even if that file doesn't exist), but on the (unlikely, in your case) offchance that it ends in /.emacs.el or /.emacs.d/init.el then it would mean that you have an existing init file at that location.

使用以下适当的一项加载该文件:

Load that file with the appropriate one of the following:

  • C-xC-f ~/.emacs RET
  • C-xC-f ~/.emacs.el RET
  • C-xC-f ~/.emacs.d/init.el RET
  • C-xC-f ~/.emacs RET
  • C-xC-f ~/.emacs.el RET
  • C-xC-f ~/.emacs.d/init.el RET

或者你可以加载它,不管它在哪里:
M-: (find-file user-init-file) RET

Or you could load it regardless of where it was with:
M-: (find-file user-init-file) RET

然后你可以简单地将该行代码添加到文件中:

Then you can simply add that line of code to the file:

(setq visible-bell 1)

保存文件:

C-xC-s

下次启动 Emacs 时,它将使用该设置.

And the next time you start Emacs, it will use that setting.

您也可以通过在右括号后输入 C-xC-e 来立即评估设置.

You can also evaluate the setting immediately by typing C-xC-e with the cursor after the closing parenthesis.

既然您知道如何做到这一点,另一种方法是:

Now that you know how to do that, the other approach is:

  • Mx customize-variable RET visible-bell RET
  • 点击切换"按钮打开设置.
  • 点击保存以备将来使用"按钮将其保存到您的 init 文件中.

如果您随后查看您的 init 文件,您将看到它已添加到 (custom-set-variables ...) 部分.

If you then look at your init file, you will see that it has been added to the (custom-set-variables ...) section.

至于您的 .emacs 文件是什么,它是 Emacs Lisp (elisp) 代码的个人库,在您启动 Emacs 时会自动加载和评估.所有 Emacs 配置和定制都是用这种语言编写的(实际上是编辑器本身的大部分内容).

As for what your .emacs file is, it's a personal library of Emacs Lisp (elisp) code which is automatically loaded and evaluated when you start Emacs. All Emacs configuration and customization is written in this language (as indeed is the majority of the editor itself).

您可以在内置手册中阅读有关 init 文件和自定义 Emacs 的更多信息,输入:

You can read more about the init file and customizing Emacs in the built-in manual, by typing:

M-: (info "(emacs) Customization") RET
或者C-hig (emacs) 自定义 RET

您可能需要先学习如何使用信息阅读器.从 *info* 缓冲区你可以输入 h 开始它的教程,和 d 返回到顶级页面(它有一些有用的注释在顶部).

You may need to learn how to use the info reader first. From the *info* buffer you can type h to start its tutorial, and d to return to the top level page (which has some useful notes at the top).

或者有其他方法吗?我的意思是在 emacs 窗口菜单中有选项 -> 自定义 Emacs,但我找不到设置的位置.

Or is there another way to do it? I mean in the emacs window menu there is Options -> Customize Emacs but I couldn't find where the setting is.

特定选项"->visible-bell"是该方法的答案.但是请注意,并非所有内容都可以通过这些菜单访问,因此这并不总是答案,而且很多人完全禁用菜单栏,因为没有它也可以访问所有内容.(我更倾向于建议通过浏览菜单来发现一些人们认为足够有用的选项,可以放入其中,但请确保您不依赖它们.)

"Specific Option" -> "visible-bell" was the answer for that approach. But do take note that not everything is available through those menus, so that won't always be the answer, and lots of people disable the menu bar entirely, because everything can be accessed without it. (I'm more inclined to suggest browsing through the menus as a way of discovering some of the options which people thought were useful enough to put in there, but make sure you're not reliant on them.)

我觉得在那里很难找到东西,除非你已经知道它在哪里.

I feel like it's kind of hard to find things in there unless you already know where it is.

这在某种程度上当然是正确的,但是 Emacs 的自文档化方面意味着即使您不知道去哪里,您几乎总能找到您是否知道 看起来如何.

That's certainly true to an extent, but the self-documentation aspect of Emacs means that even if you don't know where to look, you can almost always find out if you know how to look.

诚然,即使这样做也有一定的学习曲线,但我建议您尽快学习 Emacs 的这方面的知识.这会让你开始:

Admittedly there's a definite learning curve even on doing that, but I recommend learning as much as you can about this aspect of Emacs as soon as possible. This will get you started:

http://emacswiki.org/emacs/SelfDocumentation

这篇关于如何在 Windows 上的 emacs 中禁用哔声的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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