From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Engster Newsgroups: gmane.emacs.devel Subject: Re: scrollbar alternative Date: Mon, 15 Mar 2010 18:28:00 +0100 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1268674762 13901 80.91.229.12 (15 Mar 2010 17:39:22 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 15 Mar 2010 17:39:22 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Mar 15 18:39:17 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 1NrEG4-0007mZ-Cu for ged-emacs-devel@m.gmane.org; Mon, 15 Mar 2010 18:39:16 +0100 Original-Received: from localhost ([127.0.0.1]:45525 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NrEG3-0000Dg-PF for ged-emacs-devel@m.gmane.org; Mon, 15 Mar 2010 13:39:15 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NrE5Y-0004Kg-CZ for emacs-devel@gnu.org; Mon, 15 Mar 2010 13:28:24 -0400 Original-Received: from [140.186.70.92] (port=45978 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NrE5W-0004IM-8P for emacs-devel@gnu.org; Mon, 15 Mar 2010 13:28:23 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NrE5N-0004bw-Jw for emacs-devel@gnu.org; Mon, 15 Mar 2010 13:28:22 -0400 Original-Received: from m61s02.vlinux.de ([83.151.21.164]:48804) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NrE5N-0004Zl-BU for emacs-devel@gnu.org; Mon, 15 Mar 2010 13:28:13 -0400 Original-Received: from imac-c2.pc.gwdg.de ([134.76.4.139]) by m61s02.vlinux.de with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.69) (envelope-from ) id 1NrE5G-0001Ci-Fc for emacs-devel@gnu.org; Mon, 15 Mar 2010 18:28:06 +0100 In-Reply-To: (joakim@verona.se's message of "Mon, 15 Mar 2010 17:38:18 +0100") User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.1.92 (darwin) Mail-Followup-To: emacs-devel@gnu.org 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:122012 Archived-At: writes: > David Engster wrote a neat package called minimap.el. It renders the > current buffer with tiny fonts, in a mini window besides the current > buffer. The mini-window has an overlay showing the position in the main window. > > It could be modified to replace a scrollbar. > > I sometimes use minimap.el, but I never use scrollbars. Maybe that's a bit much. I think the minimap is useful for certain things, like getting a quick glance of the overall structure of some code. Like many others, I never used the scrollbars for scrolling, but for getting a quick and rough impression on a) the size of the buffer, and b) the part of the buffer which is currently displayed. To me, the GTK scrollbars always behaved a bit strange in this regard, anyway. For example, I think scrollbars should be hidden when there is nothing to scroll, this way giving you an immediate optical hint that you're currently seeing everything there is. But in Emacs, you can always scroll the window until (window-start) reaches (point-max). Therefore, I also disabled the scrollbar and now use some code to get a scrollbar-like display in the mode-line. I know there's size-indication-mode, but I find an information like "13% of 2.8k" not very helpful. Regards, David This is the code I currently use: (defvar size-mode-line-max-length 30) (defvar size-mode-line-beginstr "--[") (defvar size-mode-line-endstr "]--") (defun size-mode-line-create () (let* ((start (window-start)) (end (window-end)) (mlength (if (evenp size-mode-line-length) (1- size-mode-line-length) size-mode-line-length)) (beginning (floor (* (/ (float start) (float (point-max))) mlength))) (percentage (/ (float end) (float (point-max)))) (end (ceiling (* percentage mlength))) string) (if (or (< end mlength) (> start (point-min))) (progn (setq string (concat size-mode-line-beginstr (make-string (- (/ mlength 2) 2) 32) (format "%3d" (round (* percentage 100))) "%%" (make-string (- (/ mlength 2) 2) 32) size-mode-line-endstr)) (setq beginning (+ beginning (length size-mode-line-beginstr))) (when (= beginning (setq end (+ end (length size-mode-line-beginstr)))) (setq end (1+ end))) (when (and (= (elt string beginning) 37) (= (elt string end) 37)) (setq end (1+ end))) (put-text-property beginning end 'face `(:background ,(face-foreground 'mode-line) :foreground ,(face-background 'mode-line)) string) string) ""))) (add-to-list 'global-mode-string '(:eval (size-mode-line-create)) t)