From: David Engster <deng@randomsample.de>
To: emacs-devel@gnu.org
Subject: Re: scrollbar alternative
Date: Mon, 15 Mar 2010 18:28:00 +0100 [thread overview]
Message-ID: <m2634xqyu7.fsf@imac-c2.pc.gwdg.de> (raw)
In-Reply-To: <m3eijl7d6t.fsf@verona.se> (joakim@verona.se's message of "Mon, 15 Mar 2010 17:38:18 +0100")
<joakim@verona.se> 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)
next prev parent reply other threads:[~2010-03-15 17:28 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-15 16:38 scrollbar alternative joakim
2010-03-15 17:28 ` David Engster [this message]
2010-03-15 18:20 ` Drew Adams
2010-03-15 19:57 ` David Engster
2010-03-15 19:41 ` Leo
2010-03-15 20:18 ` David Engster
2010-03-16 3:12 ` Zhu, Shenli
2010-03-16 4:34 ` Drew Adams
2010-03-16 6:24 ` Zhu, Shenli
2010-03-16 12:44 ` Lennart Borgman
2010-03-16 15:40 ` Drew Adams
2010-03-16 15:43 ` Lennart Borgman
2010-03-16 16:10 ` Drew Adams
2010-03-16 16:53 ` Lennart Borgman
2010-03-16 16:54 ` Deniz Dogan
2010-03-29 19:47 ` Progress indicator (was: scrollbar alternative) Leo
2010-03-29 19:54 ` Lennart Borgman
2010-03-29 21:30 ` Leo
2010-03-29 21:32 ` Lennart Borgman
2010-03-29 21:47 ` Eli Zaretskii
2010-03-15 18:36 ` scrollbar alternative Deniz Dogan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2634xqyu7.fsf@imac-c2.pc.gwdg.de \
--to=deng@randomsample.de \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.