* line-number-at-pos
@ 2010-03-03 19:06 Sam Steingold
0 siblings, 0 replies; only message in thread
From: Sam Steingold @ 2010-03-03 19:06 UTC (permalink / raw)
To: emacs-devel
in simple.el:
(defun line-number-at-pos (&optional pos)
"Return (narrowed) buffer line number at position POS.
If POS is nil, use current buffer location.
Counting starts at (point-min), so the value refers
to the contents of the accessible portion of the buffer."
(let ((opoint (or pos (point))) start)
(save-excursion
(goto-char (point-min))
(setq start (point))
(goto-char opoint)
(forward-line 0)
(1+ (count-lines start (point))))))
why not just
(count-lines (point-min) (or pos (point)))
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-03-03 19:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-03 19:06 line-number-at-pos Sam Steingold
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).