help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Adding total lines to modeline (NOT percentage)?


From: Deniz Dogan
Subject: Re: Adding total lines to modeline (NOT percentage)?
Date: Fri, 15 Apr 2011 01:03:50 +0200

2011/4/14 Scott Frazer <address@hidden>:
> On 4/13/11 3:11 PM, fork wrote:
>>
>> Is there a way to customize my modeline such that I can see the total
>> number of
>> lines of the current file?
>>
>> The percentage is not particularly interesting to me...
>>
>> Thanks!
>>
>
> I use these forms in my `mode-line-format' variable to show
> "current_line/total_num_lines":
>
> (list 'line-number-mode "  L%l/")
> (list 'line-number-mode (:eval (int-to-string (count-lines (point-min)
> (point-max)))))
>
>

Note that this method will be affected by narrowing. To get the full
number of lines in the buffer use (1+ (count-lines 1 (buffer-size))).
This could also get rather sluggish when used in large buffers. The
best way would probably be to use a timer to recalculate the number of
lines in the buffer and then use that.

-- 
Deniz Dogan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]