From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Zhu, Shenli" Newsgroups: gmane.emacs.devel Subject: Re: scrollbar alternative Date: Tue, 16 Mar 2010 14:24:19 +0800 Message-ID: <4B9F2413.8080309@gmail.com> References: <87vdcxwd7r.fsf@engster.org> <4B9EF736.2040203@gmail.com> 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 1268720688 22427 80.91.229.12 (16 Mar 2010 06:24:48 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 16 Mar 2010 06:24:48 +0000 (UTC) Cc: emacs-devel@gnu.org To: Drew Adams Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Mar 16 07:24:42 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 1NrQCo-00034F-6d for ged-emacs-devel@m.gmane.org; Tue, 16 Mar 2010 07:24:42 +0100 Original-Received: from localhost ([127.0.0.1]:55949 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NrQCm-0002wr-T3 for ged-emacs-devel@m.gmane.org; Tue, 16 Mar 2010 02:24:40 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NrQCc-0002wE-SE for emacs-devel@gnu.org; Tue, 16 Mar 2010 02:24:30 -0400 Original-Received: from [140.186.70.92] (port=51386 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NrQCb-0002vL-Bs for emacs-devel@gnu.org; Tue, 16 Mar 2010 02:24:30 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NrQCa-0004Wi-BF for emacs-devel@gnu.org; Tue, 16 Mar 2010 02:24:29 -0400 Original-Received: from mail-gw0-f41.google.com ([74.125.83.41]:46196) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NrQCa-0004Wc-5c for emacs-devel@gnu.org; Tue, 16 Mar 2010 02:24:28 -0400 Original-Received: by gwb17 with SMTP id 17so3899625gwb.0 for ; Mon, 15 Mar 2010 23:24:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=FGCH6sTGv2SnO8Fdgn/5DvS+UoeXmw8yDsnpciCMZJs=; b=kQLqBVZNpe1gFmlAK5jb6y/cAq7bVuWymniZaO5xdB1JxByrHZ6kMcBOE0n0NHHiqG 90mC1Txqdw49iHNs1Po4Qls+ynXXOum5hnC2yDNGNJNw1VBD9xQek1xcBz60/amFeUSc cuFySQeBm0fFZbdZp4vLW29irOcC/MqG38yxU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=uMsnew6lzXzEO59SIrp/FS264SWBmR7TqofbBp+bUjAUrxOiHCqs25MMmqDapY/VYa n6uKwUvXOWksudhHYSwius22+nc61JPHBTJd8H9gfNWuSkP82STSLS6fbEAbjitK9JFy We6jfY4y85jgcudHVZlAMoNfrIr2OJLNWiwhg= Original-Received: by 10.101.94.20 with SMTP id w20mr3403072anl.112.1268720667555; Mon, 15 Mar 2010 23:24:27 -0700 (PDT) Original-Received: from [116.232.80.210] ([116.232.80.210]) by mx.google.com with ESMTPS id 6sm1680985yxg.48.2010.03.15.23.24.23 (version=SSLv3 cipher=RC4-MD5); Mon, 15 Mar 2010 23:24:26 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3 In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) 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:122043 Archived-At: On 03/16/2010 12:34 PM, Drew Adams wrote: >> I tried to copy your code to my .emacs file, but my mode bar >> doesn't change like yours. Shall I change something else? >> > If your window is not wide enough, it might actually be "showing", but off to > the right, too far for you to see (outside the window). The mode line can be > truncated at the right, depending on the window width. If you make your window > wider, you might see the indicator. > > (That explanation doesn't apply if your Emacs version is 21 - in that case, the > indicator appears just after the buffer name.) > > Try this (same code, just tweaked a bit, mainly to avoid wrapping by my mailer). > The last line here moves the indicator to where the size indicator normally is, > just after the buffer name, so you should be able to see it OK. > > (defvar sml-len 12) > (defvar sml-begin "[") > (defvar sml-end "]") > > (defun sml-create () > (let* ((start (window-start)) > (end (window-end)) > (mlength (if (eq (logand sml-len 1) 0) ; Even? > (1- sml-len) > sml-len)) > (start > (floor (* (/ (float start) > (float (point-max))) mlength))) > (percentage (/ (float end) (float (point-max)))) > (end (ceiling (* percentage mlength))) > string) > (if (not (or (< end mlength) (> start (point-min)))) > "" > (setq string > (concat sml-begin > (make-string (- (/ mlength 2) 2) 32) > (format > "%3d" (round (* percentage 100))) "%%" > (make-string (- (/ mlength 2) 2) 32) > sml-end) > start (+ start (length sml-begin))) > (when (= start > (setq end (+ end (length sml-begin)))) > (setq end (1+ end))) > (when (and (= (elt string start) 37) > (= (elt string end) 37)) > (setq end (1+ end))) > (put-text-property > start end > 'face `(:background ,(face-foreground 'mode-line) > :foreground ,(face-background 'mode-line)) > string) > string))) > > (setcar mode-line-position '(:eval (list (sml-create)))) > > Hi Drew, The code works well on Emacs23, thanks! Shenli