I showed you my source code, pls respond
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

324 lines
9.2 KiB

4 years ago
  1. #+TITLE: Interface
  2. #+AUTHOR: Christopher James Hayward
  3. #+EMAIL: chris@chrishayward.xyz
  4. #+PROPERTY: header-args:emacs-lisp :tangle interface.el :comments org
  5. #+PROPERTY: header-args:shell :tangle no
  6. #+PROPERTY: header-args :results silent :eval no-export :comments org
  7. #+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil
  8. #+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil
  9. #+ATTR_ORG: :width 420px
  10. #+ATTR_HTML: :width 420px
  11. #+ATTR_LATEX: :width 420px
  12. [[../docs/images/what-is-emacs-teaser.png]]
  13. *Bring Emacs out of the eighties*
  14. * Completion
  15. There's a lot of occasions Emacs asks to input text to match a file name in a directory, just one example of an oppertunity for a completion system. *Swiper*[fn:1] is a family of packages that work towards this common goal in Emacs.
  16. ** Selection menu
  17. *Ivy*[fn:1] is a powerful selection menu for Emacs.
  18. #+begin_src emacs-lisp
  19. (use-package ivy
  20. :diminish
  21. :config (ivy-mode 1))
  22. #+end_src
  23. ** Replace built in commands
  24. *Counsel*[fn:1] is a customized set of commands to replace built in completion buffers.
  25. #+begin_src emacs-lisp
  26. (use-package counsel
  27. :after ivy
  28. :custom (counsel-linux-app-format-function #'counsel-linux-app-format-function-name-only)
  29. :config (counsel-mode 1))
  30. #+end_src
  31. *** Switch buffers with ,
  32. Cherry picked from =doom=.
  33. #+begin_src emacs-lisp
  34. (dotfiles/leader
  35. "," '(counsel-switch-buffer :which-key "Buffers"))
  36. #+end_src
  37. ** Additional details
  38. Provide more information about each item in the completion menu with *Ivy rich*[fn:2].
  39. #+begin_src emacs-lisp
  40. (use-package ivy-rich
  41. :after counsel
  42. :init (ivy-rich-mode 1))
  43. #+end_src
  44. * Fonts
  45. Write out to all of Emacs' available font faces with the unified font defined in the options.
  46. #+begin_src emacs-lisp
  47. (set-face-attribute 'default nil :font dotfiles/font :height dotfiles/font-size)
  48. (set-face-attribute 'fixed-pitch nil :font dotfiles/font :height dotfiles/font-size)
  49. (set-face-attribute 'variable-pitch nil :font dotfiles/font :height dotfiles/font-size)
  50. #+end_src
  51. ** Text scaling
  52. Define a transient keybinding for Scaling the text.
  53. #+begin_src emacs-lisp
  54. (defhydra hydra-text-scale (:timeout 4)
  55. "Scale"
  56. ("j" text-scale-increase "Increase")
  57. ("k" text-scale-decrease "Decrease")
  58. ("f" nil "Finished" :exit t))
  59. #+end_src
  60. + Scale the text inside of buffers with =SPC t f=
  61. * Increase =j=
  62. * Decrease =k=
  63. * Finished =f=
  64. #+begin_src emacs-lisp
  65. (dotfiles/leader
  66. "tf" '(hydra-text-scale/body :which-key "Font"))
  67. #+end_src
  68. * Icons
  69. 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.
  70. #+begin_src emacs-lisp
  71. (use-package all-the-icons
  72. :when (window-system))
  73. #+end_src
  74. Integration with the *All the Icons Dired*[fn:4]package.
  75. #+begin_src emacs-lisp
  76. (use-package all-the-icons-dired
  77. :when (window-system)
  78. :hook (dired-mode . all-the-icons-dired-mode))
  79. #+end_src
  80. * Themes
  81. #+ATTR_ORG: :width 420px
  82. #+ATTR_HTML: :width 420px
  83. #+ATTR_LATEX: :width 420px
  84. [[../docs/images/what-is-emacs-customizable.gif]]
  85. High quality and modern colour themes are provided in the *Doom Themes*[fn:5] package.
  86. #+begin_src emacs-lisp
  87. (use-package doom-themes
  88. :when (window-system)
  89. :init (load-theme 'doom-moonlight t))
  90. #+end_src
  91. Load a theme with =SPC t t=.
  92. #+begin_src emacs-lisp
  93. (dotfiles/leader
  94. "tt" '(counsel-load-theme t t :which-key "Theme"))
  95. #+end_src
  96. * Modeline
  97. *Doom modeline*[fn:6] provides an elegant and modern status bar / modeline.
  98. #+begin_src emacs-lisp
  99. (use-package doom-modeline
  100. :when (window-system)
  101. :custom (doom-modeline-height 16)
  102. :config (doom-modeline-mode 1))
  103. #+end_src
  104. * Line numbering
  105. 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.
  106. #+begin_example
  107. 5:
  108. 4:
  109. 3:
  110. 2:
  111. 1:
  112. 156: << CURRENT LINE >>
  113. 1:
  114. 2:
  115. 3:
  116. 4:
  117. 5:
  118. #+end_example
  119. #+begin_src emacs-lisp
  120. (use-package linum-relative
  121. :commands (linum-relative-global-mode)
  122. :custom (linum-relative-backend 'display-line-numbers-mode))
  123. #+end_src
  124. Toggle line numbers with =SPC t l=.
  125. #+begin_src emacs-lisp
  126. (dotfiles/leader
  127. "tl" '(linum-relative-global-mode :which-key "Lines"))
  128. #+end_src
  129. * Parenthesis
  130. Colourize nested parenthesis with *Rainbow delimeters*[fn:8].
  131. #+begin_src emacs-lisp
  132. (use-package rainbow-delimiters
  133. :hook (prog-mode . rainbow-delimiters-mode))
  134. #+end_src
  135. * Superstar
  136. Make headline stars *super* with *Org superstar mode*[fn:14].
  137. #+begin_src emacs-lisp
  138. (use-package org-superstar
  139. :when (window-system)
  140. :after org
  141. :hook (org-mode . org-superstar-mode))
  142. #+end_src
  143. * Emojis
  144. Gotta have those emojis, first class support for Emacs via the *Emacs-emojify*[fn:13] package.
  145. #+begin_src emacs-lisp
  146. (use-package emojify
  147. :when (window-system)
  148. :hook (after-init . global-emojify-mode))
  149. #+end_src
  150. + Place *Emojify*[fn:13] bindings behind =SPC f=
  151. * List with =l=
  152. * Search with =s=
  153. * Insert with =i=
  154. * Describe with =d=
  155. #+begin_src emacs-lisp
  156. (dotfiles/leader
  157. "f" '(:ignore t :which-key "Emojify")
  158. "fl" '(emojify-list-emojis :which-key "List")
  159. "fs" '(emojify-apropos-emoji :which-key "Search")
  160. "fi" '(emojify-insert-emoji :which-key "Insert")
  161. "fd" '(emojify-describe-emoji :which-key "Describe"))
  162. #+end_src
  163. * Symbols
  164. Programming buffers made prettier with *Pretty mode*[fn:9], complimentary to the built-in *Prettify symbols mode*[fn:10].
  165. #+begin_src emacs-lisp
  166. (use-package pretty-mode
  167. :hook (python-mode . turn-on-pretty-mode))
  168. #+end_src
  169. * Ligatures
  170. Enable font ligatures via *Fira Code mode*[fn:11].
  171. + Perform when *Fira Code* is the current font
  172. + Don't enable on TTY
  173. #+begin_src emacs-lisp
  174. (use-package fira-code-mode
  175. :when (and (window-system)
  176. (equal dotfiles/font "Fira Code"))
  177. :hook (prog-mode org-mode))
  178. #+end_src
  179. Toggle global ligature mode with =SPC t g=.
  180. #+begin_src emacs-lisp
  181. (dotfiles/leader
  182. "tg" '(global-fira-code-mode :which-key "Ligatures"))
  183. #+end_src
  184. * Dashboard
  185. #+ATTR_ORG: :width 420px
  186. #+ATTR_HTML: :width 420px
  187. #+ATTR_LATEX: :width 420px
  188. [[../docs/images/desktop.png]]
  189. Present a *Dashboard* when first launching Emacs. Customize the buttons of the navigator.
  190. + Brain @ http://localhost:8080
  191. + Homepage @ https://chrishayward.xyz
  192. + Athabasca @ https://login.athabascau.ca/cas/login
  193. + Bookshelf @ https://online.vitalsource.com
  194. #+begin_src emacs-lisp
  195. (use-package dashboard
  196. :when (window-system)
  197. :custom (dashboard-center-content t)
  198. (dashboard-set-init-info t)
  199. (dashboard-set-file-icons t)
  200. (dashboard-set-heading-icons t)
  201. (dashboard-set-navigator t)
  202. (dashboard-startup-banner 'logo)
  203. (dashboard-projects-backend 'projectile)
  204. (dashboard-items '((projects . 10) (recents . 10) (agenda . 10)))
  205. (dashboard-navigator-buttons `(((,(all-the-icons-fileicon "brain" :height 1.1 :v-adjust 0.0)
  206. "Brain" "Knowledge base"
  207. (lambda (&rest _) (browse-url "http://localhost:8080"))))
  208. ((,(all-the-icons-material "public" :height 1.1 :v-adjust 0.0)
  209. "Homepage" "Personal website"
  210. (lambda (&rest _) (browse-url "https://chrishayward.xyz"))))
  211. ((,(all-the-icons-faicon "university" :height 1.1 :v-adjust 0.0)
  212. "Athabasca" "Univeristy login"
  213. (lambda (&rest _) (browse-url "https://login.athabascau.ca/cas/login"))))
  214. ((,(all-the-icons-faicon "book" :height 1.1 :v-adjust 0.0)
  215. "Bookshelf" "Vitalsource bookshelf"
  216. (lambda (&rest _) (browse-url "https://online.vitalsource.com"))))))
  217. :config (dashboard-setup-startup-hook))
  218. #+end_src
  219. When running in *daemon* mode, ensure that the dashboard is the initial buffer.
  220. #+begin_src emacs-lisp
  221. (setq initial-buffer-choice
  222. (lambda ()
  223. (get-buffer "*dashboard*")))
  224. #+end_src
  225. Quickly navigate to the dashboard with =SPC SPC=.
  226. #+begin_src emacs-lisp
  227. (dotfiles/leader
  228. "SPC" '((lambda ()
  229. (interactive)
  230. (switch-to-buffer "*dashboard*"))
  231. :which-key "Dashboard"))
  232. #+end_src
  233. * Resources
  234. [fn:1] https://github.com/abo-abo/swiper
  235. [fn:2] https://github.com/Yevgnen/ivy-rich
  236. [fn:3] [[https://github.com/domtronn/all-the-icons.el]]
  237. [fn:4] https://github.com/jtbm37/all-the-icons-dired
  238. [fn:5] https://github.com/hlissner/emacs-doom-themes
  239. [fn:6] https://github.com/seagle0128/doom-modeline
  240. [fn:7] https://github.com/emacsmirror/linum-relative
  241. [fn:8] https://github.com/Fanael/rainbow-delimiters
  242. [fn:9] https://emacswiki.org/emacs/pretty-mode.el
  243. [fn:10] https://emacswiki.org/emacs/PrettySymbol
  244. [fn:11] https://github.com/jming422/fira-code-mode
  245. [fn:12] https://github.com/emacs-dashboard/emacs-dashboard
  246. [fn:13] https://github.com/iqbalansari/emacs-emojify
  247. [fn:14] https://github.com/integral-dw/org-superstar-mode