Skip to content

Instantly share code, notes, and snippets.

@mbuczko
Created July 29, 2019 11:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mbuczko/e15d61363d31cf78ff17427072e0c325 to your computer and use it in GitHub Desktop.
Save mbuczko/e15d61363d31cf78ff17427072e0c325 to your computer and use it in GitHub Desktop.
emacs / pretty-hydra config
(require 'all-the-icons)
(defun with-faicon (icon str &optional height v-adjust)
(s-concat (all-the-icons-faicon icon :v-adjust (or v-adjust 0) :height (or height 1)) " " str))
(defun with-fileicon (icon str &optional height v-adjust)
(s-concat (all-the-icons-fileicon icon :v-adjust (or v-adjust 0) :height (or height 1)) " " str))
(defun with-octicon (icon str &optional height v-adjust)
(s-concat (all-the-icons-octicon icon :v-adjust (or v-adjust 0) :height (or height 1)) " " str))
(defun with-material (icon str &optional height v-adjust)
(s-concat (all-the-icons-material icon :v-adjust (or v-adjust 0) :height (or height 1)) " " str))
(defun with-mode-icon (mode str &optional height nospace face)
(let* ((v-adjust (if (eq major-mode 'emacs-lisp-mode) 0.0 0.05))
(args `(:height ,(or height 1) :v-adjust ,v-adjust))
(_ (when face
(lax-plist-put args :face face)))
(icon (apply #'all-the-icons-icon-for-mode mode args))
(icon (if (symbolp icon)
(apply #'all-the-icons-octicon "file-text" args)
icon)))
(s-concat icon (if nospace "" " ") str)))
(pretty-hydra-define jp-toggles
(:color amaranth :quit-key "q" :title (with-faicon "toggle-on" "Titel"))
("Basic"
(("n" linum-mode "line number" :toggle t)
("w" whitespace-mode "whitespace" :toggle t)
("W" whitespace-cleanup-mode "whitespace cleanup" :toggle t)
("r" rainbow-mode "rainbow" :toggle t)
("L" page-break-lines-mode "page break lines" :toggle t))
"Highlight"
(("s" symbol-overlay-mode "symbol" :toggle t)
("l" hl-line-mode "line" :toggle t)
("x" highlight-sexp-mode "sexp" :toggle t)
("t" hl-todo-mode "todo" :toggle t))
"UI"
(("d" jp-themes-toggle-light-dark "dark theme" :toggle jp-current-theme-dark-p))
"Coding"
(("p" smartparens-mode "smartparens" :toggle t)
("P" smartparens-strict-mode "smartparens strict" :toggle t)
("S" show-smartparens-mode "show smartparens" :toggle t)
("f" flycheck-mode "flycheck" :toggle t))
"Emacs"
(("D" toggle-debug-on-error "debug on error" :toggle (default-value 'debug-on-error))
("X" toggle-debug-on-quit "debug on quit" :toggle (default-value 'debug-on-quit)))))
(defun jp-projects--title ()
(let ((p (projectile-project-name)))
(with-octicon "repo"
(if (s-blank-p p)
"Projects"
(s-concat "Projects (current: " p ")")))))
@AtomicNess123
Copy link

Excellent. What is "with-octicon"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment