为什么在Emacs中应该有行数的空格

为什么在Emacs中应该有行数的空格

本文介绍了为什么在Emacs中应该有行数的空格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用(global-linum-mode t)在Emacs中显示行号。
这个功能很好,直到我使用 + / 命令(段落后退段落)导航缓冲区,此时某些行号被错误地呈现(见附件)。
只有当我使用所述命令来跳过整个代码段时,才会发生这种情况,如果我以其他方式开始浏览缓冲区,则问题立即消失(行号正确呈现,就是这样)。
问题出现在C和C ++模式(可视化)中,我在x86-64 Fedora 19上使用Emacs 24.3.1。

I'm using (global-linum-mode t) to present line numbers in Emacs.This works just fine up-until I use the + / commands (forward-paragraph and backward-paragraph) to navigate a buffer, at which point some line numbers are rendered incorrectly (see attached image).This occurs only when I use said commands to skip entire segments of code, and the issue immediately disappears (the line numbers are rendered correctly, that is) if I start navigating the buffer by other means.The issue is present in both C and C++ modes (visualized), and I'm using Emacs 24.3.1 on x86-64 Fedora 19.

在线导航编译错误和警告方面,我的目的是为了我的目的,我想保留行号,因为我发现它们在快速逼近函数长度方面是有帮助的。
到目前为止,我没有发现其他地方没有提到这个问题,我不知道这是否是Emacs的预期行为,或者是否提交错误报告。

While the go-to-line command serves my purposes in terms of navigating compilation errors and warnings, I'd like to keep the line numbers as I find them to be helpful in terms of quickly approximating length of functions.So far I've found no mention of this problem elsewhere, and I'm unsure of whether or not this is expected behavior of Emacs or if I'm to submit a bug report.

有没有人遇到这个问题或者知道其中的任何东西?

Has anyone encountered the issue or know anything of its origin?

修复:

可以通过调用(linum-update-current)来解决问题,如下面他的答案中的@lawlist所描绘的。反复这样做的一个简单的方法是将命令追加到执行 forward-paragraph ,这可以使用Emacs Lisp :

The problem may be resolved by invoking (linum-update-current), as portrayed by @lawlist in his answer below. An easy way of repeatedly doing this is to append the command to the execution of forward-paragraph, which may be done using the Emacs Lisp advice feature:

(defadvice forward-paragraph (after forward-paragraph-linum-update)
  "Perform (linum-update-current) after jumping forward one
  paragraph to ensure line numbers are being rendered
  correctly."
  (global-linum-mode t)
  (linum-update-current))
(ad-activate 'forward-paragraph)


推荐答案

几个Emacs的主要成员开发团队建议以各种原因避免linum模式,而是建议使用nlinum模式:

A few of the lead members on the Emacs development team suggest that linum-mode be avoided for a variety of reasons, and instead they suggest using nlinum-mode: http://elpa.gnu.org/packages/nlinum.html

I pe rongally使用修改版本的linum模式,我已经修复了一些错误 - 如果你继续使用linum模式,你可能需要做同样的事情 - 即在你找到它们时实现自己的错误修复。修复您看到的错误的最快方法是遵循以下命令:

I personally use a modified version of linum-mode, and I have fixed a few bugs -- if you keep using linum-mode, you will likely need to do the same -- i.e., implement your own bug fixes as you find them. The quickest way to fix the bug you see is to follow your command with:

(linum-update-current)

这篇关于为什么在Emacs中应该有行数的空格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 05:36