MiniMap

Minimap is a feature provided by the Sublime editor. It shows a smaller, “minibar”, display of the current buffer alongside the main editing window.

This page is about a minimap implementation for Emacs. In the minibar window, it highlights the portion of the buffer that is currently visible in the main window. This highlight position is updated automatically, as you navigate in the main window. You can scroll the main window by dragging the highlighted area in the minibar.

You can configure the size/readability of the sidebar freely by specifying the font familiy and height. Here are two screenshots of the minibar in action:

With Bitstream Vera Sans, Height 30, with semantic overlays enabled (requires CEDET):

http://randomsample.de/minimap1.jpg

With Proggyfont Tiny, Height 20:

http://randomsample.de/minimap2.jpg

It is in GNU ELPA, so you can get it directly from ‘M-x package-install’, or you can find its code at http://bzr.savannah.gnu.org/lh/emacs/elpa/files/head:/packages/minimap/

Also in Marmalade http://marmalade-repo.org/packages/minimap/1.0

Repository at GitHub: https://github.com/dengste/minimap

Usage:

Things you can customize:

KNOWN BUGS:

TODO:

Discussion

Nice. I found two issues:

The movement of the very small cursor is visible in the minimap windows when the viewport is dragged with the mouse. The cursor should be hidden in that window with ‘cursor-type’.

The other thing is an interaction bug. When I finish dragging the viewport I get the following backtrace:

Debugger entered--Lisp error: (error "The mark is not set now, so there is no region")
  call-interactively(copy-region-as-kill-nomark nil nil)

I use pc-selection mode, copy-region-as-kill-nomark is a function in that package. pc-selection allows the user to copy text by simply selecting text and releasing the mouse button. Apparently, this feature clashes with viewport dragging. pc-selection mode should be deactivated in the minimap buffer, if it’s possible.

Thanks, I think I fixed those two in the latest version.

I suggest hiding the vertical scrollbars in the minimap buffer. They are not really needed if the viewport can be dragged.

I agree. I added a new option for that. The default is to hide the scroll-bar.

You could create a new screenshot with the toolbars hidden. I assume it looks better too!

Done.


Some actions seem to steal the minimap window for their own output. What about adding

(set-window-dedicated-p nil t)

in the mode setup to try and minimize that.

Added a new option for that. It defaults to ‘nil’ though, because dedicated windows tend to confuse users since they behave unexpectedly.


Really nice! How can you set up emacs so it creates a minimap for every buffer (or, for buffers of a certain type)? A problem I encounter is that when you create minimaps for 2 buffers, you get two minimap windows side-by-side. And so on. Could the minimap frame be reused when you switch buffer in a window? (On Carbon Emacs Fall 2008: Emacs 22.3.1) Thanks!

Well, that’s in the TODO list. Currently, you can’t really do that in Emacs without heaviliy using ‘defadvice’ on all the functions that switch or change buffers (thats what EmacsCodeBrowser does at the moment). There is some work going on to make this kind of fixed ‘window grouping’ possible in Emacs proper, so I rather just wait for that. At the moment, I’d suggest to bind ‘minimap-create’ to a key, then just maximize the buffer you’re currently editing and use the key combination for ‘minimap-create’. Existing minimaps which are currently hidden will then be reused.


It seems linum-mode displays line numbers at normal size and thus only displays the normal number of lines in the minimap, you should probably check for it and disable it in the minimap buffer.

Done. I also changed the overlay-syncing, so that only the ‘face and ‘invisible property will be synced - otherwise, linum-mode would still change the line spacing in the minimap buffer.


I find the following function handy, maybe it would make sense to add it to minimap.el?

;;;###autoload
(defun minimap-toggle ()
  "Toggle minimap for current buffer."
  (interactive)
  (if (null minimap-bufname)
      (minimap-create)
    (minimap-kill)))

Then I can bind single shortcut to minimap toggling, it’s handy.


…and for those of us who like to keep the width of our frames at 80 columns…

(defun minimap-toggle ()
  "Toggle minimap for current buffer."
  (interactive)
  (if (not (boundp 'minimap-bufname))
      (setf minimap-bufname nil))
  (if (null minimap-bufname)
      (progn (minimap-create)
	     (set-frame-width (selected-frame) 100))
    (progn (minimap-kill)
	   (set-frame-width (selected-frame) 80))))

I have this set to <f7>… It is quite convenient since I don’t have to resize my window each time.


I have updated minimap.el to use a single dedicated minimap sidebar window instead of new windows per buffer. Minimap now updates based on what the currently selected buffer is. You can find it here: https://github.com/dustinlacewell/emacs-minimap

Current bugs include semantic overlays disappearing when the current buffer changes.


And for this updated version… Here is the equivalent above function to keep buffer sizes to 80 wide…

(defun minimap-toggle-retain-size ()
  "Toggle minimap"
  (interactive)
  (if (or (not (boundp 'minimap-exists))
	  (not minimap-exists))
      (progn (minimap-create)
	     (setf minimap-exists t)
	     (set-frame-width (selected-frame) 100))
    (progn (minimap-kill)
	   (setf minimap-exists nil)
	   (set-frame-width (selected-frame) 80))))

Would it be possible to make the minimap buffer scroll-wheel enabled ? Currently using the scroll-wheel triggers a refresh which just makes the buffer glitch a bit. As a workaround, tips to (really) disable the scroll wheel would be welcome.


Some problems occurs when resizing the view (emacs 23.1.50.1 on Ubuntu 10.10). M-x minimap-create Drag to resize the windows to full screen, drag to make it 0 columns wide. Repeat. Sometimes the minimap gets as wide as the buffer, sometimes it disappears. Furthermore there is no way to change the width of the minimap alone. Hovering the mouse over its scrollbar changes the pointer to a double horizontal arrow and pops up “drag-mouse-1: resize”, but dragging doesn’t do anything.


It would be really good if the minimap would change automatically as you go through buffers. The link posted by the other user has 2 issues: - the minimap is always on the left - it is buggy


I am using Emacs in server environments where I do not have X11 available, so I use it in text terminal. Minimap shows fonts at same size as other buffers if used this way. Is it possible to solve this issue? Yes, but not totally: vim-minimap uses drawille library to lower the size of the text in terminal. Emacs’ minimap could do the same: https://github.com/dengste/minimap/issues/12.


Note: I use the VHDL-Mode from http://www.iis.ee.ethz.ch/~zimmi/emacs/vhdl-mode.html. To enable the minimap mode here, I had to add the VHDL-Mode to the list of minimap major modes: (add-to-list ‘minimap-major-modes ‘vhdl-mode) Thanks for this great feature.


CategoryWindows CategoryDisplay Minimap is a feature provided by the Sublime editor. It shows a smaller,


I try to use this with auctex, but it doesn’t seem to work. It works in my other buffers – so there seem to be a package conflict here.