(Emacs)~fixing some documentation
Cleaner text and more dividing particularly in the previous sections.
This commit is contained in:
@@ -11,8 +11,8 @@ My configuration for (a very specific form of) Emacs
|
|||||||
#+toc: headlines
|
#+toc: headlines
|
||||||
|
|
||||||
* Basics
|
* Basics
|
||||||
Firstly, set full name and mail address for use in a variety of
|
Firstly, set full name and mail address. This is used in encryption
|
||||||
applications, including encryption.
|
and mailing.
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(setq user-full-name "Aryadev Chavali"
|
(setq user-full-name "Aryadev Chavali"
|
||||||
user-mail-address "aryadev@aryadevchavali.com")
|
user-mail-address "aryadev@aryadevchavali.com")
|
||||||
@@ -22,6 +22,7 @@ Let's set all yes or no questions to single letter responses.
|
|||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(fset 'yes-or-no-p 'y-or-n-p)
|
(fset 'yes-or-no-p 'y-or-n-p)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
Set the encoding to UTF-8-Unix by default.
|
Set the encoding to UTF-8-Unix by default.
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package emacs
|
(use-package emacs
|
||||||
@@ -41,8 +42,10 @@ Emacs.
|
|||||||
no-littering-var-directory (expand-file-name ".local/" user-emacs-directory)))
|
no-littering-var-directory (expand-file-name ".local/" user-emacs-directory)))
|
||||||
#+end_src
|
#+end_src
|
||||||
** File saves and custom file
|
** File saves and custom file
|
||||||
Setup file saving and auto-revert-mode. Along with that, setup the
|
Setup automatic saving for files (in case of system failure) and
|
||||||
custom-file to exist in the var-directory
|
auto-revert-mode (which refreshes the buffer on changes to the
|
||||||
|
underlying file). Along with that, set the custom-file (which holds
|
||||||
|
temporary customisation) in the etc folder.
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package emacs
|
(use-package emacs
|
||||||
:straight nil
|
:straight nil
|
||||||
@@ -54,19 +57,13 @@ custom-file to exist in the var-directory
|
|||||||
:config
|
:config
|
||||||
(global-auto-revert-mode 1))
|
(global-auto-revert-mode 1))
|
||||||
#+end_src
|
#+end_src
|
||||||
** Save place
|
* Custom functionality
|
||||||
#+begin_src emacs-lisp
|
|
||||||
(use-package saveplace
|
|
||||||
:straight nil
|
|
||||||
:config
|
|
||||||
(save-place-mode))
|
|
||||||
#+end_src
|
|
||||||
* Custom Functions
|
|
||||||
Functions that don't require a packages to work other than Emacs,
|
Functions that don't require a packages to work other than Emacs,
|
||||||
which means I can define them early and use them later.
|
which means I can define them early. These are used much later in the
|
||||||
|
config.
|
||||||
** Toggle buffer
|
** Toggle buffer
|
||||||
Like VSCode's toggling feature for just the terminal, but now for
|
Like VSCode's toggling feature for just the terminal but now for
|
||||||
anything I want.
|
any buffer of choice, as long as I can generate it via a command.
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(with-eval-after-load "window"
|
(with-eval-after-load "window"
|
||||||
(defmacro +oreo/create-toggle-function (func-name buf-name
|
(defmacro +oreo/create-toggle-function (func-name buf-name
|
||||||
@@ -102,8 +99,7 @@ BUF-NAME cannot be a regexp, it must be a fixed name."
|
|||||||
#+end_src
|
#+end_src
|
||||||
** Auto-run command after-save-hook
|
** Auto-run command after-save-hook
|
||||||
Define a macro, which creates hooks into the ~after-save-hook~. On
|
Define a macro, which creates hooks into the ~after-save-hook~. On
|
||||||
certain ~conditions~ (defined by user) being met, ~to-run~ is
|
certain ~conditions~ being met, ~to-run~ is evaluated.
|
||||||
evaluated as code.
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package simple
|
(use-package simple
|
||||||
:straight nil
|
:straight nil
|
||||||
@@ -117,11 +113,10 @@ TO-RUN is evaluated. "
|
|||||||
,@to-run)))))
|
,@to-run)))))
|
||||||
#+end_src
|
#+end_src
|
||||||
** Procedure
|
** Procedure
|
||||||
The ~lambda~ macro provides a function with possible arguments. A
|
A ~lambda~ which takes no arguments is a procedure. This macro
|
||||||
procedure is a type of callable that takes no arguments. This macro
|
generates procedures, with the parameters of the macro being the body
|
||||||
returns an anonymous function, which takes no arguments, with the
|
of the procedure. It returns it in quoted form, as that is the most
|
||||||
parameters of the macro being the body of the procedure. It returns
|
common use of this macro.
|
||||||
it in quoted form as that is the most common use of this macro.
|
|
||||||
|
|
||||||
(You may notice ~proc~ is used where the return value doesn't matter).
|
(You may notice ~proc~ is used where the return value doesn't matter).
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
@@ -130,12 +125,11 @@ it in quoted form as that is the most common use of this macro.
|
|||||||
lambda."
|
lambda."
|
||||||
`(quote (lambda () ,@CDR)))
|
`(quote (lambda () ,@CDR)))
|
||||||
#+end_src
|
#+end_src
|
||||||
** sys-name-cond
|
** System specificity
|
||||||
A macro that acts as a switch case on ~(system-name)~ which allows
|
A macro that acts as a switch case on ~(system-name)~ which allows the
|
||||||
user to write machine specific code. For me this is for my desktop
|
writing of system specific code. For me this is for my desktop and
|
||||||
and laptop, particularly for font sizes. Basically a cond constructor
|
laptop, particularly for font sizes. Though there may be an easier
|
||||||
specifically for testing system names. In fact there may be an easier
|
solution than this, this seems simple enough.
|
||||||
solution than this.
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(defmacro +oreo/sys-name-cond (&rest pairs)
|
(defmacro +oreo/sys-name-cond (&rest pairs)
|
||||||
"Switch case on result of function `system-name'.
|
"Switch case on result of function `system-name'.
|
||||||
@@ -163,7 +157,7 @@ depending on the machine I use:
|
|||||||
can actually use the rest of the laptop while waiting for
|
can actually use the rest of the laptop while waiting for
|
||||||
compilation
|
compilation
|
||||||
- On my desktop (=oldboy=) I'd prefer to use 4-6 threads as I can
|
- On my desktop (=oldboy=) I'd prefer to use 4-6 threads as I can
|
||||||
afford more to get a much faster compilation as a result.
|
afford more, so I can get a faster load up.
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(+oreo/sys-name-cond
|
(+oreo/sys-name-cond
|
||||||
("spiderboy"
|
("spiderboy"
|
||||||
@@ -172,7 +166,8 @@ depending on the machine I use:
|
|||||||
(setq native-comp-async-jobs-number 6)))
|
(setq native-comp-async-jobs-number 6)))
|
||||||
#+end_src
|
#+end_src
|
||||||
** Clean buffer list
|
** Clean buffer list
|
||||||
Instead of cleaning my buffer list manually, just use this. Preserves
|
Instead of cleaning my buffer list manually, selectively preserving
|
||||||
|
some fixed set of buffers, this function does it for me. Preserves
|
||||||
any buffers in ~+oreo/keep-buffer~ and kills the rest.
|
any buffers in ~+oreo/keep-buffer~ and kills the rest.
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(defconst +oreo/keep-buffers
|
(defconst +oreo/keep-buffers
|
||||||
@@ -190,6 +185,8 @@ any buffers in ~+oreo/keep-buffer~ and kills the rest.
|
|||||||
(buffer-list)))
|
(buffer-list)))
|
||||||
#+end_src
|
#+end_src
|
||||||
* Aesthetics
|
* Aesthetics
|
||||||
|
General look and feel of Emacs (mostly disabling stuff I don't like).
|
||||||
|
** Custom theme
|
||||||
Load my custom "personal-primary" theme which is stored in the Emacs
|
Load my custom "personal-primary" theme which is stored in the Emacs
|
||||||
lisp folder (look at [[file:elisp/personal-primary-theme.el][this file]]).
|
lisp folder (look at [[file:elisp/personal-primary-theme.el][this file]]).
|
||||||
|
|
||||||
@@ -204,7 +201,7 @@ scheme ([[file:elisp/personal-theme.el][this file]])
|
|||||||
:config
|
:config
|
||||||
(load-theme 'personal-primary t))
|
(load-theme 'personal-primary t))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
** Font size
|
||||||
Set font size to 140 if on my desktop (oldboy) or 175 if on my laptop
|
Set font size to 140 if on my desktop (oldboy) or 175 if on my laptop
|
||||||
(spiderboy).
|
(spiderboy).
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
@@ -215,7 +212,7 @@ Set font size to 140 if on my desktop (oldboy) or 175 if on my laptop
|
|||||||
("spiderboy" (set-face-attribute 'default nil :height 175))
|
("spiderboy" (set-face-attribute 'default nil :height 175))
|
||||||
("oldboy" (set-face-attribute 'default nil :height 140))))
|
("oldboy" (set-face-attribute 'default nil :height 140))))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
** Scratch buffer
|
||||||
Turn off the startup buffer because I prefer [[Dashboard]], and write into
|
Turn off the startup buffer because I prefer [[Dashboard]], and write into
|
||||||
the scratch buffer some nice information about Emacs.
|
the scratch buffer some nice information about Emacs.
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
@@ -226,32 +223,28 @@ the scratch buffer some nice information about Emacs.
|
|||||||
initial-scratch-message (format ";; Emacs v%s\n" emacs-version)
|
initial-scratch-message (format ";; Emacs v%s\n" emacs-version)
|
||||||
ring-bell-function 'ignore))
|
ring-bell-function 'ignore))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
** Blinking cursor
|
||||||
Turn off blinking-cursor-mode as we will later be setting up hl-line,
|
Turn off blinking-cursor-mode as [[*Hl-line][hl-line]] is better.
|
||||||
which does a better job of indicating where the cursor is on screen.
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package frame
|
(use-package frame
|
||||||
:straight nil
|
:straight nil
|
||||||
:config
|
:config
|
||||||
(blink-cursor-mode 0))
|
(blink-cursor-mode 0))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
** Fringes
|
||||||
Turning off borders in my window manager was a good idea, so turn off
|
Turning off borders in my window manager was a good idea, so turn off
|
||||||
the borders for Emacs.
|
the borders for Emacs.
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package fringe
|
(use-package fringe
|
||||||
:after dashboard
|
:after dashboard
|
||||||
:straight nil
|
:straight nil
|
||||||
:init
|
|
||||||
(setq left-fringe-width 0
|
|
||||||
right-fringe-width 0)
|
|
||||||
:config
|
:config
|
||||||
(fringe-mode 0))
|
(fringe-mode 0))
|
||||||
#+end_src
|
#+end_src
|
||||||
* Core packages
|
* Core packages
|
||||||
** General
|
** General
|
||||||
A good package for defining keys. In this case, I generate a new
|
A good package for defining key bindings. In this case, I generate a
|
||||||
definer for the "LEADER" keys. Leader is bound to ~SPC~ and it's
|
new definer for the "LEADER" keys. Leader is bound to ~SPC~ and it's
|
||||||
functionally equivalent to the doom/spacemacs leader. Local leader is
|
functionally equivalent to the doom/spacemacs leader. Local leader is
|
||||||
bound to ~SPC ,~ and it's similar to doom/spacemacs leader but doesn't
|
bound to ~SPC ,~ and it's similar to doom/spacemacs leader but doesn't
|
||||||
try to fully assimilate the local-leader map, instead just picking
|
try to fully assimilate the local-leader map, instead just picking
|
||||||
@@ -1380,6 +1373,16 @@ Nice set of icons with a great user interface to manage them.
|
|||||||
(leader
|
(leader
|
||||||
"ie" #'all-the-icons-insert))
|
"ie" #'all-the-icons-insert))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
** Save place
|
||||||
|
Saves current place in a buffer permanently, so on revisiting the file
|
||||||
|
(even in a different Emacs instance) you go back to the place you were
|
||||||
|
at last.
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(use-package saveplace
|
||||||
|
:straight nil
|
||||||
|
:config
|
||||||
|
(save-place-mode))
|
||||||
|
#+end_src
|
||||||
* Applications
|
* Applications
|
||||||
** Dashboard
|
** Dashboard
|
||||||
Dashboard creates a custom dashboard for Emacs that replaces the
|
Dashboard creates a custom dashboard for Emacs that replaces the
|
||||||
@@ -1784,7 +1787,7 @@ changes that haven't been committed).
|
|||||||
Also add ~eshell/goto~, which is actually a command accessible from
|
Also add ~eshell/goto~, which is actually a command accessible from
|
||||||
within eshell (this is because ~eshell/*~ creates an accessible
|
within eshell (this is because ~eshell/*~ creates an accessible
|
||||||
function within eshell with name ~*~). ~eshell/goto~ makes it easier
|
function within eshell with name ~*~). ~eshell/goto~ makes it easier
|
||||||
to change directories by using Emacs to provide an interface (which is
|
to change directories by using Emacs' find-file interface (which is
|
||||||
much faster than ~cd ..; ls -l~).
|
much faster than ~cd ..; ls -l~).
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package eshell
|
(use-package eshell
|
||||||
@@ -2003,8 +2006,8 @@ further filtering of the process list.
|
|||||||
** Calculator
|
** Calculator
|
||||||
Surprise, surprise Emacs comes with a calculator.
|
Surprise, surprise Emacs comes with a calculator.
|
||||||
|
|
||||||
Greater surprise, this thing is over powered beyond just simple
|
Greater surprise, this thing is over powered. It can perform the
|
||||||
calculation:
|
following (and more):
|
||||||
- Matrix calculations
|
- Matrix calculations
|
||||||
- Generalised calculus operations
|
- Generalised calculus operations
|
||||||
- Equation solvers for n-degree multi-variable polynomials
|
- Equation solvers for n-degree multi-variable polynomials
|
||||||
@@ -2015,6 +2018,10 @@ diverse array of mathematical operations. It uses reverse polish
|
|||||||
notation to do calculations (though there is a standard infix
|
notation to do calculations (though there is a standard infix
|
||||||
algebraic notation mode).
|
algebraic notation mode).
|
||||||
|
|
||||||
|
Embedded mode allows computation with the current buffer as the echo
|
||||||
|
area. This basically means I can compute stuff within a buffer
|
||||||
|
without invoking calc directly: $1 + 2\rightarrow_{\text{calc-embed}} 3$.
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package calc
|
(use-package calc
|
||||||
:straight nil
|
:straight nil
|
||||||
@@ -2115,10 +2122,11 @@ flyspell-mode should be hooked to text-mode.
|
|||||||
(kbd "M-c") #'flyspell-auto-correct-word))
|
(kbd "M-c") #'flyspell-auto-correct-word))
|
||||||
#+end_src
|
#+end_src
|
||||||
*** Undo tree
|
*** Undo tree
|
||||||
Undo tree is a system for handling the history of any buffer. It
|
Undo tree sits on top of the incredible Emacs undo capabilities.
|
||||||
provides a very nice 'tree' visualiser (hence the name) for revisions
|
Provides a nice visual for edits and a great way to produce branches
|
||||||
of a file or buffer, and allows you to move around different versions
|
of edits. Also allows saving of undo trees, which makes Emacs a quasi
|
||||||
at once, without using a VCS like git (all in Emacs).
|
version control system in and of itself! The only extra necessary
|
||||||
|
would be describing changes...
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package undo-tree
|
(use-package undo-tree
|
||||||
:straight t
|
:straight t
|
||||||
@@ -2155,6 +2163,11 @@ Auto fill mode is nice for most text modes, 80 char limit is great.
|
|||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(add-hook 'text-mode-hook #'auto-fill-mode)
|
(add-hook 'text-mode-hook #'auto-fill-mode)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
*** Show-paren-mode
|
||||||
|
Show parenthesis for Emacs
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(add-hook 'prog-mode-hook #'show-paren-mode)
|
||||||
|
#+end_src
|
||||||
*** Smartparens
|
*** Smartparens
|
||||||
Smartparens is a smarter electric-parens, it's much more aware of
|
Smartparens is a smarter electric-parens, it's much more aware of
|
||||||
context and easier to use.
|
context and easier to use.
|
||||||
@@ -2177,11 +2190,6 @@ context and easier to use.
|
|||||||
(sp-local-pair sp-lisp-modes "(" ")" :unless '(:rem sp-point-before-same-p))
|
(sp-local-pair sp-lisp-modes "(" ")" :unless '(:rem sp-point-before-same-p))
|
||||||
(require 'smartparens-config))
|
(require 'smartparens-config))
|
||||||
#+end_src
|
#+end_src
|
||||||
*** Show-paren-mode
|
|
||||||
Show parenthesis for Emacs
|
|
||||||
#+begin_src emacs-lisp
|
|
||||||
(add-hook 'prog-mode-hook #'show-paren-mode)
|
|
||||||
#+end_src
|
|
||||||
** Programming Configuration
|
** Programming Configuration
|
||||||
*** Eldoc
|
*** Eldoc
|
||||||
Eldoc presents documentation to the user upon placing ones cursor upon
|
Eldoc presents documentation to the user upon placing ones cursor upon
|
||||||
@@ -2189,6 +2197,8 @@ any symbol. This is very useful when programming as it:
|
|||||||
- presents the arguments of functions while writing calls for them
|
- presents the arguments of functions while writing calls for them
|
||||||
- presents typing and documentation of variables
|
- presents typing and documentation of variables
|
||||||
|
|
||||||
|
Eldoc box makes the help buffer a hovering box instead of printing it
|
||||||
|
in the minibuffer. A lot cleaner.
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package eldoc
|
(use-package eldoc
|
||||||
:straight nil
|
:straight nil
|
||||||
@@ -2279,7 +2289,7 @@ highlighting.
|
|||||||
("FIXME" . "#d02090")))
|
("FIXME" . "#d02090")))
|
||||||
)
|
)
|
||||||
#+end_src
|
#+end_src
|
||||||
** Hide-show mode
|
*** Hide-show mode
|
||||||
Turn on ~hs-minor-mode~ for all prog-mode.
|
Turn on ~hs-minor-mode~ for all prog-mode.
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package hideshow
|
(use-package hideshow
|
||||||
@@ -2299,7 +2309,7 @@ describe it won't do it justice.
|
|||||||
(prog-mode-hook . aggressive-indent-mode))
|
(prog-mode-hook . aggressive-indent-mode))
|
||||||
#+end_src
|
#+end_src
|
||||||
** PDF
|
** PDF
|
||||||
PDFs are a format for (somewhat) immutable text and reports with great
|
I use PDFs mostly for reading reports or papers, providing great
|
||||||
formatting options. Though Emacs isn't my favourite application for
|
formatting options. Though Emacs isn't my favourite application for
|
||||||
viewing PDFs (I highly recommend [[https://pwmt.org/projects/zathura/][Zathura]]), similar to most things with
|
viewing PDFs (I highly recommend [[https://pwmt.org/projects/zathura/][Zathura]]), similar to most things with
|
||||||
Emacs, having a PDF viewer builtin can be a very useful asset.
|
Emacs, having a PDF viewer builtin can be a very useful asset.
|
||||||
@@ -2338,6 +2348,8 @@ to standard grep (but for PDFs!).
|
|||||||
"M-g" #'pdfgrep))
|
"M-g" #'pdfgrep))
|
||||||
#+end_src
|
#+end_src
|
||||||
** SQL
|
** SQL
|
||||||
|
SQL package, with support for connecting to common database types
|
||||||
|
(sqlite, mysql, etc) for auto completion and query execution.
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package sql
|
(use-package sql
|
||||||
:straight nil
|
:straight nil
|
||||||
|
|||||||
Reference in New Issue
Block a user