re-organized emacs config, added minimap and added keybindings
This commit is contained in:
parent
cf455f222d
commit
9b25080a58
3 changed files with 719 additions and 112 deletions
197
emacs
197
emacs
|
|
@ -1,20 +1,12 @@
|
||||||
|
;;;
|
||||||
|
;;; sjs' emacs config
|
||||||
|
;;;
|
||||||
|
|
||||||
|
|
||||||
;; feel out the system
|
;; feel out the system
|
||||||
(defvar macosx-p (string-match "darwin" (symbol-name system-type)))
|
(defvar macosx-p (string-match "darwin" (symbol-name system-type)))
|
||||||
(defvar linux-p (string-match "gnu/linux" (symbol-name system-type)))
|
(defvar linux-p (string-match "gnu/linux" (symbol-name system-type)))
|
||||||
|
|
||||||
;; disable splash screen and startup message
|
|
||||||
(setq inhibit-startup-message t)
|
|
||||||
;(setq initial-scratch-message nil)
|
|
||||||
|
|
||||||
;; don't litter my filesystem with ~ files!
|
|
||||||
(setq make-backup-files nil)
|
|
||||||
|
|
||||||
;; map cmd to meta (Emacs.app 23.2)
|
|
||||||
(when macosx-p
|
|
||||||
(setq mac-option-key-is-meta nil)
|
|
||||||
(setq mac-command-key-is-meta t)
|
|
||||||
(setq mac-command-modifier 'meta)
|
|
||||||
(setq mac-option-modifier nil))
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; setup load paths ;;
|
;; setup load paths ;;
|
||||||
|
|
@ -30,6 +22,65 @@
|
||||||
(mapcar 'add-to-load-path load-paths))
|
(mapcar 'add-to-load-path load-paths))
|
||||||
|
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;
|
||||||
|
;; global config ;;
|
||||||
|
;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
(setq inhibit-startup-message t)
|
||||||
|
(setq make-backup-files nil)
|
||||||
|
(global-subword-mode 1)
|
||||||
|
|
||||||
|
;; map cmd to meta (Emacs.app 23.2)
|
||||||
|
(when macosx-p
|
||||||
|
(setq mac-option-key-is-meta nil)
|
||||||
|
(setq mac-command-key-is-meta t)
|
||||||
|
(setq mac-command-modifier 'meta)
|
||||||
|
(setq mac-option-modifier 'super))
|
||||||
|
|
||||||
|
;; keep a list of recently visited files
|
||||||
|
(require 'recentf)
|
||||||
|
(recentf-mode 1)
|
||||||
|
|
||||||
|
;; remember my position in files
|
||||||
|
(require 'saveplace)
|
||||||
|
(setq-default save-place t)
|
||||||
|
|
||||||
|
;; always highlight syntax
|
||||||
|
(global-font-lock-mode t)
|
||||||
|
(setq font-lock-maximum-decoration t) ; highlight liberally
|
||||||
|
|
||||||
|
(autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t)
|
||||||
|
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
|
||||||
|
|
||||||
|
;; always start emacs server
|
||||||
|
(server-start)
|
||||||
|
|
||||||
|
;; setup tramp mode
|
||||||
|
(setq tramp-default-method "ssh")
|
||||||
|
|
||||||
|
;; complete like zsh's complete-in-word option (p-b expands to print-buffer)
|
||||||
|
(load "complete")
|
||||||
|
|
||||||
|
;; show the date & time in the mode line
|
||||||
|
(setq display-time-day-and-date t)
|
||||||
|
(display-time)
|
||||||
|
|
||||||
|
(setq track-eol t) ; When at EOL, C-n and C-p move to EOL on other lines
|
||||||
|
(setq indent-tabs-mode nil) ; never insert tabs
|
||||||
|
|
||||||
|
;; highlight the current line
|
||||||
|
(global-hl-line-mode 1)
|
||||||
|
|
||||||
|
;; To customize the background color
|
||||||
|
(set-face-background 'hl-line "#330")
|
||||||
|
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;
|
||||||
|
;; minimap ;;
|
||||||
|
;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
(require 'minimap)
|
||||||
|
|
||||||
;;;;;;;
|
;;;;;;;
|
||||||
;; c ;;
|
;; c ;;
|
||||||
;;;;;;;
|
;;;;;;;
|
||||||
|
|
@ -81,8 +132,7 @@
|
||||||
(setq tab-width 8
|
(setq tab-width 8
|
||||||
;; this will make sure spaces are used instead of tabs
|
;; this will make sure spaces are used instead of tabs
|
||||||
indent-tabs-mode nil)
|
indent-tabs-mode nil)
|
||||||
(c-toggle-auto-newline 1)
|
(c-toggle-auto-newline 1))
|
||||||
(c-subword-mode t))
|
|
||||||
;; (setq skeleton-pair t)
|
;; (setq skeleton-pair t)
|
||||||
;; (setq skeleton-autowrap t)
|
;; (setq skeleton-autowrap t)
|
||||||
;; (let ((chars '("'" "\"" "(" "[" "{")))
|
;; (let ((chars '("'" "\"" "(" "[" "{")))
|
||||||
|
|
@ -121,12 +171,12 @@
|
||||||
(add-hook 'ruby-mode-hook
|
(add-hook 'ruby-mode-hook
|
||||||
'(lambda ()
|
'(lambda ()
|
||||||
(inf-ruby-keys)
|
(inf-ruby-keys)
|
||||||
(ruby-electric-mode)
|
(ruby-electric-mode)))
|
||||||
(c-subword-mode t)))
|
|
||||||
(autoload 'rubydb "rubydb3x" "Ruby debugger" t)
|
(autoload 'rubydb "rubydb3x" "Ruby debugger" t)
|
||||||
|
|
||||||
(add-to-list 'auto-mode-alist '(".irbrc$" . ruby-mode))
|
(add-to-list 'auto-mode-alist '(".irbrc$" . ruby-mode))
|
||||||
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;
|
;;;;;;;;;;;;;
|
||||||
;; haskell ;;
|
;; haskell ;;
|
||||||
;;;;;;;;;;;;;
|
;;;;;;;;;;;;;
|
||||||
|
|
@ -155,7 +205,6 @@
|
||||||
(add-to-list 'auto-mode-alist '("Jakefile$" . js2-mode))
|
(add-to-list 'auto-mode-alist '("Jakefile$" . js2-mode))
|
||||||
(add-hook 'js2-mode-hook '(lambda ()
|
(add-hook 'js2-mode-hook '(lambda ()
|
||||||
(local-set-key "\C-m" 'newline)
|
(local-set-key "\C-m" 'newline)
|
||||||
(c-subword-mode t)
|
|
||||||
(setq indent-tabs-mode nil)))
|
(setq indent-tabs-mode nil)))
|
||||||
|
|
||||||
(autoload #'espresso-mode "espresso" "Start espresso-mode" t)
|
(autoload #'espresso-mode "espresso" "Start espresso-mode" t)
|
||||||
|
|
@ -218,8 +267,6 @@
|
||||||
(autoload 'whitespace-mode "whitespace"
|
(autoload 'whitespace-mode "whitespace"
|
||||||
"Toggle whitespace visualization." t)
|
"Toggle whitespace visualization." t)
|
||||||
|
|
||||||
(add-hook 'python-mode-hook '(lambda ()
|
|
||||||
(c-subword-mode t)))
|
|
||||||
|
|
||||||
;;;;;;;;;;;;
|
;;;;;;;;;;;;
|
||||||
;; erlang ;;
|
;; erlang ;;
|
||||||
|
|
@ -230,6 +277,7 @@
|
||||||
(setq exec-path (cons "/opt/local/lib/erlang/bin" exec-path))
|
(setq exec-path (cons "/opt/local/lib/erlang/bin" exec-path))
|
||||||
(require 'erlang-start)
|
(require 'erlang-start)
|
||||||
|
|
||||||
|
|
||||||
;;;;;;;;;;;;
|
;;;;;;;;;;;;
|
||||||
;; markup ;;
|
;; markup ;;
|
||||||
;;;;;;;;;;;;
|
;;;;;;;;;;;;
|
||||||
|
|
@ -241,14 +289,6 @@
|
||||||
(add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode))
|
(add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode))
|
||||||
|
|
||||||
|
|
||||||
;; keep a list of recently visited files
|
|
||||||
(require 'recentf)
|
|
||||||
(recentf-mode 1)
|
|
||||||
|
|
||||||
;; remember my position in files
|
|
||||||
(require 'saveplace)
|
|
||||||
(setq-default save-place t)
|
|
||||||
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; lisp and scheme ;;
|
;; lisp and scheme ;;
|
||||||
|
|
@ -273,86 +313,28 @@
|
||||||
(add-hook 'inferior-scheme-mode-hook (lambda () (inferior-slime-mode t)))
|
(add-hook 'inferior-scheme-mode-hook (lambda () (inferior-slime-mode t)))
|
||||||
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;
|
|
||||||
;; textmate mode ;;
|
|
||||||
;;;;;;;;;;;;;;;;;;;
|
|
||||||
|
|
||||||
;; disabled. ruins C-x C-f
|
|
||||||
;
|
|
||||||
;(require 'textmate)
|
|
||||||
;(textmate-mode)
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;
|
|
||||||
;; drag stuff mode ;;
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;
|
|
||||||
|
|
||||||
;; (add-to-list 'load-path "~/config/emacs.d/drag-stuff")
|
|
||||||
;; (require 'drag-stuff)
|
|
||||||
;; (drag-stuff-mode t) ; always on
|
|
||||||
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;
|
|
||||||
;; customizations ;;
|
|
||||||
;;;;;;;;;;;;;;;;;;;;
|
|
||||||
|
|
||||||
;; always start emacs server
|
|
||||||
(server-start)
|
|
||||||
|
|
||||||
;; setup tramp mode
|
|
||||||
(setq tramp-default-method "ssh")
|
|
||||||
|
|
||||||
;; complete like zsh's complete-in-word option (p-b expands to print-buffer)
|
|
||||||
(load "complete")
|
|
||||||
|
|
||||||
;; show the date & time in the mode line
|
|
||||||
(setq display-time-day-and-date t)
|
|
||||||
(display-time)
|
|
||||||
|
|
||||||
(setq track-eol t) ; When at EOL, C-n and C-p move to EOL on other lines
|
|
||||||
(setq indent-tabs-mode nil) ; never insert tabs
|
|
||||||
|
|
||||||
;; ah, now I can read the text I'm supposed to correct
|
|
||||||
;; (progn
|
|
||||||
;; (set-face-background 'flymake-errline "red4")
|
|
||||||
;; (set-face-background 'flymake-warnline "dark slate blue"))
|
|
||||||
|
|
||||||
;; highlight the current line
|
|
||||||
(global-hl-line-mode 1)
|
|
||||||
|
|
||||||
;; To customize the background color
|
|
||||||
(set-face-background 'hl-line "#330")
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;
|
||||||
;; key bindings ;;
|
;; key bindings ;;
|
||||||
;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;
|
||||||
;; TODO add these only to appropriate modes
|
|
||||||
|
;; can't seem to un-hijack cmd-`, so make it do something useful
|
||||||
|
(global-set-key "\M-`" 'other-window)
|
||||||
|
|
||||||
;; custom key bindings under a common prefix
|
;; custom key bindings under a common prefix
|
||||||
(global-set-key "\C-z" nil) ; Suspend is useless. Give me C-z!
|
(global-set-key "\C-z" nil) ; Suspend is useless. Give me C-z!
|
||||||
(global-set-key "\C-zf" 'find-file-at-point)
|
|
||||||
(global-set-key "\C-zz" 'shell) ; z for zsh
|
|
||||||
(global-set-key "\C-zl" 'duplicate-line)
|
|
||||||
(global-set-key "\C-zg" 'goto-line)
|
|
||||||
(global-set-key "\C-zr" 'query-replace-regexp)
|
|
||||||
(global-set-key "\C-z\C-r" 'reload-dot-emacs)
|
|
||||||
(global-set-key "\C-zc" 'comment-line)
|
(global-set-key "\C-zc" 'comment-line)
|
||||||
|
(global-set-key "\C-zf" 'find-file-at-point)
|
||||||
|
(global-set-key "\C-zg" 'goto-line)
|
||||||
(global-set-key "\C-zj" 'run-js)
|
(global-set-key "\C-zj" 'run-js)
|
||||||
|
(global-set-key "\C-zl" 'duplicate-line)
|
||||||
|
(global-set-key "\C-zm" 'minimap-create)
|
||||||
|
(global-set-key "\C-zM" 'minimap-kill)
|
||||||
|
(global-set-key "\C-zr" 'query-replace-regexp)
|
||||||
(global-set-key "\C-zs" 'run-scheme)
|
(global-set-key "\C-zs" 'run-scheme)
|
||||||
|
(global-set-key "\C-zt" 'tagify-region-or-insert-tag)
|
||||||
|
(global-set-key "\C-zz" 'shell) ; z for zsh
|
||||||
|
(global-set-key "\C-z\C-r" 'reload-dot-emacs)
|
||||||
(global-set-key "\C-z\C-t" 'totd)
|
(global-set-key "\C-z\C-t" 'totd)
|
||||||
(global-set-key [f5] 'compile)
|
|
||||||
|
|
||||||
;; *** only do this for specific modes?
|
|
||||||
;; help out a TextMate junkie
|
|
||||||
;; (setq skeleton-pair t)
|
|
||||||
;; (setq skeleton-autowrap t)
|
|
||||||
|
|
||||||
;; (let ((chars '("'" "\"" "`" "(" "[" "{")))
|
|
||||||
;; (mapcar (lambda (char)
|
|
||||||
;; (global-set-key char 'skeleton-pair-insert-maybe)) chars))
|
|
||||||
|
|
||||||
;; web searches
|
|
||||||
(global-set-key "\C-zwg" 'web-search-google)
|
|
||||||
(global-set-key "\C-zww" 'web-search-wikipedia)
|
|
||||||
|
|
||||||
;; extend Emacs' default key binding space
|
;; extend Emacs' default key binding space
|
||||||
(global-set-key "\C-x\C-b" 'bs-show) ; use the buffer list buffer menu
|
(global-set-key "\C-x\C-b" 'bs-show) ; use the buffer list buffer menu
|
||||||
|
|
@ -365,13 +347,10 @@
|
||||||
|
|
||||||
;; wrap a region with an HTML/XML tag
|
;; wrap a region with an HTML/XML tag
|
||||||
(global-set-key "<" 'tagify-region-or-insert-self)
|
(global-set-key "<" 'tagify-region-or-insert-self)
|
||||||
(global-set-key "\C-zt" 'tagify-region-or-insert-tag)
|
|
||||||
|
|
||||||
;; XXX:todo need a version of this that inserts a line terminator as well
|
(global-set-key [f5] 'compile)
|
||||||
;; Use C-j!
|
|
||||||
;;(global-set-key [M-return] 'move-end-of-line-insert-newline)
|
|
||||||
|
|
||||||
;; saved macros
|
;; utilities
|
||||||
|
|
||||||
(defun duplicate-line (&optional arg)
|
(defun duplicate-line (&optional arg)
|
||||||
"Duplicate the current line."
|
"Duplicate the current line."
|
||||||
|
|
@ -391,7 +370,6 @@
|
||||||
(interactive "p")
|
(interactive "p")
|
||||||
(kmacro-call-macro (quote ([1 67108896 14 134217787 16] 0 "%d")) arg)))
|
(kmacro-call-macro (quote ([1 67108896 14 134217787 16] 0 "%d")) arg)))
|
||||||
|
|
||||||
;; function definitions
|
|
||||||
|
|
||||||
;; Reload the .emacs file with a minimum of effort,
|
;; Reload the .emacs file with a minimum of effort,
|
||||||
;; first saving histories with Persistent
|
;; first saving histories with Persistent
|
||||||
|
|
@ -436,13 +414,6 @@
|
||||||
;; (color-theme-tty-dark)
|
;; (color-theme-tty-dark)
|
||||||
))
|
))
|
||||||
|
|
||||||
;; always highlight syntax
|
|
||||||
(global-font-lock-mode t)
|
|
||||||
(setq font-lock-maximum-decoration t) ; highlight liberally
|
|
||||||
|
|
||||||
(autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t)
|
|
||||||
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
|
|
||||||
|
|
||||||
(defun totd ()
|
(defun totd ()
|
||||||
(interactive)
|
(interactive)
|
||||||
(with-output-to-temp-buffer "*Tip of the day*"
|
(with-output-to-temp-buffer "*Tip of the day*"
|
||||||
|
|
@ -477,6 +448,8 @@
|
||||||
'(js2-highlight-level 3)
|
'(js2-highlight-level 3)
|
||||||
'(js2-mode-escape-quotes nil)
|
'(js2-mode-escape-quotes nil)
|
||||||
'(js2-strict-inconsistent-return-warning nil)
|
'(js2-strict-inconsistent-return-warning nil)
|
||||||
|
'(minimap-always-recenter nil)
|
||||||
|
'(minimap-display-semantic-overlays t)
|
||||||
'(mojo-build-directory "~/Projects/brighthouse/webOS/build")
|
'(mojo-build-directory "~/Projects/brighthouse/webOS/build")
|
||||||
'(mojo-debug nil)
|
'(mojo-debug nil)
|
||||||
'(mojo-project-directory "~/Projects/brighthouse/webOS")
|
'(mojo-project-directory "~/Projects/brighthouse/webOS")
|
||||||
|
|
@ -503,4 +476,4 @@
|
||||||
;; If you edit it by hand, you could mess it up, so be careful.
|
;; If you edit it by hand, you could mess it up, so be careful.
|
||||||
;; Your init file should contain only one such instance.
|
;; Your init file should contain only one such instance.
|
||||||
;; If there is more than one, they won't work right.
|
;; If there is more than one, they won't work right.
|
||||||
)
|
'(minimap-font-face ((default (:height 30 :family "DejaVu Sans Mono")) (nil nil))))
|
||||||
|
|
|
||||||
4
emacs.d/ede-projects.el
Normal file
4
emacs.d/ede-projects.el
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
;; EDE project cache file.
|
||||||
|
;; This contains a list of projects you have visited.
|
||||||
|
(
|
||||||
|
)
|
||||||
630
emacs.d/minimap.el
Normal file
630
emacs.d/minimap.el
Normal file
|
|
@ -0,0 +1,630 @@
|
||||||
|
;;; minimap.el --- Minimap sidebar for Emacs
|
||||||
|
|
||||||
|
;; Copyright (C) 2009, 2010 David Engster
|
||||||
|
|
||||||
|
;; Author: David Engster <dengste@eml.cc>
|
||||||
|
;; Keywords:
|
||||||
|
;; Version: 0.7
|
||||||
|
|
||||||
|
;; This file is NOT part of GNU Emacs.
|
||||||
|
|
||||||
|
;; 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 2
|
||||||
|
;; of the License, 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. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
;;; Commentary:
|
||||||
|
|
||||||
|
;; This file is an implementation of a minimap sidebar, i.e., a
|
||||||
|
;; smaller display of the current buffer on the left side. It
|
||||||
|
;; highlights the currently shown region and updates its position
|
||||||
|
;; automatically. You can navigate in the minibar by dragging the
|
||||||
|
;; active region with the mouse, which will scroll the corresponding
|
||||||
|
;; edit buffer.
|
||||||
|
|
||||||
|
;; Usage:
|
||||||
|
;; * Put minimap.el in your load path.
|
||||||
|
;; * (require 'minimap)
|
||||||
|
;; * Use 'M-x minimap-create' in a buffer you're currently editing.
|
||||||
|
;; * Use 'M-x minimap-kill' to kill the minimap.
|
||||||
|
;; * Use 'M-x customize-group RET minimap RET' to adapt minimap to your needs.
|
||||||
|
|
||||||
|
;; Download:
|
||||||
|
;; You can always get the latest version from the git repository:
|
||||||
|
;; git://randomsample.de/minimap.git
|
||||||
|
;; or http://randomsample.de/minimap.git
|
||||||
|
|
||||||
|
;;; KNOWN BUGS:
|
||||||
|
|
||||||
|
;; * Currently cannot deal with images.
|
||||||
|
;; * Display/movement can be a bit erratic at times.
|
||||||
|
|
||||||
|
;;; TODO:
|
||||||
|
|
||||||
|
;; * Fix known bugs.
|
||||||
|
;; * Make sidebar permanently visible. This requires something like a
|
||||||
|
;; 'window group' feature in Emacs, which is currently being worked on.
|
||||||
|
;; * Moving the active region with the keyboard / mouse-wheel ?
|
||||||
|
|
||||||
|
|
||||||
|
;;; Customizable variables:
|
||||||
|
|
||||||
|
(defgroup minimap nil
|
||||||
|
"A minimap sidebar for Emacs."
|
||||||
|
:group 'convenience)
|
||||||
|
|
||||||
|
(defface minimap-font-face
|
||||||
|
'((default :family "DejaVu Sans Mono" :height 30))
|
||||||
|
"Face used for text in minimap buffer, notably the font family and height.
|
||||||
|
This height should be really small. You probably want to use a
|
||||||
|
TrueType font for this. After changing this, you should
|
||||||
|
recreate the minimap to avoid problems with recentering."
|
||||||
|
:group 'minimap)
|
||||||
|
|
||||||
|
(defface minimap-active-region-background
|
||||||
|
'((((background dark)) (:background "#4517305D0000"))
|
||||||
|
(t (:background "#C847D8FEFFFF")))
|
||||||
|
"Face for the active region in the minimap.
|
||||||
|
By default, this is only a different background color."
|
||||||
|
:group 'minimap)
|
||||||
|
|
||||||
|
(defface minimap-semantic-function-face
|
||||||
|
'((((background dark))
|
||||||
|
(:box (:line-width 1 :color "white")
|
||||||
|
:inherit (font-lock-function-name-face minimap-font-face)
|
||||||
|
:height 2.5 :background "gray10"))
|
||||||
|
(t (:box (:line-width 1 :color "black")
|
||||||
|
:inherit (font-lock-function-name-face minimap-font-face)
|
||||||
|
:height 2.5 :background "gray90")))
|
||||||
|
"Face used for functions in the semantic overlay.")
|
||||||
|
|
||||||
|
(defface minimap-semantic-variable-face
|
||||||
|
'((((background dark))
|
||||||
|
(:box (:line-width 1 :color "white")
|
||||||
|
:inherit (font-lock-variable-name-face minimap-font-face)
|
||||||
|
:height 2.5 :background "gray10"))
|
||||||
|
(t (:box (:line-width 1 :color "black")
|
||||||
|
:inherit (font-lock-function-name-face minimap-font-face)
|
||||||
|
:height 2.5 :background "gray90")))
|
||||||
|
"Face used for variables in the semantic overlay.")
|
||||||
|
|
||||||
|
(defface minimap-semantic-type-face
|
||||||
|
'((((background dark))
|
||||||
|
(:box (:line-width 1 :color "white")
|
||||||
|
:inherit (font-lock-type-face minimap-font-face)
|
||||||
|
:height 2.5 :background "gray10"))
|
||||||
|
(t (:box (:line-width 1 :color "black")
|
||||||
|
:inherit (font-lock-function-name-face minimap-font-face)
|
||||||
|
:height 2.5 :background "gray90")))
|
||||||
|
"Face used for types in the semantic overlay.")
|
||||||
|
|
||||||
|
(defcustom minimap-width-fraction 0.2
|
||||||
|
"Fraction of width which should be used for minimap sidebar."
|
||||||
|
:type 'number
|
||||||
|
:group 'minimap)
|
||||||
|
|
||||||
|
(defcustom minimap-window-location 'left
|
||||||
|
"Location of the minimap window.
|
||||||
|
Can be either the symbol `left' or `right'."
|
||||||
|
:type '(choice (const :tag "Left" left)
|
||||||
|
(const :tag "Right" right))
|
||||||
|
:group 'minimap)
|
||||||
|
|
||||||
|
(defcustom minimap-buffer-name-prefix "*MINIMAP* "
|
||||||
|
"Prefix for buffer names of minimap sidebar."
|
||||||
|
:type 'string
|
||||||
|
:group 'minimap)
|
||||||
|
|
||||||
|
(defcustom minimap-update-delay 0.2
|
||||||
|
"Delay in seconds after which sidebar gets updated.
|
||||||
|
Setting this to 0 will let the minimap react immediately, but
|
||||||
|
this will slow down scrolling."
|
||||||
|
:type 'number
|
||||||
|
:set (lambda (sym value)
|
||||||
|
(set sym value)
|
||||||
|
(when (and (boundp 'minimap-timer-object)
|
||||||
|
minimap-timer-object)
|
||||||
|
(cancel-timer minimap-timer-object)
|
||||||
|
(setq minimap-timer-object
|
||||||
|
(run-with-idle-timer
|
||||||
|
minimap-update-delay t 'minimap-update))))
|
||||||
|
:group 'minimap)
|
||||||
|
|
||||||
|
(defcustom minimap-always-recenter nil
|
||||||
|
"Whether minimap sidebar should be recentered after every point movement."
|
||||||
|
:type 'boolean
|
||||||
|
:group 'minimap)
|
||||||
|
|
||||||
|
(defcustom minimap-recenter-type 'relative
|
||||||
|
"Specifies the type of recentering the minimap should use.
|
||||||
|
The minimap can use different types of recentering, i.e., how the
|
||||||
|
minimap should behave when you scroll in the main window or when
|
||||||
|
you drag the active region with the mouse. The following
|
||||||
|
explanations will probably not help much, so simply try them and
|
||||||
|
choose the one which suits you best.
|
||||||
|
|
||||||
|
`relative' -- The position of the active region in the minimap
|
||||||
|
corresponds with the relative position of this region in the
|
||||||
|
buffer. This the default.
|
||||||
|
|
||||||
|
`middle' -- The active region will stay fixed in the middle of
|
||||||
|
the minimap.
|
||||||
|
|
||||||
|
`free' -- The position will be more or less free. When dragging
|
||||||
|
the active region, the minimap will scroll when you reach the
|
||||||
|
bottom or top."
|
||||||
|
:type '(choice (const :tag "Relative" relative)
|
||||||
|
(const :tag "Middle" middle)
|
||||||
|
(const :tag "Free" free))
|
||||||
|
:group 'minimap)
|
||||||
|
|
||||||
|
(defcustom minimap-hide-scroll-bar t
|
||||||
|
"Whether the minimap should hide the vertical scrollbar."
|
||||||
|
:type 'boolean
|
||||||
|
:group 'minimap)
|
||||||
|
|
||||||
|
(defcustom minimap-hide-fringes t
|
||||||
|
"Whether the minimap should hide the fringes."
|
||||||
|
:type 'boolean
|
||||||
|
:group 'minimap)
|
||||||
|
|
||||||
|
(defcustom minimap-dedicated-window nil
|
||||||
|
"Whether the minimap should create a dedicated window."
|
||||||
|
:type 'boolean
|
||||||
|
:group 'minimap)
|
||||||
|
|
||||||
|
(defcustom minimap-display-semantic-overlays t
|
||||||
|
"Display overlays from CEDET's semantic analyzer.
|
||||||
|
If you use CEDET and the buffer's major-mode is supported, the
|
||||||
|
minimap can display overlays generated by the semantic analyzer.
|
||||||
|
By default, it will apply the faces `minimap-semantic-<X>-face',
|
||||||
|
with <X> being \"function\", \"variable\" and \"type\". Also, it
|
||||||
|
will display the name of the tag in the middle of the overlay in
|
||||||
|
the corresponding font-lock face.
|
||||||
|
|
||||||
|
See also `minimap-enlarge-certain-faces', which can be used as
|
||||||
|
fallback."
|
||||||
|
:type 'boolean
|
||||||
|
:group 'minimap)
|
||||||
|
|
||||||
|
(defcustom minimap-enlarge-certain-faces 'as-fallback
|
||||||
|
"Whether certain faces should be enlarged in the minimap.
|
||||||
|
All faces listed in `minimap-normal-height-faces' will be
|
||||||
|
displayed using the default font height, allowing you to still
|
||||||
|
read text using those faces. By default, this should enlarge all
|
||||||
|
function names in the minimap, given you have font locking
|
||||||
|
enabled. This variable can have the following values:
|
||||||
|
|
||||||
|
'as-fallback (the default) -- The feature will only be activated
|
||||||
|
if information from CEDET's semantic analyzer isn't available
|
||||||
|
(see: `minimap-display-semantic-overlays').
|
||||||
|
'always -- Always active.
|
||||||
|
nil -- Inactive."
|
||||||
|
:type '(choice (const :tag "Fallback if CEDET unavailable." 'as-fallback)
|
||||||
|
(const :tag "Always active." 'always)
|
||||||
|
(const :tag "Inactive." nil))
|
||||||
|
:group 'minimap)
|
||||||
|
|
||||||
|
(defcustom minimap-normal-height-faces '(font-lock-function-name-face)
|
||||||
|
"List of faces which should be displayed with normal height.
|
||||||
|
When `minimap-enlarge-certain-faces' is non-nil, all faces in
|
||||||
|
this list will be displayed using the default font height. By
|
||||||
|
default, this list contains `font-lock-function-name-face', so
|
||||||
|
you can still read function names in the minimap."
|
||||||
|
:type '(repeat face)
|
||||||
|
:group 'minimap)
|
||||||
|
|
||||||
|
(defcustom minimap-sync-overlay-properties '(face invisible)
|
||||||
|
"Specifies which overlay properties should be synced.
|
||||||
|
Unlike text properties, overlays are not applied automatically to
|
||||||
|
the minimap and must be explicitly synced. This variable
|
||||||
|
specifies which overlay properties should be synced by
|
||||||
|
`minimap-sync-overlays'. Most importantly, this variable should
|
||||||
|
include 'invisible', so that hidden text does not appear in the
|
||||||
|
minimap buffer."
|
||||||
|
:type '(repeat symbol)
|
||||||
|
:group 'minimap)
|
||||||
|
|
||||||
|
;;; Internal variables
|
||||||
|
|
||||||
|
(defvar minimap-start nil)
|
||||||
|
(defvar minimap-end nil)
|
||||||
|
(defvar minimap-active-overlay nil)
|
||||||
|
(defvar minimap-bufname nil)
|
||||||
|
(defvar minimap-timer-object nil)
|
||||||
|
(defvar minimap-active-minimaps 0)
|
||||||
|
(defvar minimap-base-overlay nil)
|
||||||
|
(defvar minimap-numlines nil)
|
||||||
|
(defvar minimap-pointmin-overlay nil)
|
||||||
|
|
||||||
|
(make-variable-buffer-local 'minimap-start)
|
||||||
|
(make-variable-buffer-local 'minimap-end)
|
||||||
|
(make-variable-buffer-local 'minimap-active-overlay)
|
||||||
|
(make-variable-buffer-local 'minimap-bufname)
|
||||||
|
(make-variable-buffer-local 'minimap-base-overlay)
|
||||||
|
(make-variable-buffer-local 'minimap-numlines)
|
||||||
|
(make-variable-buffer-local 'minimap-pointmin-overlay)
|
||||||
|
|
||||||
|
;;; Minimap creation / killing
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun minimap-create ()
|
||||||
|
"Create a minimap sidebar for the current window."
|
||||||
|
(interactive)
|
||||||
|
;; If minimap is visible, do nothing.
|
||||||
|
(unless (and minimap-bufname
|
||||||
|
(get-buffer minimap-bufname)
|
||||||
|
(get-buffer-window (get-buffer minimap-bufname)))
|
||||||
|
(let ((bufname (concat minimap-buffer-name-prefix
|
||||||
|
(buffer-name (current-buffer))))
|
||||||
|
(new-win (if (eq minimap-window-location 'left)
|
||||||
|
(split-window-horizontally
|
||||||
|
(round (* (window-width)
|
||||||
|
minimap-width-fraction)))
|
||||||
|
(split-window-horizontally
|
||||||
|
(round (* (window-width)
|
||||||
|
(- 1 minimap-width-fraction))))
|
||||||
|
(other-window 1))))
|
||||||
|
;; If minimap exists but isn't visible, reuse it.
|
||||||
|
(if (and minimap-bufname
|
||||||
|
(get-buffer minimap-bufname))
|
||||||
|
(switch-to-buffer minimap-bufname t)
|
||||||
|
;; Otherwise create new minimap
|
||||||
|
(minimap-new-minimap bufname)
|
||||||
|
;; If this is the first minimap, create the idle timer.
|
||||||
|
(when (zerop minimap-active-minimaps)
|
||||||
|
(setq minimap-timer-object
|
||||||
|
(run-with-idle-timer minimap-update-delay t 'minimap-update)))
|
||||||
|
(setq minimap-active-minimaps
|
||||||
|
(1+ minimap-active-minimaps))))
|
||||||
|
(other-window 1)
|
||||||
|
(minimap-sync-overlays)))
|
||||||
|
|
||||||
|
(defun minimap-new-minimap (bufname)
|
||||||
|
"Create new minimap BUFNAME for current buffer and window."
|
||||||
|
(let ((indbuf (make-indirect-buffer (current-buffer) bufname t))
|
||||||
|
(edges (window-pixel-edges)))
|
||||||
|
(setq minimap-bufname bufname)
|
||||||
|
(set-buffer indbuf)
|
||||||
|
(when minimap-hide-scroll-bar
|
||||||
|
(setq vertical-scroll-bar nil))
|
||||||
|
(switch-to-buffer indbuf)
|
||||||
|
(setq minimap-base-overlay (make-overlay (point-min) (point-max) nil t t))
|
||||||
|
(overlay-put minimap-base-overlay 'face 'minimap-font-face)
|
||||||
|
(overlay-put minimap-base-overlay 'priority 1)
|
||||||
|
(setq minimap-pointmin-overlay (make-overlay (point-min) (1+ (point-min))))
|
||||||
|
(setq minimap-start (window-start)
|
||||||
|
minimap-end (window-end)
|
||||||
|
minimap-active-overlay (make-overlay minimap-start minimap-end)
|
||||||
|
line-spacing 0)
|
||||||
|
(overlay-put minimap-active-overlay 'face
|
||||||
|
'minimap-active-region-background)
|
||||||
|
(overlay-put minimap-active-overlay 'priority 5)
|
||||||
|
(minimap-mode 1)
|
||||||
|
(when (and (boundp 'linum-mode)
|
||||||
|
linum-mode)
|
||||||
|
(linum-mode 0))
|
||||||
|
(when minimap-hide-fringes
|
||||||
|
(set-window-fringes nil 0 0))
|
||||||
|
(when minimap-dedicated-window
|
||||||
|
(set-window-dedicated-p nil t))
|
||||||
|
(setq buffer-read-only t)
|
||||||
|
;; Calculate the actual number of lines displayable with the minimap face.
|
||||||
|
(setq minimap-numlines
|
||||||
|
(floor
|
||||||
|
(/
|
||||||
|
(- (nth 3 edges) (nth 1 edges))
|
||||||
|
(car (progn (redisplay) (window-line-height))))))))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun minimap-kill ()
|
||||||
|
"Kill minimap for current buffer.
|
||||||
|
Cancel the idle timer if no more minimaps are active."
|
||||||
|
(interactive)
|
||||||
|
(if (null minimap-bufname)
|
||||||
|
(message "No minimap associated with %s." (buffer-name (current-buffer)))
|
||||||
|
(let ((curname (buffer-name (current-buffer)))
|
||||||
|
(buf (get-buffer minimap-bufname))
|
||||||
|
(win (get-buffer-window minimap-bufname)))
|
||||||
|
(setq minimap-bufname nil)
|
||||||
|
(if (null buf)
|
||||||
|
(message "No minimap associated with %s." curname)
|
||||||
|
(when win
|
||||||
|
(delete-window win))
|
||||||
|
(kill-buffer buf)
|
||||||
|
(when (zerop
|
||||||
|
(setq minimap-active-minimaps
|
||||||
|
(1- minimap-active-minimaps)))
|
||||||
|
(cancel-timer minimap-timer-object)
|
||||||
|
(setq minimap-timer-object nil))
|
||||||
|
(message "Minimap for %s killed." curname)))))
|
||||||
|
|
||||||
|
;;; Minimap update
|
||||||
|
|
||||||
|
(defun minimap-update (&optional force)
|
||||||
|
"Update minimap sidebar if necessary.
|
||||||
|
This is meant to be called from the idle-timer or the post command hook.
|
||||||
|
When FORCE, enforce update of the active region."
|
||||||
|
(when minimap-bufname
|
||||||
|
(let ((win (get-buffer-window minimap-bufname))
|
||||||
|
start end pt ov)
|
||||||
|
(when win
|
||||||
|
(setq start (window-start)
|
||||||
|
end (window-end)
|
||||||
|
pt (point)
|
||||||
|
ov)
|
||||||
|
(with-selected-window win
|
||||||
|
(unless (and (not force)
|
||||||
|
(= minimap-start start)
|
||||||
|
(= minimap-end end))
|
||||||
|
(move-overlay minimap-active-overlay start end)
|
||||||
|
(setq minimap-start start
|
||||||
|
minimap-end end)
|
||||||
|
(minimap-recenter (line-number-at-pos (/ (+ end start) 2))
|
||||||
|
(/ (- (line-number-at-pos end)
|
||||||
|
(line-number-at-pos start))
|
||||||
|
2)))
|
||||||
|
(goto-char pt)
|
||||||
|
(when minimap-always-recenter
|
||||||
|
(recenter (round (/ (window-height) 2)))))))))
|
||||||
|
|
||||||
|
;;; Overlay movement
|
||||||
|
|
||||||
|
(defun minimap-move-overlay-mouse (start-event)
|
||||||
|
"Move overlay by tracking mouse movement."
|
||||||
|
(interactive "e")
|
||||||
|
(mouse-set-point start-event)
|
||||||
|
(when (get-buffer-window (buffer-base-buffer (current-buffer)))
|
||||||
|
(let* ((echo-keystrokes 0)
|
||||||
|
(end-posn (event-end start-event))
|
||||||
|
(start-point (posn-point end-posn))
|
||||||
|
(make-cursor-line-fully-visible nil)
|
||||||
|
(cursor-type nil)
|
||||||
|
(pcselmode pc-selection-mode)
|
||||||
|
pt ev)
|
||||||
|
(when pcselmode
|
||||||
|
(pc-selection-mode -1))
|
||||||
|
(move-overlay minimap-active-overlay start-point minimap-end)
|
||||||
|
(track-mouse
|
||||||
|
(minimap-set-overlay start-point)
|
||||||
|
(while (and
|
||||||
|
(consp (setq ev (read-event)))
|
||||||
|
(eq (car ev) 'mouse-movement))
|
||||||
|
(setq pt (posn-point (event-start ev)))
|
||||||
|
(when (numberp pt)
|
||||||
|
(minimap-set-overlay pt))))
|
||||||
|
(select-window (get-buffer-window (buffer-base-buffer)))
|
||||||
|
(minimap-update)
|
||||||
|
(when pcselmode
|
||||||
|
(pc-selection-mode 1)))))
|
||||||
|
|
||||||
|
(defun minimap-set-overlay (pt)
|
||||||
|
"Set overlay position, with PT being the middle."
|
||||||
|
(goto-char pt)
|
||||||
|
(let* ((ovstartline (line-number-at-pos minimap-start))
|
||||||
|
(ovendline (line-number-at-pos minimap-end))
|
||||||
|
(ovheight (round (/ (- ovendline ovstartline) 2)))
|
||||||
|
(line (line-number-at-pos))
|
||||||
|
(winstart (window-start))
|
||||||
|
(winend (window-end))
|
||||||
|
newstart newend)
|
||||||
|
(setq pt (point-at-bol))
|
||||||
|
(setq newstart (minimap-line-to-pos (- line ovheight)))
|
||||||
|
;; Perform recentering
|
||||||
|
(minimap-recenter line ovheight)
|
||||||
|
;; Set new position in main buffer and redisplay
|
||||||
|
(with-selected-window (get-buffer-window (buffer-base-buffer))
|
||||||
|
(goto-char pt)
|
||||||
|
(set-window-start nil newstart)
|
||||||
|
(redisplay t)
|
||||||
|
(setq newend (window-end)))
|
||||||
|
(when (eq minimap-recenter-type 'free)
|
||||||
|
(while (> newend winend)
|
||||||
|
(scroll-up 5)
|
||||||
|
(redisplay t)
|
||||||
|
(setq winend (window-end))))
|
||||||
|
(move-overlay minimap-active-overlay newstart newend)))
|
||||||
|
|
||||||
|
(defun minimap-line-to-pos (line)
|
||||||
|
"Return point position of line number LINE."
|
||||||
|
(save-excursion
|
||||||
|
(goto-char 1)
|
||||||
|
(if (eq selective-display t)
|
||||||
|
(re-search-forward "[\n\C-m]" nil 'end (1- line))
|
||||||
|
(forward-line (1- line)))
|
||||||
|
(point)))
|
||||||
|
|
||||||
|
(defun minimap-recenter (middle height)
|
||||||
|
"Recenter the minimap according to `minimap-recenter-type'.
|
||||||
|
MIDDLE is the line number in the middle of the active region.
|
||||||
|
HEIGHT is the number of lines from MIDDLE to begin/end of the
|
||||||
|
active region."
|
||||||
|
(cond
|
||||||
|
;; Relative recentering
|
||||||
|
((eq minimap-recenter-type 'relative)
|
||||||
|
(let* ((maxlines (line-number-at-pos (point-max)))
|
||||||
|
percentage relpos newline start numlines)
|
||||||
|
(setq numlines (count-lines (window-start) (window-end)))
|
||||||
|
(setq percentage (/ (float middle) (float maxlines)))
|
||||||
|
(setq newline (ceiling (* percentage numlines)))
|
||||||
|
(setq start (minimap-line-to-pos
|
||||||
|
(- middle height
|
||||||
|
(floor (* percentage
|
||||||
|
(- numlines height height))))))
|
||||||
|
(or (> start (point-min))
|
||||||
|
(setq start (point-min)))
|
||||||
|
;; If (point-max) already visible, don't go further
|
||||||
|
(if (and (> start (window-start))
|
||||||
|
(with-selected-window (get-buffer-window (buffer-base-buffer))
|
||||||
|
(= (point-max) (window-end))))
|
||||||
|
(save-excursion
|
||||||
|
(goto-char (point-max))
|
||||||
|
(recenter -1))
|
||||||
|
(unless (and (> start (window-start))
|
||||||
|
(= (point-max) (window-end)))
|
||||||
|
(set-window-start nil start)))))
|
||||||
|
;; Middle recentering
|
||||||
|
((eq minimap-recenter-type 'middle)
|
||||||
|
(let ((start (- middle height
|
||||||
|
(floor (* 0.5
|
||||||
|
(- minimap-numlines height height))))))
|
||||||
|
(if (< start 1)
|
||||||
|
(progn
|
||||||
|
;; Hack: Emacs cannot scroll down any further, so we fake
|
||||||
|
;; it using an overlay. Otherwise, the active region
|
||||||
|
;; would move to the top.
|
||||||
|
(overlay-put minimap-pointmin-overlay
|
||||||
|
'display (concat
|
||||||
|
(make-string (abs start) 10)
|
||||||
|
(buffer-substring (point-min) (1+ (point-min)))))
|
||||||
|
(overlay-put minimap-pointmin-overlay
|
||||||
|
'face `(:background ,(face-background 'default)))
|
||||||
|
(overlay-put minimap-pointmin-overlay
|
||||||
|
'priority 10)
|
||||||
|
(setq start 1))
|
||||||
|
(overlay-put minimap-pointmin-overlay 'display "")
|
||||||
|
(overlay-put minimap-pointmin-overlay 'face nil))
|
||||||
|
(set-window-start nil (minimap-line-to-pos start))))
|
||||||
|
;; Free recentering
|
||||||
|
((eq minimap-recenter-type 'free)
|
||||||
|
(let ((newstart (minimap-line-to-pos (- middle height)))
|
||||||
|
(winstart (window-start)))
|
||||||
|
(while (< newstart winstart)
|
||||||
|
(scroll-down 5)
|
||||||
|
(redisplay t)
|
||||||
|
(setq winstart (window-start)))))))
|
||||||
|
|
||||||
|
;;; Minimap minor mode
|
||||||
|
|
||||||
|
(defvar minimap-mode-map (make-sparse-keymap)
|
||||||
|
"Keymap used by `minimap-mode'.")
|
||||||
|
|
||||||
|
(define-key minimap-mode-map [down-mouse-1] 'minimap-move-overlay-mouse)
|
||||||
|
(define-key minimap-mode-map [down-mouse-2] 'minimap-move-overlay-mouse)
|
||||||
|
(define-key minimap-mode-map [down-mouse-3] 'minimap-move-overlay-mouse)
|
||||||
|
|
||||||
|
(define-minor-mode minimap-mode
|
||||||
|
"Minor mode for minimap sidebar."
|
||||||
|
nil "minimap" minimap-mode-map)
|
||||||
|
|
||||||
|
;;; Sync minimap with modes which create/delete overlays.
|
||||||
|
|
||||||
|
(defun minimap-sync-overlays ()
|
||||||
|
"Synchronize overlays between base and minimap buffer.
|
||||||
|
Apply semantic overlays or face enlargement if necessary."
|
||||||
|
(interactive)
|
||||||
|
(when minimap-bufname
|
||||||
|
(let ((baseov (overlays-in (point-min) (point-max)))
|
||||||
|
(semantic (and (boundp 'semantic-version)
|
||||||
|
(semantic-active-p)))
|
||||||
|
ov props p)
|
||||||
|
(with-current-buffer minimap-bufname
|
||||||
|
(remove-overlays)
|
||||||
|
(while baseov
|
||||||
|
(when (setq props (minimap-get-sync-properties (car baseov)))
|
||||||
|
(setq ov (make-overlay (overlay-start (car baseov))
|
||||||
|
(overlay-end (car baseov))))
|
||||||
|
(while (setq p (car props))
|
||||||
|
(overlay-put ov (car p) (cadr p))
|
||||||
|
(setq props (cdr props))))
|
||||||
|
(setq baseov (cdr baseov)))
|
||||||
|
(move-overlay minimap-pointmin-overlay (point-min) (1+ (point-min)))
|
||||||
|
;; Re-apply font overlay
|
||||||
|
(move-overlay minimap-base-overlay (point-min) (point-max)))
|
||||||
|
;; Face enlargement
|
||||||
|
(when (and font-lock-mode
|
||||||
|
(or (eq minimap-enlarge-certain-faces 'always)
|
||||||
|
(and (eq minimap-enlarge-certain-faces 'as-fallback)
|
||||||
|
(or (not minimap-display-semantic-overlays)
|
||||||
|
(not semantic)))))
|
||||||
|
(when (eq font-lock-support-mode 'jit-lock-mode)
|
||||||
|
(jit-lock-fontify-now))
|
||||||
|
(with-current-buffer minimap-bufname
|
||||||
|
(minimap-enlarge-faces)))
|
||||||
|
;; Semantic overlays
|
||||||
|
(when (and semantic
|
||||||
|
minimap-display-semantic-overlays)
|
||||||
|
(minimap-apply-semantic-overlays)))
|
||||||
|
(minimap-update t)))
|
||||||
|
|
||||||
|
(defun minimap-get-sync-properties (ov)
|
||||||
|
"Get properties from overlay OV which should be synced.
|
||||||
|
You can specify those properties with
|
||||||
|
`minimap-sync-overlay-properties'."
|
||||||
|
(delq nil
|
||||||
|
(mapcar
|
||||||
|
(lambda (p)
|
||||||
|
(let ((val (overlay-get ov p)))
|
||||||
|
(if val
|
||||||
|
(list p val)
|
||||||
|
nil)))
|
||||||
|
minimap-sync-overlay-properties)))
|
||||||
|
|
||||||
|
(defun minimap-enlarge-faces ()
|
||||||
|
"Apply default font to all faces in `minimap-normal-height-faces'.
|
||||||
|
This has to be called in the minimap buffer."
|
||||||
|
(let ((pos (next-single-property-change (point-min) 'face))
|
||||||
|
next ov face)
|
||||||
|
(while pos
|
||||||
|
(setq face (get-text-property pos 'face))
|
||||||
|
(when (delq nil (mapcar (lambda (x) (equal x face))
|
||||||
|
minimap-normal-height-faces))
|
||||||
|
(setq ov
|
||||||
|
(make-overlay pos
|
||||||
|
(setq pos (next-single-property-change pos 'face))))
|
||||||
|
(overlay-put ov 'face `(:family ,(face-font 'default)))
|
||||||
|
(overlay-put ov 'priority 5))
|
||||||
|
(setq pos (next-single-property-change pos 'face)))))
|
||||||
|
|
||||||
|
(defun minimap-apply-semantic-overlays ()
|
||||||
|
"Apply semantic overlays to the minimap.
|
||||||
|
This has to be called from the base buffer."
|
||||||
|
(let ((tags (semantic-fetch-tags))
|
||||||
|
tag class ov ovnew)
|
||||||
|
(while tags
|
||||||
|
(setq tag (car tags))
|
||||||
|
(setq class (semantic-tag-class tag))
|
||||||
|
(setq ov (semantic-tag-overlay tag))
|
||||||
|
(when (and (overlayp ov)
|
||||||
|
(or (eq class 'function)
|
||||||
|
(eq class 'type)
|
||||||
|
(eq class 'variable)))
|
||||||
|
(with-current-buffer minimap-bufname
|
||||||
|
(let ((start (overlay-start ov))
|
||||||
|
(end (overlay-end ov))
|
||||||
|
(name (semantic-tag-name tag)))
|
||||||
|
(overlay-put
|
||||||
|
(setq ovnew (make-overlay start end))
|
||||||
|
'face `(:background ,(face-background
|
||||||
|
(intern (format "minimap-semantic-%s-face"
|
||||||
|
(symbol-name class))))))
|
||||||
|
(overlay-put ovnew 'priority 1)
|
||||||
|
(setq start
|
||||||
|
(minimap-line-to-pos (/ (+ (line-number-at-pos start)
|
||||||
|
(line-number-at-pos end)) 2)))
|
||||||
|
(setq end (progn (goto-char start) (point-at-eol)))
|
||||||
|
(setq ovnew (make-overlay start end))
|
||||||
|
(overlay-put ovnew 'face (format "minimap-semantic-%s-face"
|
||||||
|
(symbol-name class)))
|
||||||
|
(overlay-put ovnew 'display (concat " " name " "))
|
||||||
|
(overlay-put ovnew 'priority 6))))
|
||||||
|
(setq tags (cdr tags)))))
|
||||||
|
|
||||||
|
;; outline-(minor-)mode
|
||||||
|
(add-hook 'outline-view-change-hook 'minimap-sync-overlays)
|
||||||
|
|
||||||
|
;; hideshow
|
||||||
|
(add-hook 'hs-hide-hook 'minimap-sync-overlays)
|
||||||
|
(add-hook 'hs-show-hook 'minimap-sync-overlays)
|
||||||
|
|
||||||
|
(provide 'minimap)
|
||||||
|
|
||||||
|
;;; minimap.el ends here
|
||||||
Loading…
Reference in a new issue