From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: storm@cua.dk (Kim F. Storm) Newsgroups: gmane.emacs.devel Subject: Re: [patch] add interactive browse of revisions from vc *Annotate* buffers Date: 21 Jan 2004 17:39:31 +0100 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: References: <1073937837.2822.180.camel@localhost> <1074519239.10692.24.camel@localhost> <87u12rbrlf.fsf@emptyhost.emptydomain.de> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1074701780 5213 80.91.224.253 (21 Jan 2004 16:16:20 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 21 Jan 2004 16:16:20 +0000 (UTC) Cc: brutt+news@bloomington.in.us, kai@emptydomain.de, rms@gnu.org, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Wed Jan 21 17:16:10 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AjL1V-00014j-00 for ; Wed, 21 Jan 2004 17:16:09 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1AjL1V-0001cW-00 for ; Wed, 21 Jan 2004 17:16:09 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AjL1D-0001Ls-QM for emacs-devel@quimby.gnus.org; Wed, 21 Jan 2004 11:15:51 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1AjKyy-0000fo-DN for emacs-devel@gnu.org; Wed, 21 Jan 2004 11:13:32 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1AjKyR-0000RX-C1 for emacs-devel@gnu.org; Wed, 21 Jan 2004 11:13:30 -0500 Original-Received: from [212.88.64.25] (helo=mail-relay.sonofon.dk) by monty-python.gnu.org with smtp (Exim 4.24) id 1AjKSQ-0008Ic-3k for emacs-devel@gnu.org; Wed, 21 Jan 2004 10:39:54 -0500 Original-Received: (qmail 44529 invoked from network); 21 Jan 2004 15:39:39 -0000 Original-Received: from unknown (HELO kfs-l.imdomain.dk.cua.dk) (213.83.150.2) by 0 with SMTP; 21 Jan 2004 15:39:39 -0000 Original-To: Stefan Monnier In-Reply-To: Original-Lines: 46 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:19404 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:19404 Stefan Monnier writes: > > (defun line-at-pos (&optional pos) > > "Return buffer line number and narrowed line number at position POS. > > If POS is nil, use current buffer location. > > Return value is a cons (line-number . narrowed-line-number)." > > I suggest to only return narrowed-line-number (i.e. ignore narrowing). > After all, most/all functions are expected to ignore narrowing unless they > specifically need to know about it. > > `what-line' can still make use of such a function by doing the widening > itself like it used to (and use the same optimization you suggested). > How about this version? (defun line-at-pos (&optional pos start) "Return (narrowed) buffer line number at position POS. If POS is nil, use current buffer location. If START is non-nil, count lines from that buffer position, even if narrowing is in effect." (let ((opoint (or pos (point)))) (save-excursion (save-restriction (goto-char (point-min)) (widen) (if start (goto-char start)) (forward-line 0) (setq start (point)) (goto-char opoint) (forward-line 0) (1+ (count-lines start (point))))))) (defun what-line () "Print the current buffer line number and narrowed line number of point." (interactive) (let ((l1 (line-at-pos (point-min) 0)) (l2 (line-at-pos (point) (point-min)))) (if (> l1 1) (message "line %d (narrowed line %d)" (+ l1 l2 -1) l2) (message "Line %d" l2)))) -- Kim F. Storm http://www.cua.dk