(Emacs)~small edits to explanations and some basic edits to code

This commit is contained in:
2021-03-12 03:21:22 +00:00
parent f88f5bb640
commit 79b86425f2

View File

@@ -208,18 +208,16 @@ Basic, tail recursive algorithm for calculating powers
#+begin_src emacs-lisp #+begin_src emacs-lisp
(defun pow (a n &optional initial) (defun pow (a n &optional initial)
"Raise a to the nth power. Use init to set the initial value." "Raise a to the nth power. Use init to set the initial value."
(let ((init (if initial (let ((init (or initial 1)))
initial
1)))
(if (= n 0) (if (= n 0)
init init
(pow a (- n 1) (* a init))))) (pow a (- n 1) (* a init)))))
#+end_src #+end_src
** Define procedure ** Define procedure
=lambda= provides a function with possible arguments. A procedure is The =lambda= macro provides a function with possible arguments. A
something I define as essentially a function without arguments. This procedure is a type of form that takes no arguments. This macro
macro returns an anonymous function with no arguments with all the returns an anonymous function with no arguments with all the forms
forms provided. It returns it in 'backquoted' form as that is the most provided. It returns it in 'backquoted' form as that is the most
common use of this macro. common use of this macro.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(defmacro proc (&rest CDR) (defmacro proc (&rest CDR)
@@ -230,7 +228,7 @@ common use of this macro.
** General ** General
Setup general, a good package for defining keys. In this case, I Setup general, a good package for defining keys. In this case, I
generate a new definer for the "LEADER" keys. Leader is bound to SPC generate a new definer for the "LEADER" keys. Leader is bound to SPC
and it's functionally equivalent the doom/spacemacs leader. and it's functionally equivalent to the doom/spacemacs leader.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package general (use-package general
:demand t :demand t
@@ -314,17 +312,17 @@ moment), bind to general some basic binds.
#+end_src #+end_src
** Evil ** Evil
*** Evil Preamble *** Evil Preamble
Evil (Emacs VI Layer) is a package that provides the Vi experience to Evil (Emacs VI Layer) is a package that brings the Vi experience to
Emacs. Packaged with it alone are: Emacs. Packaged with it by default are:
- Modal system - The modal system
- EX - EX
- Vi mapping functions - Vi mapping functions
This provides a lot of stuff for the vim user moving to This provides a lot of stuff for the average vim user moving to Emacs.
Emacs. However there are many other packages surrounding evil that However there are many other packages surrounding evil that port even
provide even greater functionality from vi to Emacs. Surround, greater functionality from vi to Emacs. Surround, commenting,
commenting, multiple cursors and further support to other packages are multiple cursors and further support to other packages are configured
configured here. here.
*** Evil Core *** Evil Core
Setup the evil package, with some basic keybinds. Setup the evil package, with some basic keybinds.
#+begin_src emacs-lisp #+begin_src emacs-lisp
@@ -338,7 +336,7 @@ Setup the evil package, with some basic keybinds.
"zC" #'hs-hide-level) "zC" #'hs-hide-level)
(general-def (general-def
:states 'visual :states 'visual
:keymaps 'emacs-lisp-mode-map :keymaps '(emacs-lisp-mode-map lisp-interaction-mode-map)
"gr" #'eval-region) "gr" #'eval-region)
(leader (leader
"w" #'evil-window-map "w" #'evil-window-map
@@ -371,9 +369,8 @@ Setup for multicursors in Evil mode. Don't let evil-mc setup it's own
keymap because it uses 'gr' as its prefix, which I don't like. keymap because it uses 'gr' as its prefix, which I don't like.
Instead, bind some useful functions to my personal =dx:evil-mc-map= Instead, bind some useful functions to my personal =dx:evil-mc-map=
which is bound to 'gz'. Furthermore, define a function which is bound to 'gz'. Define a function =dx:evil-mc-cursor-here=
=dx:evil-mc-cursor-here= which pauses cursors upon placing a cursor at which pauses cursors upon placing a cursor at the current position.
the current position.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package evil-mc (use-package evil-mc
:after evil :after evil
@@ -443,18 +440,19 @@ desirable to some, it can be advanced through the use of 'completion
frameworks'. frameworks'.
These frameworks handle the input from the user for common commands These frameworks handle the input from the user for common commands
and provide a differing interface to the one Emacs comes with. Most of and provide a differing interface to the one Emacs comes with. Most
these completion frameworks provide a text based menu that is actively of these completion frameworks provide a text based menu that is
filtered as more input is provided. Along with these frameworks come actively filtered as more input is provided (progressive input
added functionality and applications to integrate into the Emacs filtering). Along with these frameworks come added functionality and
environment further. applications to integrate into the Emacs environment further.
One may say that when using a completion framework there is no point One may say that when using a completion framework there is no point
in using any other framework as they encompasses so much of the in using any other framework as they encompasses so much of the
default functionality. However I'd argue that with a bit of management default functionality. This is wrong: I'd argue that with a bit of
and Emacs lisp it's totally possible to pick and mix your options. For management and Emacs lisp it's totally possible to pick and mix your
small number selections (like finding files) use something like Ido options. For small number selections (like finding files) use
and for something larger like searching buffers use ivy. something like Ido and for something larger like searching buffers use
ivy.
Along with frameworks, there is a configuration for the Along with frameworks, there is a configuration for the
completions-list, which is actually the original and default method of completions-list, which is actually the original and default method of
@@ -470,7 +468,7 @@ Ido is a very old completion package that still works great to this
day. Though it is limited in its scope (and may thus be called a day. Though it is limited in its scope (and may thus be called a
completion add-on rather than a full on framework), it is still a very completion add-on rather than a full on framework), it is still a very
powerful package. With the use of ido-completing-read+, it may be used powerful package. With the use of ido-completing-read+, it may be used
to as a fully fledged completion framework. similarly to a fully fledged completion framework.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package ido (use-package ido
@@ -551,6 +549,7 @@ Along with that, set the help function and variable functions to their
helpful counterparts. helpful counterparts.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package counsel (use-package counsel
:commands +org/swiper-goto
:general :general
(leader (leader
"ss" #'counsel-grep-or-swiper "ss" #'counsel-grep-or-swiper
@@ -623,10 +622,10 @@ just setup some evil binds for company.
** Pretty symbols ** Pretty symbols
Prettify symbols mode allows for users to declare 'symbols' that Prettify symbols mode allows for users to declare 'symbols' that
replace text within certain modes. For example, you may replace the replace text within certain modes. For example, you may replace the
'for' word in c-mode in trade of '∀'. Though this may seem like 'for' word in c-mode in trade of the logical symbol for [[https://en.wikipedia.org/wiki/Universal_quantification][universal
useless eye candy, it actually increases my speed of recognition quantification]]. Though this may seem like useless eye candy, it has
(recognising symbols is easier than words for many, including aided my comprehension and speed of recognition (recognising symbols
me). is easier than words for many, including me).
Now here I provide a macro +pretty/set-alist. This macro works pretty Now here I provide a macro +pretty/set-alist. This macro works pretty
simply: given a mode hook, as well as a list of pairs typed (text to simply: given a mode hook, as well as a list of pairs typed (text to
@@ -1157,7 +1156,9 @@ integrate it into my workflow just a bit better.
:config :config
;; sync mail after refresh ;; sync mail after refresh
(advice-add #'notmuch-poll-and-refresh-this-buffer :before (advice-add #'notmuch-poll-and-refresh-this-buffer :before
#'+mail/sync-mail)) #'+mail/sync-mail)
(with-eval-after-load "evil-collection"
(evil-collection-notmuch-setup)))
#+end_src #+end_src
*** Smtpmail *** Smtpmail
#+begin_src emacs-lisp #+begin_src emacs-lisp
@@ -1428,10 +1429,12 @@ don't need to write everything myself.
** IBuffer ** IBuffer
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package ibuffer (use-package ibuffer
:after evil
:general :general
(leader (leader
"bi" #'ibuffer)) "bi" #'ibuffer)
:config
(with-eval-after-load "evil-collection"
(evil-collection-ibuffer-setup)))
#+end_src #+end_src
** Proced ** Proced
Proced is the process manager for Emacs. Just setup evil-collection Proced is the process manager for Emacs. Just setup evil-collection
@@ -2019,6 +2022,7 @@ opposing style.
"{\n" "{\n"
> _ "\n" > _ "\n"
"}\n")) "}\n"))
(c-add-style (c-add-style
"user" "user"
'((c-basic-offset . 2) '((c-basic-offset . 2)