all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Zhu, Shenli" <zhushenli2@gmail.com>
To: Drew Adams <drew.adams@oracle.com>
Cc: emacs-devel@gnu.org
Subject: Re: scrollbar alternative
Date: Tue, 16 Mar 2010 14:24:19 +0800	[thread overview]
Message-ID: <4B9F2413.8080309@gmail.com> (raw)
In-Reply-To: <CEA3CA7D2FE3406D869DB130CB9B2D4C@us.oracle.com>

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




  reply	other threads:[~2010-03-16  6:24 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
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 [this message]
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=4B9F2413.8080309@gmail.com \
    --to=zhushenli2@gmail.com \
    --cc=drew.adams@oracle.com \
    --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.