From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Sam Steingold Newsgroups: gmane.emacs.devel Subject: line-number-at-pos Date: Wed, 03 Mar 2010 14:06:45 -0500 Message-ID: <4B8EB345.4050703@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1267645374 16796 80.91.229.12 (3 Mar 2010 19:42:54 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 3 Mar 2010 19:42:54 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Mar 03 20:42:46 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1NmuSz-0008To-1j for ged-emacs-devel@m.gmane.org; Wed, 03 Mar 2010 20:42:45 +0100 Original-Received: from localhost ([127.0.0.1]:59591 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NmuSy-000095-DN for ged-emacs-devel@m.gmane.org; Wed, 03 Mar 2010 14:42:44 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NmtuS-0001s6-Hv for emacs-devel@gnu.org; Wed, 03 Mar 2010 14:07:04 -0500 Original-Received: from [140.186.70.92] (port=39200 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NmtuR-0001rw-P5 for emacs-devel@gnu.org; Wed, 03 Mar 2010 14:07:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NmtuR-0001RO-5q for emacs-devel@gnu.org; Wed, 03 Mar 2010 14:07:03 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]:51763) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NmtuR-0001RI-0L for emacs-devel@gnu.org; Wed, 03 Mar 2010 14:07:03 -0500 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1NmtuP-0007rr-8N for emacs-devel@gnu.org; Wed, 03 Mar 2010 20:07:01 +0100 Original-Received: from 38.105.200.250 ([38.105.200.250]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 03 Mar 2010 20:07:01 +0100 Original-Received: from sds by 38.105.200.250 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 03 Mar 2010 20:07:01 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 18 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 38.105.200.250 User-Agent: Thunderbird 2.0.0.22 (X11/20090625) X-Enigmail-Version: 0.95.6 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:121614 Archived-At: 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)))