Code Surfing is a minor-mode which makes it easy for me to explore codebases that I am not entirely familiar with. It disables the language font-locking1, and reintroduces colors using rainbow-identifiers mode. In combination with my Focused Text Editing fundamentals, and my Emacs code navigation tooling, I can work my way through codebases I otherwise don't understand.
provide 'cce/code-surf)
(defun enable-code-surf ()
(
(interactive)
(global-rainbow-identifiers-mode)
(global-auto-highlight-symbol-mode)
'font-lock-builtin-face nil :inherit 'default :foreground nil :background nil)
(set-face-attribute 'font-lock-comment-face nil :inherit 'default :foreground "grey50" :background nil)
(set-face-attribute 'font-lock-comment-delimiter-face nil :inherit 'font-lock-comment-face)
(set-face-attribute 'font-lock-constant-face nil :inherit 'default :foreground nil :background nil)
(set-face-attribute 'font-lock-doc-face nil :inherit 'default :foreground "grey50" :background nil)
(set-face-attribute 'font-lock-function-name-face nil :inherit 'default :foreground nil :background nil)
(set-face-attribute 'font-lock-keyword-face nil :inherit 'default :foreground nil :background nil :weight 'normal)
(set-face-attribute 'font-lock-negation-char-face nil :inherit 'default) :foreground nil :background nil
(set-face-attribute 'font-lock-preprocessor-face nil :inherit 'default) :foreground nil :background nil
(set-face-attribute 'font-lock-string-face nil :inherit 'default :foreground nil :background nil)
(set-face-attribute 'font-lock-type-face nil :inherit 'default :foreground nil :background nil)
(set-face-attribute 'font-lock-variable-name-face nil :inherit 'default :foreground nil :background nil)
(set-face-attribute 'font-lock-warning-face nil :inherit 'default :foreground nil :background nil)
(set-face-attribute 'font-lock-regexp-grouping-backslash nil :inherit 'default :foreground nil :background nil)
(set-face-attribute 'font-lock-regexp-grouping-construct nil :inherit 'default :foreground nil :background nil)
(set-face-attribute
setq rainbow-identifiers-faces-to-override '(font-lock-function-name-face
(
font-lock-warning-face
font-lock-type-face
font-lock-constant-face
font-lock-variable-name-face)))
setq code-surf-last-themes custom-enabled-themes)
("Disable most font locking and enable rainbow-delimeters"
(define-minor-mode code-surf-mode nil "[CS]" nil
if code-surf-mode
(progn
("enable")
(message
(enable-code-surf))progn
("disable")
(message
(global-rainbow-identifiers-mode -1)
(global-auto-highlight-symbol-mode -1)mapc (lambda (name)
(
(enable-theme name)) code-surf-last-themes))))
This code-surf-mode
uses Rainbow
Identifiers and Auto Highlight Symbol. Configuration of
rainbow-identifiers is simple, we simply expand the range of colors that
it is willing to use, and define a global minor mode which will enable
rainbow-identifiers in every buffer which inherits prog-mode
.
use-package rainbow-identifiers
(
:config
(define-global-minor-mode
global-rainbow-identifiers-mode
rainbow-identifiers-modelambda ()
(when (derived-mode-p 'prog-mode)
(
(rainbow-identifiers-mode))))setq rainbow-identifiers-cie-l*a*b*-lightness 40
(70
rainbow-identifiers-cie-l*a*b*-saturation 'rainbow-identifiers-cie-l*a*b*-choose-face)) rainbow-identifiers-choose-face-function
use-package auto-highlight-symbol
(
:bind (:map evil-leader--default-map)"v" . hydra-highlight-symbol/body)
(
:confignil
(defhydra hydra-highlight-symbol "
Highlight -----------> Dim
_h_: Highlight at Point _f_: flow
_j_: Previous Symbol _r_: focus-ro
_k_: Next Symbol _e_: end flow
_d_: Clear All Symbols
_a_: Toggle AHS
"
"h" highlight-symbol-at-point)
("j" highlight-symbol-prev)
("k" highlight-symbol-next)
("d" highlight-symbol-remove-all)
("a" auto-highlight-symbol-mode)
("f" flow :exit t)
("e" end-flow :exit t)
("r" focus-read-only-mode))) (