2010-03-20

showing the buffer position in the mode-line

I do quite a bit of scrolling in emacs, but I hardly ever use the scroll bar for that. The main reason for still having the scroll bar is that it gives me some indication where I am in the buffer. Of course, there is some information in the mode-line, and you can get some more with size-indication-mode, but it's not as immediately obvious as the scroll bar.
But recently, I discovered Lennart Borgman's sml-modeline, which combines all of the scroll bar information into a nice visual indication on the modeline, and I have been happily using it, and got rid of my scroll bar.
Put you sml-modeline in your load-path, and the following fragment in your .emacs should do the trick:
(if (require 'sml-modeline nil 'noerror)    ;; use sml-modeline if available
  (progn 
    (sml-modeline-mode 1)                   ;; show buffer pos in the mode line
    (scroll-bar-mode -1))                   ;; turn off the scrollbar
  (scroll-bar-mode 1)                       ;; otherwise, show a scrollbar...
  (set-scroll-bar-mode 'right))             ;; ... on the right

Note, there is a older version available in Emacswiki which has some problems (such as conflicting with the Standard ML editing mode for emacs); thus, for now it's better to us the Launchpad version; the instructions above apply to that version.

6 comments:

semente said...

I like fringe:


(setq default-indicate-empty-lines t
default-indicate-buffer-boundaries 'left)

Jason Riedy said...

Thank you for eliminating more noise from by Emacs. And as a bonus, this indicator also works outside windowing mode.

David said...

Scrollbars (if they are enabled) belong to the left of course. The most text is on this side, therefore the view and the mouse is often nearer to the left as well.

djcb said...

@David, well, taste difference; personally, I like my scrollbars on the right, as I mostly used them as an indicator, and I don't like these moving items distracting me :)

BFW said...

I like it, thanks for the pointer.

Drew said...

See also `modeline-posn.el'. It highlights the column number when past a limit. And when the region is active it shows the number of chars and/or lines in the region.