line-number-mode to have an indicator of the current line in my modeline, however for large files or rather, files with long lines, it starts displaying two question marks instead of a line number. I've digged a bit and found out that while
line-number-mode is defined in
simple.el, the customizable variables (and probably all logic involved) are defined in
xdisp.c. Changing the
line-number-display-width variable to an arbitrarily high number might fix this, but I'm far more interested in the piece of code and the logic that makes it print the two question marks. It'd be very useful if any of you could find it for me, maybe even explain the logic behind it.
Thanks to @lunaryorn's suggestions I've been able to locate the piece of code causing this. It looks like
format-mode-line eventually calls
decode_mode_spec to turn the format codes given into values. For the case of
%l this function does a few sanity checks to avoid spending too much time calculating, then checks whether the current line is exceeding
line-number-display-limit-width. Since that is the case for my file in question, it jumps to a
no_value label which returns a padded
?? as value.
"Solving" this involves setting the variable to a sufficiently high value:
(setq line-number-display-limit-width 2000000)
This value was derived by looking at the corresponding heuristics in
xdisp.c which takes the window height times two plus thirty and multiplies it with
line-number-display-limit-width, to avoid overflowing
most-positive-fixnum on a 32bit system, a value of 2000000 would be a safe bet.