修复自动完成模式和 linum 模式的烦恼 [英] fix an auto-complete-mode and linum-mode annoyance
问题描述
我正在使用 auto-complete-mode
,我认为这非常棒.我也是 linum-mode
的忠实粉丝,但是当两者一起使用时,我遇到了一个非常恼人的问题,尤其是当我在一个新的缓冲区(或具有非常几行).
I'm using auto-complete-mode
which I think is totally fantastic. I'm also a big fan of linum-mode
but I've got a very irritating issue when the two are used together, especially when I'm working in a new buffer (or a buffer with very few lines).
基本上缓冲区是 'x' 行长,但是当自动完成启动时,它会向缓冲区添加"行,因此 linum-mode
不断切换,例如,在显示行号之间一列或两列,取决于 auto-complete
是否建议完成.
Basically the buffer is 'x' lines long but when auto-complete kicks in it "adds" lines to the buffer, so linum-mode
keeps switching, for example, between displaying line numbers on one column or two columns, depending on whether auto-complete
is suggesting a completion or not.
所以你输入一个句子,你会看到缓冲区的内容在每次按键时都从左到右疯狂地移动.这真的很烦人.
So you type a sentence and you see your buffer's content frantically shifting from left to right at every keypress. It is really annoying.
我认为解决方案涉及配置 linum-format 变量,但我不知道如何.
I take it the solution involves configuring the linum-format variable but I don't know how.
理想情况下,如果我的 linum 格式是:
Ideally it would be great if my linum-format was:
- 动态
- 右对齐
- 考虑到缓冲区的行数比缓冲区实际拥有的行数多 'y' 行
我的理由是 auto-complete
不会建议超过 'y' 的建议,因此,两者应该开始很好地一起玩.
My rationale being that auto-complete
shall not suggest more than 'y' suggestion and that, hence, the two shall start playing nicely together.
例如,如果 'y' 设置为 20 并且我的缓冲区有 75 行,那么 linum 应该使用两列:因为无论我在哪里 auto-complete
都不会制作缓冲区 '大于 99 行.
For example, if 'y' is set to 20 and my buffer has 75 lines, then linum should use two columns: because no matter where I am auto-complete
shall not make the buffer 'bigger' than 99 lines.
相反,如果 'y' 仍然设置为 20 并且我的缓冲区有 95 行,那么 linum
应该使用三列,否则如果我接近缓冲区的末尾并且 <当我输入时,代码>自动完成代码>在我的缓冲区中踢将开始向左和向右摆动".
On the contrary, if 'y' is still set to 20 and my buffer has 95 lines, then linum
should use three columns because otherwise if I'm near the end of the buffer and auto-complete
kicks in my buffer shall start "wobbling" left and right when I type.
我不想为 linum
硬编码3 列宽".
I'd rather not hardcode "3 columns wide" for linum
.
我想使用动态但总是至少两列"会以某种方式解决大多数烦恼,但仍然像我描述的那样会很棒.
I guess using "dynamic but always at least two columns" would somehow fix most annoyances but still something as I described would be great.
PS:我意识到我的修复"意味着 linum 将始终显示在至少两列上,我对此很好......只要它保持右对齐并使用 2,3 或 4 列,视需要而定.
推荐答案
只需将以下行放在 .emacs 中即可解决此问题.它在 auto-complete.el 中.
Simply put the following line in .emacs which resolves this issue. It is in auto-complete.el.
(ac-linum-workaround)
这篇关于修复自动完成模式和 linum 模式的烦恼的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!