[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: scrollbar alternative
From: |
Drew Adams |
Subject: |
RE: scrollbar alternative |
Date: |
Mon, 15 Mar 2010 21:34:41 -0700 |
> 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))))
- scrollbar alternative, joakim, 2010/03/15
- Re: scrollbar alternative, David Engster, 2010/03/15
- RE: scrollbar alternative, Drew Adams, 2010/03/15
- Re: scrollbar alternative, Leo, 2010/03/15
- Re: scrollbar alternative, David Engster, 2010/03/15
- Re: scrollbar alternative, Zhu, Shenli, 2010/03/15
- RE: scrollbar alternative,
Drew Adams <=
- Re: scrollbar alternative, Zhu, Shenli, 2010/03/16
- Re: scrollbar alternative, Lennart Borgman, 2010/03/16
- RE: scrollbar alternative, Drew Adams, 2010/03/16
- Re: scrollbar alternative, Lennart Borgman, 2010/03/16
- RE: scrollbar alternative, Drew Adams, 2010/03/16
- Re: scrollbar alternative, Lennart Borgman, 2010/03/16
- Re: scrollbar alternative, Deniz Dogan, 2010/03/16
- Progress indicator (was: scrollbar alternative), Leo, 2010/03/29
- Re: Progress indicator (was: scrollbar alternative), Lennart Borgman, 2010/03/29
- Re: Progress indicator (was: scrollbar alternative), Leo, 2010/03/29