unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Efficiently getting the line at point
@ 2009-09-18 14:30 Nordlöw
  2009-09-18 15:02 ` Eli Zaretskii
  0 siblings, 1 reply; 2+ messages in thread
From: Nordlöw @ 2009-09-18 14:30 UTC (permalink / raw)
  To: help-gnu-emacs

How do I efficiently get the current line at a given position?

Is line-number-at-pos() the best candidate?
This function in turn calls count-lines().
Why? --- I thought Emacs had an internal O(1) lookup table for the
positions of line beginnings of a buffer or file.

Thanks in advance,
Per Nordlöw


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

* Re: Efficiently getting the line at point
  2009-09-18 14:30 Efficiently getting the line at point Nordlöw
@ 2009-09-18 15:02 ` Eli Zaretskii
  0 siblings, 0 replies; 2+ messages in thread
From: Eli Zaretskii @ 2009-09-18 15:02 UTC (permalink / raw)
  To: help-gnu-emacs

> From: =?ISO-8859-1?Q?Nordl=F6w?= <per.nordlow@gmail.com>
> Date: Fri, 18 Sep 2009 07:30:19 -0700 (PDT)
> 
> I thought Emacs had an internal O(1) lookup table for the positions
> of line beginnings of a buffer or file.

It doesn't.  line-number-at-pos is what you are looking for.





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

end of thread, other threads:[~2009-09-18 15:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-18 14:30 Efficiently getting the line at point Nordlöw
2009-09-18 15:02 ` 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).