From 96c3747b1ca046fc6e71839a534016ae3679f3ec Mon Sep 17 00:00:00 2001 From: Christopher James Hayward Date: Sun, 16 May 2021 11:57:40 -0400 Subject: [PATCH] Cleanup modules --- elisp/options.el | 2 +- modules/fonts.org | 125 ++++++++++++++++++++++++++++++++++++++++++ modules/interface.org | 122 ----------------------------------------- modules/org.org | 24 ++++++-- 4 files changed, 145 insertions(+), 128 deletions(-) create mode 100644 modules/fonts.org diff --git a/elisp/options.el b/elisp/options.el index fc22bd3..c31da15 100644 --- a/elisp/options.el +++ b/elisp/options.el @@ -17,7 +17,7 @@ capture projects development - interface themes modeline + fonts interface themes modeline dashboard) "All of the available modules.") diff --git a/modules/fonts.org b/modules/fonts.org new file mode 100644 index 0000000..77e13d1 --- /dev/null +++ b/modules/fonts.org @@ -0,0 +1,125 @@ +#+TITLE: Fonts +#+AUTHOR: Christopher James Hayward +#+EMAIL: chris@chrishayward.xyz + +#+PROPERTY: header-args:emacs-lisp :tangle fonts.el :comments org +#+PROPERTY: header-args:shell :tangle no +#+PROPERTY: header-args :results silent :eval no-export :comments org + +#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil +#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil + +Unified system font across Emacs. + +* Setup + +Install the required ~firacode~[fn:1] font before loading the module: + +#+begin_src shell +RUN apt install -y fonts-firacode +#+end_src + +* Config + +Write out the value of ~dotfiles/font~ to all of the available font faces supported by Emacs. By default, this uses ~firacode~[fn:1] for its readability and ligature support. All of the heights are configured to ~dotfiles/font-size~ by default, with further configuration based on the given size possible. + +#+begin_src emacs-lisp +(set-face-attribute 'default nil :font dotfiles/font :height dotfiles/font-size) +(set-face-attribute 'fixed-pitch nil :font dotfiles/font :height dotfiles/font-size) +(set-face-attribute 'variable-pitch nil :font dotfiles/font :height dotfiles/font-size) +#+end_src + +** Icons + +Emacs feels more modern with prioritized icon fonts, available in the ~all-the-icons~[fn:2] package. This makes navigation and visually parsing directories much faster, given that the file types are quickly identified by their corresponding icons. + +#+begin_src emacs-lisp +(use-package all-the-icons) +#+end_src + +Integration with the built-in ~dired~ package is available in the ~all-the-icons-dired~[fn:3] package. + +#+begin_src emacs-lisp +(use-package all-the-icons-dired + :hook (dired-mode . all-the-icons-dired-mode)) +#+end_src + +** Emojis + +It's finally here, first class support for Emojis in Emacs via the ~emacs-emojify~[fn:4] package. Have we finally gone too far? + +#+begin_src emacs-lisp +(use-package emojify + :when (window-system) + :hook (after-init . global-emojify-mode)) +#+end_src + +** Symbols + +Programming buffers can be made prettier with ~pretty-mode~[fn:5], this is complimentary to ~prettify-symbols-mode~[fn:6], a built-in package containing similar (but lacking) functionality. + +#+begin_src emacs-lisp +(use-package pretty-mode + :hook (python-mode . turn-on-pretty-mode)) +#+end_src + +** Ligatures + +Enable ~firacode~[fn:1] font ligatures with the ~fira-code-mode~[fn:7] package. Only perform this action when ~firacode~[fn:1] is the current font, and Emacs isn't running on the TTY. + +#+begin_src emacs-lisp +(use-package fira-code-mode + :when (and (window-system) + (equal dotfiles/font "Fira Code")) + :hook (prog-mode org-mode)) +#+end_src + +** Parenthesis + +Colourize nested parenthesis with ~rainbow-delimeters~[fn:4], a mandatory life-jacked to keep you from drowning in the sea of them in Lisp. + +#+begin_src emacs-lisp +(use-package rainbow-delimiters + :hook (prog-mode . rainbow-delimiters-mode)) +#+end_src + +** Text scaling + +Define a transient keybinding for scaling the text. One caveat to this, it only works when Emacs is running as a GUI application, and has no effect in the terminal. + +#+begin_src emacs-lisp +(defhydra hydra-text-scale (:timeout 4) + "Scale" + ("j" text-scale-increase "Increase") + ("k" text-scale-decrease "Decrease") + ("f" nil "Finished" :exit t)) +#+end_src + +* Shortcuts + +Scale the text inside of buffers using the custom transient binding, behind =SPC t f=: + ++ Increase with =j= ++ Decrease with =k= ++ Finish with =f= + +#+begin_src emacs-lisp +(dotfiles/leader + "tf" '(hydra-text-scale/body :which-key "Font")) +#+end_src + +* Footnotes + +[fn:1] https://github.com/tonsky/FiraCode + +[fn:2] [[https://github.com/domtronn/all-the-icons.el]] + +[fn:3] https://github.com/jtbm37/all-the-icons-dired + +[fn:4] https://github.com/Fanael/rainbow-delimiters + +[fn:5] https://emacswiki.org/emacs/pretty-mode.el + +[fn:6] https://emacswiki.org/emacs/PrettySymbol + +[fn:7] https://github.com/jming422/fira-code-mode diff --git a/modules/interface.org b/modules/interface.org index c4d4538..6becc2c 100644 --- a/modules/interface.org +++ b/modules/interface.org @@ -116,108 +116,6 @@ Sort completion candidates based on how recently or frequently they're selected. (ivy-prescient-mode 1)) #+end_src -* Unified fonts - -Write out to all of Emacs' available font faces with the unified font defined in the options. - -#+begin_src emacs-lisp -(set-face-attribute 'default nil :font dotfiles/font :height dotfiles/font-size) -(set-face-attribute 'fixed-pitch nil :font dotfiles/font :height dotfiles/font-size) -(set-face-attribute 'variable-pitch nil :font dotfiles/font :height dotfiles/font-size) -#+end_src - -** Text scaling - -Define a transient keybinding for Scaling the text. - -#+begin_src emacs-lisp -(defhydra hydra-text-scale (:timeout 4) - "Scale" - ("j" text-scale-increase "Increase") - ("k" text-scale-decrease "Decrease") - ("f" nil "Finished" :exit t)) -#+end_src - -+ Scale the text inside of buffers with =SPC t f= - * Increase =j= - * Decrease =k= - * Finished =f= - -#+begin_src emacs-lisp -(dotfiles/leader - "tf" '(hydra-text-scale/body :which-key "Font")) -#+end_src - -** Icon fonts - -Dired feels more modern with prioritized icon fonts using *All the Icons*[fn:3]. This makes navigation and visually parsing directories much faster, given that file types are quickly identified by their corresponding icons. - -#+begin_src emacs-lisp -(use-package all-the-icons) -#+end_src - -Integration with the *All the Icons Dired*[fn:4]package. - -#+begin_src emacs-lisp -(use-package all-the-icons-dired - :hook (dired-mode . all-the-icons-dired-mode)) -#+end_src - -** Symbols - -Programming buffers made prettier with *Pretty mode*[fn:5], complimentary to the built-in *Prettify symbols mode*[fn:6]. - -#+begin_src emacs-lisp -(use-package pretty-mode - :hook (python-mode . turn-on-pretty-mode)) -#+end_src - -** Ligatures - -Enable font ligatures via *Fira Code mode*[fn:7]. - -+ Perform when *Fira Code* is the current font -+ Don't enable on TTY - -#+begin_src emacs-lisp -(use-package fira-code-mode - :when (and (window-system) - (equal dotfiles/font "Fira Code")) - :hook (prog-mode org-mode)) -#+end_src - -Toggle global ligature mode with =SPC t g=. - -#+begin_src emacs-lisp -(dotfiles/leader - "tg" '(global-fira-code-mode :which-key "Ligatures")) -#+end_src - -** Emojification - -Gotta have those emojis, first class support for Emacs via the *Emacs-emojify*[fn:8] package. - -#+begin_src emacs-lisp -(use-package emojify - :when (window-system) - :hook (after-init . global-emojify-mode)) -#+end_src - -+ Place *Emojify*[fn:8] bindings behind =SPC f= - * List with =l= - * Search with =s= - * Insert with =i= - * Describe with =d= - -#+begin_src emacs-lisp -;; (dotfiles/leader -;; "f" '(:ignore t :which-key "Emojify") -;; "fl" '(emojify-list-emojis :which-key "List") -;; "fs" '(emojify-apropos-emoji :which-key "Search") -;; "fi" '(emojify-insert-emoji :which-key "Insert") -;; "fd" '(emojify-describe-emoji :which-key "Describe")) -#+end_src - * Line numbering Relative line numbers are important when using VI emulation keys. You can prefix commands with a number, allowing you to perform that action that number of times. Useful when navigating around pages that are hundreds, or even thousands of lines long. @@ -250,26 +148,6 @@ Toggle line numbers with =SPC t l=. "tl" '(linum-relative-global-mode :which-key "Lines")) #+end_src -* Parenthesis - -Colourize nested parenthesis with *Rainbow delimeters*[fn:11]. - -#+begin_src emacs-lisp -(use-package rainbow-delimiters - :hook (prog-mode . rainbow-delimiters-mode)) -#+end_src - -* Superstar - -Make headline stars *super* with *Org superstar mode*[fn:12]. - -#+begin_src emacs-lisp -(use-package org-superstar - :when (window-system) - :after org - :hook (org-mode . org-superstar-mode)) -#+end_src - * Footnotes [fn:1] https://github.com/abo-abo/swiper diff --git a/modules/org.org b/modules/org.org index e3dd24a..d78b426 100644 --- a/modules/org.org +++ b/modules/org.org @@ -8,11 +8,11 @@ #+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil #+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil -Organize your plain-life in plain-text. The hallmark feature of Emacs, ~org-mode~ is the king of markup languages. It has rich feature support for project management, scheduling, development, and writing. It's hard to convey everything within its capabilities. +Organize your plain-life in plain-text. The hallmark feature of Emacs, ~org-mode~[fn:1] is the king of markup languages. It has rich feature support for project management, scheduling, development, and writing. It's hard to convey everything within its capabilities. -* Hook +* Setup -Define a custom hook when ~org-mode~ is enabled to customize the experience: +Define a custom hook when ~org-mode~[fn:1] is enabled to customize the experience: + Enable ~org-indent-mode~ to indent and align text with the parent heading + Enable ~visual-line-mode~ to allow text to overflow and wrap to the next visual line @@ -25,9 +25,9 @@ Define a custom hook when ~org-mode~ is enabled to customize the experience: (variable-pitch-mode 1)) ;; Enable monospaced fonts. #+end_src -* Setup +* Config -Force ~straight~ to ignore the local version of ~org-mode~, instead downloading the most recent version available. +Force ~straight~ to ignore the local version of ~org-mode~[fn:1], instead downloading the most recent version available. #+begin_src emacs-lisp (straight-use-package '(org :local-repo nil)) @@ -65,6 +65,17 @@ Setup the default babel languages and structure templates, and apply customizati (emacs-lisp . t)))) #+end_src +** Headline stars + +Make the headline stars a bit more *super* with ~org-superstar-mode~[fn:2]. Only enable this inside of a window system, as the effect can be distracting on the TTY. + +#+begin_src emacs-lisp +(use-package org-superstar + :when (window-system) + :after org + :hook (org-mode . org-superstar-mode)) +#+end_src + * Methods Define some custom methods for use in the rest of the configuration. @@ -100,3 +111,6 @@ Function that takes in a system and configuration file path, checks to see if th * Footnotes +[fn:1] https://orgmode.org + +[fn:2] https://github.com/integral-dw/org-superstar-mode