* scrollbar alternative
@ 2010-03-15 16:38 joakim
2010-03-15 17:28 ` David Engster
2010-03-15 18:36 ` scrollbar alternative Deniz Dogan
0 siblings, 2 replies; 21+ messages in thread
From: joakim @ 2010-03-15 16:38 UTC (permalink / raw)
To: Emacs development discussions
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.
--
Joakim Verona
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: scrollbar alternative
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:41 ` Leo
2010-03-15 18:36 ` scrollbar alternative Deniz Dogan
1 sibling, 2 replies; 21+ messages in thread
From: David Engster @ 2010-03-15 17:28 UTC (permalink / raw)
To: emacs-devel
<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)
^ permalink raw reply [flat|nested] 21+ messages in thread
* RE: scrollbar alternative
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
1 sibling, 1 reply; 21+ messages in thread
From: Drew Adams @ 2010-03-15 18:20 UTC (permalink / raw)
To: 'David Engster', emacs-devel
> 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.
>
> (defvar size-mode-line-max-length 30)
Presumably, you meant `size-mode-line-length', which is what is used in the rest
of the code.
(Why not replace %p too, instead of having both?)
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: scrollbar alternative
2010-03-15 16:38 scrollbar alternative joakim
2010-03-15 17:28 ` David Engster
@ 2010-03-15 18:36 ` Deniz Dogan
1 sibling, 0 replies; 21+ messages in thread
From: Deniz Dogan @ 2010-03-15 18:36 UTC (permalink / raw)
To: joakim; +Cc: Emacs development discussions
2010/3/15 <joakim@verona.se>:
> 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.
>
> --
> Joakim Verona
>
>
>
For anyone too lazy to use Google, here is minimap.el:
http://www.randomsample.de/minimap.el
I was actually thinking about something like this when I read the
thread about the scrollbars (OT: they should be on the right ;)). I
think the idea is very cool and I'd love to see something like this
integrated with Emacs.
--
Deniz Dogan
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: scrollbar alternative
2010-03-15 17:28 ` David Engster
2010-03-15 18:20 ` Drew Adams
@ 2010-03-15 19:41 ` Leo
2010-03-15 20:18 ` David Engster
1 sibling, 1 reply; 21+ messages in thread
From: Leo @ 2010-03-15 19:41 UTC (permalink / raw)
To: emacs-devel
On 2010-03-15 17:28 +0000, David Engster wrote:
> 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.
Does your code just show the percentage in a fancy face?
I turned off scrollbar too and use fringe arrows and percentage on the
modeline. I tried your code but didn't notice any difference.
Leo
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: scrollbar alternative
2010-03-15 18:20 ` Drew Adams
@ 2010-03-15 19:57 ` David Engster
0 siblings, 0 replies; 21+ messages in thread
From: David Engster @ 2010-03-15 19:57 UTC (permalink / raw)
To: emacs-devel
Drew Adams <drew.adams@oracle.com> writes:
>> 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.
>>
>> (defvar size-mode-line-max-length 30)
>
> Presumably, you meant `size-mode-line-length', which is what is used in the rest
> of the code.
Yes, of course. That happens when you do some last minute tinkering
before posting...
> (Why not replace %p too, instead of having both?)
The percentages are slightly different, but I agree that doesn't really
matter.
-David
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: scrollbar alternative
2010-03-15 19:41 ` Leo
@ 2010-03-15 20:18 ` David Engster
2010-03-16 3:12 ` Zhu, Shenli
0 siblings, 1 reply; 21+ messages in thread
From: David Engster @ 2010-03-15 20:18 UTC (permalink / raw)
To: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 1009 bytes --]
Leo <sdl.web@gmail.com> writes:
> On 2010-03-15 17:28 +0000, David Engster wrote:
>> 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.
>
> Does your code just show the percentage in a fancy face?
>
> I turned off scrollbar too and use fringe arrows and percentage on the
> modeline. I tried your code but didn't notice any difference.
It displays the percentage and displays a moving bar, just like a
scrollbar, but you can't drag it. It should look something like this:
[-- Attachment #2: scroll-mode-line.jpg --]
[-- Type: image/jpeg, Size: 2091 bytes --]
[-- Attachment #3: Type: text/plain, Size: 8 bytes --]
-David
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: scrollbar alternative
2010-03-15 20:18 ` David Engster
@ 2010-03-16 3:12 ` Zhu, Shenli
2010-03-16 4:34 ` Drew Adams
0 siblings, 1 reply; 21+ messages in thread
From: Zhu, Shenli @ 2010-03-16 3:12 UTC (permalink / raw)
To: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 1343 bytes --]
On 03/16/2010 04:18 AM, David Engster wrote:
> Leo<sdl.web@gmail.com> writes:
>
>> On 2010-03-15 17:28 +0000, David Engster wrote:
>>
>>> 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.
>>>
>> Does your code just show the percentage in a fancy face?
>>
>> I turned off scrollbar too and use fringe arrows and percentage on the
>> modeline. I tried your code but didn't notice any difference.
>>
> It displays the percentage and displays a moving bar, just like a
> scrollbar, but you can't drag it. It should look something like this:
>
>
>
>
>
> -David
>
Hi David,
I tried to copy your code to my .emacs file, but my mode bar doesn't
change like yours. Shall I change something else?
My mode bar look like:
mode bar only percentage
Thanks in advance!
Shenli
[-- Attachment #2.1: Type: text/html, Size: 2028 bytes --]
[-- Attachment #2.2: mode-bar.png --]
[-- Type: image/png, Size: 4920 bytes --]
^ permalink raw reply [flat|nested] 21+ messages in thread
* RE: scrollbar alternative
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
0 siblings, 2 replies; 21+ messages in thread
From: Drew Adams @ 2010-03-16 4:34 UTC (permalink / raw)
To: 'Zhu, Shenli', emacs-devel
> 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))))
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: scrollbar alternative
2010-03-16 4:34 ` Drew Adams
@ 2010-03-16 6:24 ` Zhu, Shenli
2010-03-16 12:44 ` Lennart Borgman
1 sibling, 0 replies; 21+ messages in thread
From: Zhu, Shenli @ 2010-03-16 6:24 UTC (permalink / raw)
To: Drew Adams; +Cc: emacs-devel
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
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: scrollbar alternative
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-29 19:47 ` Progress indicator (was: scrollbar alternative) Leo
1 sibling, 2 replies; 21+ messages in thread
From: Lennart Borgman @ 2010-03-16 12:44 UTC (permalink / raw)
To: Drew Adams; +Cc: emacs-devel, Zhu, Shenli
[-- Attachment #1: Type: text/plain, Size: 1019 bytes --]
On Tue, Mar 16, 2010 at 5:34 AM, Drew Adams <drew.adams@oracle.com> 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.
I like the feature. I think something like this should be in Emacs.
Attached is a little bit more elaborated version. Name suggestions are welcome.
[-- Attachment #2: sml-modeline.el --]
[-- Type: text/plain, Size: 4756 bytes --]
;;; sml-modeline.el --- Show position in a scrollbar like way in mode-line
;;
;; Author: Lennart Borgman (lennart O borgman A gmail O com)
;; Created: 2010-03-16 Tue
;; Version:
;; Last-Updated:
;; URL:
;; Keywords:
;; Compatibility:
;;
;; Features that might be required by this library:
;;
;; None
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Commentary:
;;
;; Show scrollbar like position indicator in mode line.
;;
;; Idea and part of this code is adapted from Drew Adam's code in this
;; mail message:
;;
;; http://permalink.gmane.org/gmane.emacs.devel/122038
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Change log:
;;
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 3, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
;; Floor, Boston, MA 02110-1301, USA.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Code:
(defgroup sml-modeline nil
"Customization group for `sml-mode'."
:group 'frames)
(defcustom sml-len 12
"Mode line indicator total length."
:type 'integer
:group 'sml-modeline)
(defcustom sml-borders nil
"Indicator borders.
This is a pair of indicators, like [] or nil."
:type '(choice (const :tag "None" nil)
(cons (string :tag "Left border")
(string :tag "Right border")))
:group 'sml-modeline)
;;(sml-create)
(defun sml-create ()
(let* ((wstart (window-start))
(wend (window-end))
(real-point-max (save-restriction (widen) (point-max)))
(percentage-beg (/ (float wstart) (float real-point-max)))
(percentage-end (/ (float wend) (float real-point-max)))
(sml-begin (or (car sml-borders) ""))
(sml-end (or (cdr sml-borders) ""))
(inner-len (- sml-len (length sml-begin) (length sml-end)))
bpad-len
epad-len
(start (floor (* percentage-beg inner-len)))
(end (ceiling (* percentage-end inner-len)))
string)
(if (not (or (< wend real-point-max) (> wstart 1)))
""
(setq string
(concat (format "%02d" (round (* percentage-beg 100))) ""
"-"
(format "%02d" (round (* percentage-end 100))) "%%"
))
(setq bpad-len (/ (- inner-len (length string)) 2))
(setq epad-len (- inner-len (length string) bpad-len))
(setq string (concat sml-begin
(make-string bpad-len 32)
string
(make-string epad-len 32)
sml-end))
(assert (= (length string) sml-len) t)
(setq 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)
(when (and (= 0 (length sml-begin))
(= 0 (length sml-end)))
(put-text-property
0 start
'face `(:background ,(face-foreground 'mode-line-inactive)
:foreground ,(face-background 'mode-line))
string)
(put-text-property
end sml-len
'face `(:background ,(face-foreground 'mode-line-inactive)
:foreground ,(face-background 'mode-line))
string)
)
string)))
(defvar sml-old-car-mode-line-position nil)
(define-minor-mode sml-mode
"Show buffer size and position like scrollbar in mode line."
:global t
:group 'sml-modeline
(if sml-mode
(progn
(unless sml-old-car-mode-line-position
(setq sml-old-car-mode-line-position (car mode-line-position)))
(setcar mode-line-position '(:eval (list (sml-create)))))
(setcar mode-line-position sml-old-car-mode-line-position)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; sml-modeline.el ends here
^ permalink raw reply [flat|nested] 21+ messages in thread
* RE: scrollbar alternative
2010-03-16 12:44 ` Lennart Borgman
@ 2010-03-16 15:40 ` Drew Adams
2010-03-16 15:43 ` Lennart Borgman
2010-03-29 19:47 ` Progress indicator (was: scrollbar alternative) Leo
1 sibling, 1 reply; 21+ messages in thread
From: Drew Adams @ 2010-03-16 15:40 UTC (permalink / raw)
To: 'Lennart Borgman'; +Cc: emacs-devel, 'Zhu, Shenli'
> > 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.
>
>
> I like the feature. I think something like this should be in Emacs.
>
> Attached is a little bit more elaborated version. Name
> suggestions are welcome.
One comment: Your file header says:
;; Idea and part of this code is adapted from Drew Adam's code in this
;; mail message:
;; http://permalink.gmane.org/gmane.emacs.devel/122038
The original code is from David Engster, not me. The OP is here:
http://lists.gnu.org/archive/html/emacs-devel/2010-03/msg00523.html
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: scrollbar alternative
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:54 ` Deniz Dogan
0 siblings, 2 replies; 21+ messages in thread
From: Lennart Borgman @ 2010-03-16 15:43 UTC (permalink / raw)
To: Drew Adams; +Cc: emacs-devel, Zhu, Shenli
On Tue, Mar 16, 2010 at 4:40 PM, Drew Adams <drew.adams@oracle.com> wrote:
>
> One comment: Your file header says:
>
> ;; Idea and part of this code is adapted from Drew Adam's code in this
> ;; mail message:
> ;; http://permalink.gmane.org/gmane.emacs.devel/122038
>
> The original code is from David Engster, not me. The OP is here:
> http://lists.gnu.org/archive/html/emacs-devel/2010-03/msg00523.html
Thanks Drew. Sorry David.
BTW there are some minor problems with the code. I will (as usual) try
to fix them and put the code in the nXhtml repository for the moment.
^ permalink raw reply [flat|nested] 21+ messages in thread
* RE: scrollbar alternative
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
1 sibling, 1 reply; 21+ messages in thread
From: Drew Adams @ 2010-03-16 16:10 UTC (permalink / raw)
To: 'Lennart Borgman'; +Cc: emacs-devel, 'Zhu, Shenli'
> BTW there are some minor problems with the code. I will (as usual) try
> to fix them and put the code in the nXhtml repository for the moment.
Yes, like:
1. (eval-when-compile (require 'cl)) ; assert
2. Remove the :background for the left and right portions (or define it as
something different). It is often the case that the inactive mode-line
foreground is the same as the mode-line foreground, which means, e.g., black on
black - no movement shown.
3. Change the default value of `sml-borders' to show the ends, e.g. ("[" . "]").
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: scrollbar alternative
2010-03-16 16:10 ` Drew Adams
@ 2010-03-16 16:53 ` Lennart Borgman
0 siblings, 0 replies; 21+ messages in thread
From: Lennart Borgman @ 2010-03-16 16:53 UTC (permalink / raw)
To: Drew Adams; +Cc: emacs-devel, David Engster, Zhu, Shenli
[-- Attachment #1: Type: text/plain, Size: 802 bytes --]
On Tue, Mar 16, 2010 at 5:10 PM, Drew Adams <drew.adams@oracle.com> wrote:
>> BTW there are some minor problems with the code. I will (as usual) try
>> to fix them and put the code in the nXhtml repository for the moment.
>
> Yes, like:
>
> 1. (eval-when-compile (require 'cl)) ; assert
I removed the assert instead.
> 2. Remove the :background for the left and right portions (or define it as
> something different). It is often the case that the inactive mode-line
> foreground is the same as the mode-line foreground, which means, e.g., black on
> black - no movement shown.
I added some faces.
> 3. Change the default value of `sml-borders' to show the ends, e.g. ("[" . "]").
No ;-)
I prefer the version without those. But I hope the code will somehow
be adopted so someone else can decide.
[-- Attachment #2: sml-modeline.el --]
[-- Type: text/plain, Size: 4797 bytes --]
;;; sml-modeline.el --- Show position in a scrollbar like way in mode-line
;;
;; Author: Lennart Borgman (lennart O borgman A gmail O com)
;; Created: 2010-03-16 Tue
;; Version:
;; Last-Updated:
;; URL:
;; Keywords:
;; Compatibility:
;;
;; Features that might be required by this library:
;;
;; None
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Commentary:
;;
;; Show scrollbar like position indicator in mode line.
;;
;; Idea and part of this code is adapted from David Engster's and Drew
;; Adam's code in these mail messages:
;;
;; http://lists.gnu.org/archive/html/emacs-devel/2010-03/msg00523.html
;; http://permalink.gmane.org/gmane.emacs.devel/122038
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Change log:
;;
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 3, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
;; Floor, Boston, MA 02110-1301, USA.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Code:
;;;###autoload
(defgroup sml-modeline nil
"Customization group for `sml-mode'."
:group 'frames)
(defcustom sml-len 12
"Mode line indicator total length."
:type 'integer
:group 'sml-modeline)
(defcustom sml-borders nil
"Indicator borders.
This is a pair of indicators, like [] or nil."
:type '(choice (const :tag "None" nil)
(cons (string :tag "Left border")
(string :tag "Right border")))
:group 'sml-modeline)
(defface sml-end-face
'((t (:inherit match)))
"Face for invisible buffer parts."
:group 'sml-modeline)
;; 'face `(:background ,(face-foreground 'mode-line-inactive)
;; :foreground ,(face-background 'mode-line))
(defface sml-vis-face
'((t (:inherit region)))
"Face for invisible buffer parts."
:group 'sml-modeline)
;; 'face `(:background ,(face-foreground 'mode-line)
;; :foreground ,(face-background 'mode-line))
;;(sml-create)
(defun sml-create ()
(let* ((wstart (window-start))
(wend (window-end))
(real-point-max (save-restriction (widen) (point-max)))
(percentage-beg (/ (float wstart) (float real-point-max)))
(percentage-end (/ (float wend) (float real-point-max)))
(sml-begin (or (car sml-borders) ""))
(sml-end (or (cdr sml-borders) ""))
(inner-len (- sml-len (length sml-begin) (length sml-end)))
bpad-len
epad-len
(start (floor (* percentage-beg inner-len)))
(end (ceiling (* percentage-end inner-len)))
string)
(if (not (or (< wend real-point-max) (> wstart 1)))
""
(setq string
(concat (format "%02d" (round (* percentage-beg 100)))
"-"
(format "%02d" (round (* percentage-end 100))) "%%"))
(setq bpad-len (floor (/ (- inner-len (length string)) 2.0)))
(setq epad-len (- inner-len (length string) bpad-len))
(setq string (concat sml-begin
(make-string bpad-len 32)
string
(make-string epad-len 32)
sml-end))
;;(assert (= (length string) sml-len) t)
(when (= start sml-len) (setq start (1- start)))
(setq start (+ start (length sml-begin)))
(put-text-property start end 'face 'sml-vis-face string)
(when (and (= 0 (length sml-begin))
(= 0 (length sml-end)))
(put-text-property 0 start 'face 'sml-end-face string)
(put-text-property end sml-len 'face 'sml-end-face string))
string)))
(defvar sml-old-car-mode-line-position nil)
;;;###autoload
(define-minor-mode sml-mode
"Show buffer size and position like scrollbar in mode line."
:global t
:group 'sml-modeline
(if sml-mode
(progn
(unless sml-old-car-mode-line-position
(setq sml-old-car-mode-line-position (car mode-line-position)))
(setcar mode-line-position '(:eval (list (sml-create)))))
(setcar mode-line-position sml-old-car-mode-line-position)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; sml-modeline.el ends here
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: scrollbar alternative
2010-03-16 15:43 ` Lennart Borgman
2010-03-16 16:10 ` Drew Adams
@ 2010-03-16 16:54 ` Deniz Dogan
1 sibling, 0 replies; 21+ messages in thread
From: Deniz Dogan @ 2010-03-16 16:54 UTC (permalink / raw)
To: Lennart Borgman; +Cc: Zhu, Shenli, Drew Adams, emacs-devel
2010/3/16 Lennart Borgman <lennart.borgman@gmail.com>:
> On Tue, Mar 16, 2010 at 4:40 PM, Drew Adams <drew.adams@oracle.com> wrote:
>>
>> One comment: Your file header says:
>>
>> ;; Idea and part of this code is adapted from Drew Adam's code in this
>> ;; mail message:
>> ;; http://permalink.gmane.org/gmane.emacs.devel/122038
>>
>> The original code is from David Engster, not me. The OP is here:
>> http://lists.gnu.org/archive/html/emacs-devel/2010-03/msg00523.html
>
>
> Thanks Drew. Sorry David.
>
> BTW there are some minor problems with the code. I will (as usual) try
> to fix them and put the code in the nXhtml repository for the moment.
>
>
>
I created an entry on EmacsWiki:
URL: http://www.emacswiki.org/emacs/SmlModeLine
The code was copied verbatim from Lennart's e-mail, but with updated
"origin" documentation and a minor indentation change in `sml-create'.
I hope no one minds.
What does SML stand for by the way? Small?
--
Deniz Dogan
^ permalink raw reply [flat|nested] 21+ messages in thread
* Progress indicator (was: scrollbar alternative)
2010-03-16 12:44 ` Lennart Borgman
2010-03-16 15:40 ` Drew Adams
@ 2010-03-29 19:47 ` Leo
2010-03-29 19:54 ` Lennart Borgman
1 sibling, 1 reply; 21+ messages in thread
From: Leo @ 2010-03-29 19:47 UTC (permalink / raw)
To: Lennart Borgman, David Engster; +Cc: emacs-devel
On 2010-03-16 12:44 +0000, Lennart Borgman wrote:
> I like the feature. I think something like this should be in Emacs.
>
> Attached is a little bit more elaborated version. Name suggestions are
> welcome.
I was making a proposal to emms maintainer lukhas about porting that
code to emms-playing-time (you could imagine how nice it is to show the
playing time this way), but then realised emacs can benefit from having
a general facility of creating nice visual progress indicator like this.
What do you think of this idea?
Leo
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: Progress indicator (was: scrollbar alternative)
2010-03-29 19:47 ` Progress indicator (was: scrollbar alternative) Leo
@ 2010-03-29 19:54 ` Lennart Borgman
2010-03-29 21:30 ` Leo
0 siblings, 1 reply; 21+ messages in thread
From: Lennart Borgman @ 2010-03-29 19:54 UTC (permalink / raw)
To: Leo; +Cc: David Engster, emacs-devel
On Mon, Mar 29, 2010 at 9:47 PM, Leo <sdl.web@gmail.com> wrote:
>
> On 2010-03-16 12:44 +0000, Lennart Borgman wrote:
> > I like the feature. I think something like this should be in Emacs.
> >
> > Attached is a little bit more elaborated version. Name suggestions are
> > welcome.
>
> I was making a proposal to emms maintainer lukhas about porting that
> code to emms-playing-time (you could imagine how nice it is to show the
> playing time this way), but then realised emacs can benefit from having
> a general facility of creating nice visual progress indicator like this.
> What do you think of this idea?
Could you please just tell how you want the functions to be broken up
to be useful for that so I can fix it in my version for the moment.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: Progress indicator (was: scrollbar alternative)
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
0 siblings, 2 replies; 21+ messages in thread
From: Leo @ 2010-03-29 21:30 UTC (permalink / raw)
To: Lennart Borgman; +Cc: David Engster, emacs-devel
On 2010-03-29 20:54 +0100, Lennart Borgman wrote:
> On Mon, Mar 29, 2010 at 9:47 PM, Leo <sdl.web@gmail.com> wrote:
>>
>> On 2010-03-16 12:44 +0000, Lennart Borgman wrote:
>> > I like the feature. I think something like this should be in Emacs.
>
>> >
>> > Attached is a little bit more elaborated version. Name suggestions are
>> > welcome.
>>
>> I was making a proposal to emms maintainer lukhas about porting that
>> code to emms-playing-time (you could imagine how nice it is to show the
>> playing time this way), but then realised emacs can benefit from having
>> a general facility of creating nice visual progress indicator like this.
>> What do you think of this idea?
>
>
> Could you please just tell how you want the functions to be broken up
> to be useful for that so I can fix it in my version for the moment.
I guess the basic functionality will be something that takes a
percentage or 0-100 integer and display it in the mode-line.
Leo
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: Progress indicator (was: scrollbar alternative)
2010-03-29 21:30 ` Leo
@ 2010-03-29 21:32 ` Lennart Borgman
2010-03-29 21:47 ` Eli Zaretskii
1 sibling, 0 replies; 21+ messages in thread
From: Lennart Borgman @ 2010-03-29 21:32 UTC (permalink / raw)
To: Leo; +Cc: David Engster, emacs-devel
On Mon, Mar 29, 2010 at 11:30 PM, Leo <sdl.web@gmail.com> wrote:
> On 2010-03-29 20:54 +0100, Lennart Borgman wrote:
>>
>> Could you please just tell how you want the functions to be broken up
>> to be useful for that so I can fix it in my version for the moment.
>
> I guess the basic functionality will be something that takes a
> percentage or 0-100 integer and display it in the mode-line.
I expected it to be on this level, but also on the level of just
building the string to insert it anywhere.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: Progress indicator (was: scrollbar alternative)
2010-03-29 21:30 ` Leo
2010-03-29 21:32 ` Lennart Borgman
@ 2010-03-29 21:47 ` Eli Zaretskii
1 sibling, 0 replies; 21+ messages in thread
From: Eli Zaretskii @ 2010-03-29 21:47 UTC (permalink / raw)
To: Leo; +Cc: lennart.borgman, deng, emacs-devel
> From: Leo <sdl.web@gmail.com>
> Date: Mon, 29 Mar 2010 22:30:56 +0100
> Cc: David Engster <deng@randomsample.de>, emacs-devel@gnu.org
>
> > Could you please just tell how you want the functions to be broken up
> > to be useful for that so I can fix it in my version for the moment.
>
> I guess the basic functionality will be something that takes a
> percentage or 0-100 integer and display it in the mode-line.
Please also take a look at ebrowse-show-progress, it might give you
some ideas.
^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2010-03-29 21:47 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
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.