From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.devel Subject: RE: scrollbar alternative Date: Mon, 15 Mar 2010 21:34:41 -0700 Message-ID: References: <87vdcxwd7r.fsf@engster.org> <4B9EF736.2040203@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1268715986 11907 80.91.229.12 (16 Mar 2010 05:06:26 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 16 Mar 2010 05:06:26 +0000 (UTC) To: "'Zhu, Shenli'" , Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Mar 16 06:06:21 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 1NrOyL-0008HY-4P for ged-emacs-devel@m.gmane.org; Tue, 16 Mar 2010 06:06:20 +0100 Original-Received: from localhost ([127.0.0.1]:33943 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NrOy2-0008Gg-9d for ged-emacs-devel@m.gmane.org; Tue, 16 Mar 2010 01:05:22 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NrOxv-0008GG-Su for emacs-devel@gnu.org; Tue, 16 Mar 2010 01:05:15 -0400 Original-Received: from [140.186.70.92] (port=36785 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NrOxu-0008FW-1G for emacs-devel@gnu.org; Tue, 16 Mar 2010 01:05:15 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NrOxr-0006wa-Ib for emacs-devel@gnu.org; Tue, 16 Mar 2010 01:05:13 -0400 Original-Received: from rcsinet12.oracle.com ([148.87.113.124]:59712) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NrOxr-0006wU-Am for emacs-devel@gnu.org; Tue, 16 Mar 2010 01:05:11 -0400 Original-Received: from acsinet15.oracle.com (acsinet15.oracle.com [141.146.126.227]) by rcsinet12.oracle.com (Switch-3.4.2/Switch-3.4.2) with ESMTP id o2G557OH006710 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 16 Mar 2010 05:05:09 GMT Original-Received: from acsmt355.oracle.com (acsmt355.oracle.com [141.146.40.155]) by acsinet15.oracle.com (Switch-3.4.2/Switch-3.4.1) with ESMTP id o2G54mPF023258; Tue, 16 Mar 2010 05:05:07 GMT Original-Received: from abhmt019.oracle.com by acsmt354.oracle.com with ESMTP id 83625241268715902; Mon, 15 Mar 2010 22:05:02 -0700 Original-Received: from dradamslap1 (/10.175.206.45) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 15 Mar 2010 21:34:42 -0700 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: <4B9EF736.2040203@gmail.com> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 Thread-Index: AcrEtxmJZt39AS+USrKrziqvNhLaDgABIAwg X-Source-IP: acsmt355.oracle.com [141.146.40.155] X-Auth-Type: Internal IP X-CT-RefId: str=0001.0A090203.4B9F1183.00D3:SCFMA4539814,ss=1,fgs=0 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:122038 Archived-At: > 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))))