我可以禁用“(键入 e 重复宏)”吗? emacs 中的消息?
所以,我终于做出了尝试,并且已经达到了我很高兴从 vi 和 vim 切换到 emacs 的状态......我一直在将东西放入我的 .emacs 文件中,学习如何评估 是
现在我的 .emacs 文件中的 require 行(一个 require 语句*)遇到了问题,当我启动 emacs 时(通常 无法工作)。
因此,这导致我遇到以下情况:
在尝试调试上述情况的过程中,我所做的步骤之一是打开我试图需要的文件,并使用 CMf 一点一点地评估它 和 Cx Ce
(后来只是 Mx eval-buffer
),它们都工作得很好。但在逐节进行的过程中,我厌倦了输入所有这些内容,因此我录制了一个键盘宏...Cx ( CMf Cx Ce Cx )
然后Cx e
...这在迷你缓冲区中给了我一条消息(我认为我使用了正确的名称),说(键入 e 以重复宏)
。这意味着我无法再看到每段代码的评估结果值......虽然在这种情况下并不重要,但我喜欢拥有。
这引出了我的实际问题:
有没有办法禁用该消息,和/或使迷你缓冲区一次显示多行?
我了解 *Messages* 缓冲区,这可能会有所帮助,我只是想知道是否有办法禁用该消息,或者使其与其他消息共存。有什么建议吗?
谢谢!
- lindes
* - 当前的问题,这不是我真正的问题,是 (require 'ruby-mode/ruby-mode)
失败,即使 emacs 肯定是成功的(每个系统调用跟踪)打开并读取 ruby-mode.el 文件。我认为这是因为 provide
行仅显示 'ruby-mode
。我已经找到了解决方案,但如果有人可以向我指出任何“最佳实践”,我将不胜感激。
So, I've finally made the plunge, and have gotten to the state where I'm quite happy to have switched from vi and vim to emacs... I've been putting stuff in my .emacs file, learning how to evaluate things (not to mention becoming familiar with movement commands), etc. etc. etc.
And now I have a problem with a require line in my .emacs file (a require statement*), which bombs out when I launch emacs (and generally fails to work).
So, this lead me to the following situation:
In the process of trying to debug the above situation, one of the steps I did was to open the file I was trying to require, and evaluate it bit by bit, using C-M-f
and C-x C-e
(and later just M-x eval-buffer
), which all worked fine. But along the way of the section-by-section, I got tired of typing all those, and so I recorded a keyboard macro... C-x ( C-M-f C-x C-e C-x )
and then C-x e
... which gave me a message in the minibuffer (I think I'm using the right name), saying (Type e to repeat macro)
. Which meant I could no longer see the resultant value of the evaluation of each section of code... which, while not critical in this case, I was liking having.
Which leads me to the actual question:
Is there a way to disable that message, and/or to cause the minibuffer to show multiple lines at once?
I know about the *Messages*
buffer, and that could have helped, I'm just wondering if there's a way to either disable that message, or otherwise make it coexist with other messages. Any suggestions?
Thanks!
- lindes
* - the problem at hand, which is not really my question, is that (require 'ruby-mode/ruby-mode)
fails, even though emacs is definitely and successfully (per system call tracing) opening and reading the ruby-mode.el file. I presume this is because the provide
line says just 'ruby-mode
. I've found a solution for this, but if anyone can point me to any "best practices", I'd appreciate it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
(我首先要说的是:这是我很长时间以来在这里读到的最清晰的问题!干得好)。
您可以按 F4 来运行宏。它的作用与 Cx e 大致相同,只是它不包含该消息!
(May I first say: this is the clearest question I've read here in a long time! Well done).
You can hit F4 to run your macro. That does roughly the same thing as C-x e, except it doesn't include that message!
优化 lindes'回答,我会这样实现:
我取消了对
minor-mode-alist
的修改,因为没有理由多次执行它。剩下的就是使用let
和flet
进行临时绑定,这在 非本地退出。就我个人而言,我不会使用此建议,因为它会在宏的持续时间内禁用
message
函数,这意味着所有实际使用message
的宏> 将不再以同样的方式运行。我可能只是选择 编辑kmacro-call-macro 的版本。当然,您可以使用一个可以选择性地发送消息的变量来包装对消息的调用。To refine lindes' answer, I'd implement it this way:
I pulled the modification of
minor-mode-alist
out because there's no reason to do it multiple times. The rest is using thelet
andflet
to do the temporary binding, which is cleaner and also safe in the presence of nonlocal exits.Personally, I wouldn't use this advice because it disables the
message
function for the duration of the macro, which means all macros that actually usemessage
would no longer function the same way. I'd probably just go with an edited version of kmacro-call-macro. Of course you could wrap the call to message with a variable that could selectively message instead.我不知道你的“隐藏消息”问题。
关于功能和 require/provide 函数,常见的做法(尽管我不会称其为“最佳”)是将 .el 文件命名为与其“提供”的功能相同的名称。
并非所有模块都这样做。在这些情况下,您需要查看 EL 文件以找出 .el 文件提供的功能的名称。或者检查文档,在极少数情况下存在。然后只需在
require
调用中使用可选参数即可。.el 文件必须位于您的加载路径上。
I don't know about your "hide messages" question.
Regarding features and the require/provide functions, common practice, although I wouldn't go so far as to call it "best", is to name the .el file the same as the feature it "provides".
Not all modules do that. In those cases you need to look into the EL file to figure out the name of the feature the .el file is providing. Or check the documentation, in those rare cases where it exists. Then just use the optional arguments on the
require
call.The .el file must be on your load-path.
要完全禁用该功能,您可以将其添加到 .emacs 中:(
当前)无法在不显示消息的情况下保持该功能启用。
To disable the feature completely, you can add this to your .emacs:
There is no way (currently) to keep the functionality enabled but without the message.
好吧,面对“没有办法做到这一点”答案的挑战(对此我很感激,可以说),我开始尝试寻找一种方法来做到这一点。
我认为在模式行中显示一些内容而不是作为消息会很好,所以...
我读了(一些可通过网络访问的版本)kmacro-call-macro 的源代码,以及 elisp 次要模式约定,以及各种其他网页。我尝试了一些事情。我做了一些调试。最后,我想出了这个(不完美——下面有更多内容)的 elisp:
我很确定这不是最干净的方法——事实上,它实际上似乎有点错误——并不总是在应该打开和关闭模式行消息时。但它基本上有效,这让我很高兴。
如果有人对如何进一步改进有任何提示,我将不胜感激。
我认为另一个解决方案是重写 kmacro-call-macro 以基本上包含此功能,可能使用另一个自定义变量来控制它。我想,这样做还可以显示消息中的附加信息(重复键;重复计数信息)。也许使用 defadvice 甚至可以实现这一点?也许通过重新定义的消息函数或其他东西影响广告返回值的值?
不管怎样,上面的代码已经被添加到我的 .emacs 文件中,并且希望当我更好地了解 elisp 及其最佳实践时,它会在某个时候得到完善。
我希望其他人发现这很有用。
再次强调,对此的改进是最受欢迎的。
编辑:
我最初有:
这确实应该是(现在是,上面):
希望能解决问题!它是断断续续的,我认为现在说还为时过早......
Well, taking the challenge of the "there's no way to do it" answer (for which I am thankful, let it be said), I set out to try and find a way to do this.
I had the thought that it would be nice to have something show up in the mode line, instead of as a message, so...
I read (some web-accessible version of) the source code for kmacro-call-macro, and the elisp Minor Mode Conventions, and various other web pages. I tried some things. I did some debugging. And finally, I came up with this (imperfect -- more on that below) bit of elisp:
I'm quite certain that this is not the cleanest way to do this -- in fact, it actually seems to be somewhat buggy -- not always turning on and off the mode line message when it ought to. But it mostly works, and this makes me happy.
If anyone has any hints on how to improve it further, I would appreciate them.
I figure another solution is to re-write kmacro-call-macro to basically include this functionality, possibly with another customization variable to control it. Doing so, I imagine, would also allow for the additional information (key to repeat with; repeat-count information) that's in the message to appear. Perhaps that's even possible using defadvice? Maybe influencing the value of ad-return-value via the re-defined message function or something?
Anyway, the above code has been added to my
.emacs
file, and hopefully will be refined at some point, when I know my way around elisp and its best practices a bit better.I hope someone else finds this useful.
Again, improvements to this are most welcome.
edit:
I originally had:
which should really have been (and now is, above):
Here's hoping that solves the problems! It's intermittent enough that I consider it too early to tell...