From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juanma Barranquero Newsgroups: gmane.emacs.bugs Subject: bug#5042: 23.1; linum-mode gives incorrect line numbers with narrowed buffers Date: Thu, 10 Dec 2009 12:41:21 +0100 Message-ID: References: <200911260039.nAQ0dTD1019384@mailhub-pa1.hpl.hp.com> <200912100534.nBA5YSva008256@mailhub-pa1.hpl.hp.com> Reply-To: Juanma Barranquero , 5042@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1260447520 7810 80.91.229.12 (10 Dec 2009 12:18:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 10 Dec 2009 12:18:40 +0000 (UTC) Cc: 5042@emacsbugs.donarmstrong.com To: mark.lillibridge@hp.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Dec 10 13:18:33 2009 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NIhya-0006ek-UN for geb-bug-gnu-emacs@m.gmane.org; Thu, 10 Dec 2009 13:18:33 +0100 Original-Received: from localhost ([127.0.0.1]:58753 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NIhya-0006fV-IB for geb-bug-gnu-emacs@m.gmane.org; Thu, 10 Dec 2009 07:18:32 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NIho2-00065B-Jd for bug-gnu-emacs@gnu.org; Thu, 10 Dec 2009 07:07:38 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NIhnu-00062R-UZ for bug-gnu-emacs@gnu.org; Thu, 10 Dec 2009 07:07:35 -0500 Original-Received: from [199.232.76.173] (port=45290 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NIhnt-000620-Ht for bug-gnu-emacs@gnu.org; Thu, 10 Dec 2009 07:07:30 -0500 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:37888) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NIhns-0001qi-TY for bug-gnu-emacs@gnu.org; Thu, 10 Dec 2009 07:07:29 -0500 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nBAC7QJk025484; Thu, 10 Dec 2009 04:07:26 -0800 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.14.3/8.14.3/Submit) id nBABo4VG022927; Thu, 10 Dec 2009 03:50:04 -0800 Resent-Date: Thu, 10 Dec 2009 03:50:04 -0800 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: Juanma Barranquero Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs 2Resent-Date: Thu, 10 Dec 2009 11:50:04 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: followup 5042 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by 5042-submit@emacsbugs.donarmstrong.com id=B5042.126044530922337 (code B ref 5042); Thu, 10 Dec 2009 11:50:04 +0000 Original-Received: (at 5042) by emacsbugs.donarmstrong.com; 10 Dec 2009 11:41:49 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from mail-fx0-f215.google.com (mail-fx0-f215.google.com [209.85.220.215]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nBABflif022334 for <5042@emacsbugs.donarmstrong.com>; Thu, 10 Dec 2009 03:41:48 -0800 Original-Received: by fxm7 with SMTP id 7so7638382fxm.9 for <5042@emacsbugs.donarmstrong.com>; Thu, 10 Dec 2009 03:41:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=3O3R9Hk/kNJ/DpP8z+rL/C04N0JGSpdB1yIYfQWONdM=; b=W+H0lxT6re8AO8iLFnnJO10Q4bizp+5CRh4cFh7FO6x+xiLlmR1kYcWM9jR+qF5mQn WoQNIOvt23K2MndtUznaJGBltR1WK6ZvPTJbgHqSFiGPP0ic9xTOhxM+9bIP41uIhC6h 22vEZ5xjqg9Ksk3prVHVcAUgSyevjn95l8axc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=MfyLuxvDWgLAKzqlA7vvpJF+oC8VT+mHHAMl9d059Avu2Cd0YaEttwTsyPE6MaOhBn tWO90oHcP3UNYBqSzjyjlHl2eoE140Rg3MQJRP551Da6Efj3yI/GNPzJA8hZPEiDMylg ZTgz4MdClOTpG6o+biJBQQP4wcMBRUpGYX0wg= Original-Received: by 10.239.168.195 with SMTP id l3mr1165416hbe.27.1260445301108; Thu, 10 Dec 2009 03:41:41 -0800 (PST) In-Reply-To: <200912100534.nBA5YSva008256@mailhub-pa1.hpl.hp.com> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Resent-Date: Thu, 10 Dec 2009 07:07:35 -0500 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:33460 Archived-At: On Thu, Dec 10, 2009 at 06:34, Mark Lillibridge w= rote: > =C2=A0 =C2=A0The entire point of having line numbers is that they corresp= ond to > something useful. Either an external program's line number (e.g., a gcc > error number) or an internal Emacs notion such as that provided by > goto-line. =C2=A0The current behavior does neither. Well, there are many definitions of useful. I find the current behavior useful, because my main use of linum is knowing at a glance how many lines there are in the file (or in the region, if narrowing is in effect). > =C2=A0 =C2=A0Note that other line numbering modes like wb-line-number imp= lement > the behavior that I describe as correct. Yes. But linum allows you to use line numbers in a quite more flexible way. You could do (defvar num-of-lines nil) (defvar num-format nil) (make-variable-buffer-local 'num-of-lines) (make-variable-buffer-local 'num-format) (add-hook 'linum-before-numbering-hook (lambda () (save-restriction (widen) (let ((lines (count-lines (point-min) (point-max)))) (setq num-format (format "%%%dd" (length (int-to-string lines)))) (setq num-of-lines (1+ lines)))))) (setq linum-format (lambda (line) (format num-format (- num-of-lines line)))) if you fancied numbering lines in reverse, for example. Juanma