99 lines
4.8 KiB
Org Mode
99 lines
4.8 KiB
Org Mode
:PROPERTIES:
|
|
:ID: cce/surfing_through_codebases
|
|
:END:
|
|
#+TITLE: Surfing Through Codebases
|
|
#+filetags: :Emacs:CCE:Coding:
|
|
#+PROPERTY: header-args :mkdirp yes :results none
|
|
#+PROPERTY: header-args:emacs-lisp :tangle code-surf.el
|
|
#+ARROYO_EMACS_MODULE: code-surf
|
|
#+ARCOLOGY_KEY: cce/code-surf
|
|
#+ARCOLOGY_ALLOW_CRAWL: t
|
|
#+ARROYO_MODULE_WANTS: cce/basic_emacs_coding_config.org
|
|
|
|
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-locking[fn:1:[[id:modern_interface_terms][Glossary]]], and reintroduces colors using [[https://github.com/Fanael/rainbow-identifiers][rainbow-identifiers]] mode. In combination with my [[id:cce/focused_text_editing][Focused Text Editing]] fundamentals, and my Emacs code navigation tooling, I can work my way through codebases I otherwise don't understand.
|
|
|
|
#+begin_src emacs-lisp
|
|
(provide 'cce/code-surf)
|
|
(defun enable-code-surf ()
|
|
(interactive)
|
|
(global-rainbow-identifiers-mode)
|
|
(global-auto-highlight-symbol-mode)
|
|
|
|
(set-face-attribute '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)
|
|
|
|
(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)
|
|
(define-minor-mode code-surf-mode "Disable most font locking and enable rainbow-delimeters"
|
|
nil "[CS]" nil
|
|
(if code-surf-mode
|
|
(progn
|
|
(message "enable")
|
|
(enable-code-surf))
|
|
(progn
|
|
(message "disable")
|
|
(global-rainbow-identifiers-mode -1)
|
|
(global-auto-highlight-symbol-mode -1)
|
|
(mapc (lambda (name)
|
|
(enable-theme name))
|
|
code-surf-last-themes))))
|
|
#+END_SRC
|
|
|
|
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=.
|
|
|
|
#+begin_src emacs-lisp
|
|
(use-package rainbow-identifiers
|
|
:config
|
|
(define-global-minor-mode
|
|
global-rainbow-identifiers-mode
|
|
rainbow-identifiers-mode
|
|
(lambda ()
|
|
(when (derived-mode-p 'prog-mode)
|
|
(rainbow-identifiers-mode))))
|
|
(setq rainbow-identifiers-cie-l*a*b*-lightness 40
|
|
rainbow-identifiers-cie-l*a*b*-saturation 70
|
|
rainbow-identifiers-choose-face-function 'rainbow-identifiers-cie-l*a*b*-choose-face))
|
|
#+END_SRC
|
|
|
|
#+begin_src emacs-lisp
|
|
(use-package auto-highlight-symbol
|
|
:bind (:map evil-leader--default-map)
|
|
("v" . hydra-highlight-symbol/body)
|
|
:config
|
|
(defhydra hydra-highlight-symbol nil
|
|
"
|
|
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)))
|
|
#+end_src
|