unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Adding total lines to modeline (NOT percentage)?
@ 2011-04-13 19:11 fork
  2011-04-14 18:10 ` Scott Frazer
  0 siblings, 1 reply; 4+ messages in thread
From: fork @ 2011-04-13 19:11 UTC (permalink / raw)
  To: help-gnu-emacs

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!




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Adding total lines to modeline (NOT percentage)?
  2011-04-13 19:11 Adding total lines to modeline (NOT percentage)? fork
@ 2011-04-14 18:10 ` Scott Frazer
  2011-04-14 23:03   ` Deniz Dogan
  0 siblings, 1 reply; 4+ messages in thread
From: Scott Frazer @ 2011-04-14 18:10 UTC (permalink / raw)
  To: fork; +Cc: help-gnu-emacs

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)))))



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Adding total lines to modeline (NOT percentage)?
  2011-04-14 18:10 ` Scott Frazer
@ 2011-04-14 23:03   ` Deniz Dogan
  2011-04-15  8:21     ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Deniz Dogan @ 2011-04-14 23:03 UTC (permalink / raw)
  To: Scott Frazer; +Cc: fork, help-gnu-emacs

2011/4/14 Scott Frazer <frazer.scott@gmail.com>:
> 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



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Adding total lines to modeline (NOT percentage)?
  2011-04-14 23:03   ` Deniz Dogan
@ 2011-04-15  8:21     ` Eli Zaretskii
  0 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2011-04-15  8:21 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Deniz Dogan <deniz.a.m.dogan@gmail.com>
> Date: Fri, 15 Apr 2011 01:03:50 +0200
> Cc: fork <forkandwait@gmail.com>, help-gnu-emacs@gnu.org
> 
> > (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.

You bet!  The default method has some clever wizardry in the display
engine to not count too many lines unless necessary.  If we want to
support N/M display, we should make it part of the display engine, to
avoid re-counting each time redisplay is entered.  Patches are welcome.




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-04-15  8:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-13 19:11 Adding total lines to modeline (NOT percentage)? fork
2011-04-14 18:10 ` Scott Frazer
2011-04-14 23:03   ` Deniz Dogan
2011-04-15  8:21     ` Eli Zaretskii

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).