Why should there be whitespace for line numbers in Emacs?


caterpillar

I (global-linum-mode t)use to display line numbers in Emacs. This worked fine until I used the ctrl+ up/ downcommand ( forward-paragraphand backward-paragraph) to navigate the buffer, at which point some line numbers were displayed incorrectly (see image below). This only happens when I use the above command to skip the entire snippet, and if I start navigating the buffer by other means, the problem goes away immediately (i.e. the line numbers are displayed correctly). I have this problem (visualization) with both C and C++ modes, and I'm using Emacs 24.3.1 on x86-64 Fedora 19.

Although the go-to-line command did my part in navigating compilation errors and warnings, I wanted to preserve the line numbers as I found them helpful for quickly approximating the length of a function. I haven't mentioned this anywhere else so far, and am not sure if this is expected behavior of Emacs or if I should file a bug report.

Has anyone encountered this problem or know its origin?

enter image description here


fixed:

The problem can be solved by invoking (linum-update-current), as depicted by @lawlist in his answer below. An easy way to do this repeatedly is to append the command to the execution of , which can be done forward-paragraphusing the Emacs Lisp suggestion function :

(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."
  (linum-update-current))
(ad-activate 'forward-paragraph)
Lawyer

Some key members of the Emacs development team recommend avoiding linum mode for a number of reasons, and instead, they recommend using nlinum mode : http://elpa.gnu.org/packages/nlinum.html

I personally use a modified version of linum-mode, and I fixed some bugs - if you continue to use linum-mode, you may need to do the same - ie, implement your own bug fixes as you find them. The quickest way to fix the errors you see is to follow these commands:

(linum-update-current)

Related


Emacs line numbers

flood I'm having trouble getting line numbers in an emacs buffer. I have the following numbers in my init file: (setq line-number-display-limit 2000000) and I have verified that it has line number mode turned on. When I first enter the (~500) line buffer, emac

Emacs line numbers

flood I'm having trouble getting line numbers in an emacs buffer. I have the following numbers in my init file: (setq line-number-display-limit 2000000) and I have verified that it has line number mode turned on. When I first enter the (~500) line buffer, emac

Postgres eliminate whitespace in line numbers

simple J I have a table called assignmentwith indexand unit_idcolumn . Each allocation in a cell has a unique index. This way, allocations in cells can be reordered by swapping indexes. I'm trying to figure out the best way to remove potential gaps in an index

Postgres eliminate whitespace in line numbers

simple J I have a table called assignmentwith indexand unit_idcolumns . Each allocation in a cell has a unique index. This way, allocations in cells can be reordered by swapping indexes. I'm trying to figure out the best way to remove potential gaps in an inde

Postgres eliminate whitespace in line numbers

simple J I have a table called assignmentwith indexand unit_idcolumns . Each allocation in a cell has a unique index. This way, allocations in cells can be reordered by swapping indexes. I'm trying to figure out the best way to remove potential gaps in an inde

Postgres eliminate whitespace in line numbers

simple J I have a table called assignmentwith indexand unit_idcolumns . Each allocation in a cell has a unique index. This way, allocations in cells can be reordered by swapping indexes. I'm trying to figure out the best way to remove potential gaps in an inde

Postgres eliminate whitespace in line numbers

simple J I have a table called assignmentwith indexand unit_idcolumns . Each allocation in a cell has a unique index. This way, allocations in cells can be reordered by swapping indexes. I'm trying to figure out the best way to remove potential gaps in an inde

Add line numbers to GNU Emacs

Akma How to add line numbers in Emacs? Please explain, I am an absolute beginner. monster dragon If you run it in default mode, it's in the menu: Options > Show/Hide > Line Numbers. Then select Options > Save Options to save it for later sessions. If you run i

Add line numbers to GNU Emacs

Akma How to add line numbers in Emacs? Please explain, I am an absolute beginner. monster dragon If you run it in default mode, it's in the menu: Options > Show/Hide > Line Numbers. Then select Options > Save Options to save it for future sessions. If you run

How to match numbers separated by whitespace or start of line

sivaprasad de rangola I have to match numbers between 6-14 in length separated by spaces or : or possibly at the beginning of the line. I am using the following regex:/[ |:](\d[\s\-()]*){6,14}/g For the following input line, it matches as follows, Number1 :545

Emacs line numbers are set to "??" in the status bar

bph I'm having problems with emacs(24), occasionally without line numbers. The settings in the status bar are ??, e.g. U:--- filename All (1000, 4) (Conf[Unix]) Switch to: U:--- filename All (??, 4) (Conf[Unix]) It's a bit annoying and I'd

Emacs line numbers are set to "??" in the status bar

bph I'm having problems with emacs(24), occasionally without line numbers. The settings in the status bar are ??, e.g. U:--- filename All (1000, 4) (Conf[Unix]) Switch to: U:--- filename All (??, 4) (Conf[Unix]) It's a bit annoying and I'd

Emacs line numbers are set to "??" in the status bar

bph I'm having problems with emacs(24), occasionally without line numbers. The settings in the status bar are ??, e.g. U:--- filename All (1000, 4) (Conf[Unix]) Switch to: U:--- filename All (??, 4) (Conf[Unix]) It's a bit annoying and I'd

Separating line numbers from text in Terminal: Emacs

username When I run emacs in terminal mode with the global-linum-mode option enabled, the line numbers are very close to my text, which really annoys the eyes. Is there a way to separate line numbers from text in Emacs? Anton Kovalenko Try setting linum-format

Separating line numbers from text in Terminal: Emacs

username When I run emacs in terminal mode with the global-linum-mode option enabled, the line numbers are very close to my text, which really annoys the eyes. Is there a way to separate line numbers from text in Emacs? Anton Kovalenko Try setting linum-format

Separating line numbers from text in Terminal: Emacs

username When I run emacs in terminal mode with the global-linum-mode option enabled, the line numbers are very close to my text, which really annoys the eyes. Is there a way to separate line numbers from text in Emacs? Anton Kovalenko Try setting linum-format

Emacs - Empty lines have no line numbers

Kirill Novikov I am trying to set line numbers in Emacs. Linum works great, but when I open both buffers, the numbering of empty lines disappears. I am using Manjaro Linux. Emacs works in the terminal. Here is the screenshot. Code in .emacs file: (add-hook 'fi

Emacs line numbers are set to "??" in the status bar

bph I'm having problems with emacs(24), occasionally without line numbers. The settings in the status bar are ??, e.g. U:--- filename All (1000, 4) (Conf[Unix]) Switch to: U:--- filename All (??, 4) (Conf[Unix]) It's a bit annoying and I'd

Separating line numbers from text in Terminal: Emacs

username When I run emacs in terminal mode with the global-linum-mode option enabled, the line numbers are very close to my text, which really annoys the eyes. Is there a way to separate line numbers from text in Emacs? Anton Kovalenko Try setting linum-format

emacs remove whitespace at edge of page

Spenser Truex When working in emacs, I often find myself needing to remove a lot of whitespace at the edge of the page. How to remove it quickly? I looked around in the "remove whitespace" emacs lisp wiki page and didn't find what I needed. Here is an example:

emacs remove whitespace at edge of page

Spenser Truex When working in emacs, I often find myself needing to remove a lot of whitespace at the edge of the page. How to remove it quickly? I looked around in the "remove whitespace" emacs lisp wiki page and didn't find what I needed. Here is an example:

Why is this snippet giving me incorrect line numbers?

Jeff RTC I was throwing an error and I noticed that Stackoverflow and JSFiddle gave me wrong line numbers on the stack trace. function foo () { let stackTrace = (new Error()).stack; console.log(stackTrace); } foo(); Clicking "Run Code Snippet" gives me th