(Emacs)~clean up headings, descriptions and bits of code

This commit is contained in:
2022-08-21 17:43:52 +01:00
parent 9f0fb20343
commit 42e2bf3890

View File

@@ -1,6 +1,6 @@
#+title: Emacs configuration #+title: Emacs configuration
#+author: Aryadev Chavali #+author: Aryadev Chavali
#+description: My new Emacs configuration #+description: My Emacs configuration
#+property: header-args:emacs-lisp :tangle config.el :comments link :results none #+property: header-args:emacs-lisp :tangle config.el :comments link :results none
#+options: toc:nil #+options: toc:nil
@@ -10,7 +10,7 @@ My configuration for vanilla Emacs
#+latex: \clearpage #+latex: \clearpage
#+toc: headlines #+toc: headlines
* Initial * Basics
Let's setup some basic functionality. Let's setup some basic functionality.
Firstly, set full name and mail address for use in a variety of Firstly, set full name and mail address for use in a variety of
@@ -44,8 +44,8 @@ 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
Now let's setup file saving and auto-revert-mode. Along with that, Setup file saving and auto-revert-mode. Along with that, setup the
setup the custom-file to exist in the var-directory custom-file to exist in the var-directory
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package emacs (use-package emacs
:straight nil :straight nil
@@ -170,9 +170,8 @@ Set font size to 140 if on my desktop (oldboy) or 175 if on my laptop
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
(use-package startup (use-package emacs
:straight nil :straight nil
:defer t
:init :init
(setq inhibit-startup-screen t (setq inhibit-startup-screen t
initial-scratch-message (format ";; Emacs v%s\n" emacs-version) initial-scratch-message (format ";; Emacs v%s\n" emacs-version)
@@ -210,7 +209,6 @@ leader but doesn't try to fully assimilate the local-leader map
instead just picking stuff I think is useful. instead just picking stuff I think is useful.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package general (use-package general
:defer nil
:demand t :demand t
:config :config
(general-def (general-def
@@ -245,8 +243,6 @@ Add bindings for ~+literate/~ namespace, allows for quick reloads.
"d" #'delete-frame)) "d" #'delete-frame))
#+end_src #+end_src
*** Some default binds in Emacs *** Some default binds in Emacs
With a ton of use-package declarations (to defer until the last
moment), bind to general some basic binds.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package emacs (use-package emacs
:straight nil :straight nil
@@ -623,22 +619,25 @@ setups for company as it only makes it slower to use. In this case,
just setup some evil binds for company. just setup some evil binds for company.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package company (use-package company
:straight t
:hook :hook
(prog-mode-hook . company-mode) (prog-mode-hook . company-mode)
(eshell-mode-hook . company-mode) (eshell-mode-hook . company-mode)
:general :general
(imap (kbd "C-SPC") #'company-complete) (imap
(:states '(normal insert) "C-SPC" #'company-complete)
(general-def
:states '(normal insert)
"M-j" #'company-select-next "M-j" #'company-select-next
"M-k" #'company-select-previous)) "M-k" #'company-select-previous))
#+end_src #+end_src
** 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 the logical symbol for [[https://en.wikipedia.org/wiki/Universal_quantification][universal 'for' word in c-mode for [[https://en.wikipedia.org/wiki/Universal_quantification][universal quantification]]. Though this may
quantification]]. Though this may seem like useless eye candy, it has seem like useless eye candy, it has aided my comprehension and speed
aided my comprehension and speed of recognition (recognising symbols of recognition (recognising symbols is easier than words for many,
is easier than words for many, including me). 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
@@ -646,8 +645,9 @@ substitute, symbol to replace with). Then I add a hook to the given
mode, setting the prettify-symbols-alist to the symbols given. mode, setting the prettify-symbols-alist to the symbols given.
I've declared it pretty high up into my config so that the rest of my I've declared it pretty high up into my config so that the rest of my
packages can leverage it. packages can leverage it. Furthermore I've added a use-package
keyword which makes declaring this for language modes incredibly
easy. Checkout my [[C/C++][C/C++]] configuration for an example.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package prog-mode (use-package prog-mode
:straight nil :straight nil
@@ -711,13 +711,12 @@ later.
** Window management ** Window management
Window management is really important. I find the default window Window management is really important. I find the default window
handling of Emacs incredibly annoying: sometimes consuming my windows, handling of Emacs incredibly annoying: sometimes consuming my windows,
sometimes creating new ones. Of course, as Emacs is a powerful lisp sometimes creating new ones. Of course, anything and everything is
interpreter, this is easily manageable. adaptable in Emacs, this behavior is no different.
Here I create a few use-package extensions that manages the whole Here I create a use-package extension that manages the whole ordeal of
ordeal of adding a new record to the display-buffer-alist, a useful adding a new record to the display-buffer-alist, a useful abstraction
abstraction that makes it easy to manage the various buffers created that makes it easy to manage the various buffers created by packages.
by packages.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package window (use-package window
:straight nil :straight nil
@@ -1265,8 +1264,8 @@ most repositories nowadays.
*** rg *** rg
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package rg (use-package rg
:defer t :after grep
:commands (+rg/search-in-new-frame) :commands (rg +rg/search-in-new-frame)
:general :general
(leader (leader
"sr" #'rg "sr" #'rg
@@ -1326,6 +1325,7 @@ initial startup screen in default Emacs.
** EWW ** EWW
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package eww (use-package eww
:defer t
:straight nil :straight nil
:config :config
(with-eval-after-load "evil-collection" (with-eval-after-load "evil-collection"
@@ -1375,6 +1375,7 @@ integrate it into my workflow just a bit better.
*** Notmuch *** Notmuch
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package notmuch (use-package notmuch
:defer t
:commands (notmuch +mail/flag-thread) :commands (notmuch +mail/flag-thread)
:general :general
(leader "am" #'notmuch) (leader "am" #'notmuch)
@@ -1384,6 +1385,19 @@ integrate it into my workflow just a bit better.
:init :init
(defconst +mail/signature "---------------\nAryadev Chavali") (defconst +mail/signature "---------------\nAryadev Chavali")
(defconst +mail/local-dir (concat user-emacs-directory ".mail/")) (defconst +mail/local-dir (concat user-emacs-directory ".mail/"))
(setq notmuch-show-logo nil
notmuch-search-oldest-first nil
notmuch-hello-sections '(notmuch-hello-insert-saved-searches
notmuch-hello-insert-alltags
notmuch-hello-insert-recent-searches)
notmuch-archive-tags '("-inbox" "-unread" "+archive")
mail-signature +mail/signature
mail-default-directory +mail/local-dir
mail-source-directory +mail/local-dir
message-signature +mail/signature
message-auto-save-directory +mail/local-dir
message-directory +mail/local-dir)
(defun +mail/sync-mail () (defun +mail/sync-mail ()
"Sync mail via mbsync." "Sync mail via mbsync."
(interactive) (interactive)
@@ -1399,19 +1413,6 @@ integrate it into my workflow just a bit better.
(notmuch-tag-change-list '("-inbox" "+flagged") unflag) beg end) (notmuch-tag-change-list '("-inbox" "+flagged") unflag) beg end)
(when (eq beg end) (when (eq beg end)
(notmuch-search-next-thread))) (notmuch-search-next-thread)))
:custom
(notmuch-show-logo nil)
(notmuch-search-oldest-first nil)
(notmuch-hello-sections '(notmuch-hello-insert-saved-searches notmuch-hello-insert-alltags notmuch-hello-insert-recent-searches))
(notmuch-archive-tags '("-inbox" "-unread" "+archive"))
(mail-signature +mail/signature)
(mail-default-directory +mail/local-dir)
(mail-source-directory +mail/local-dir)
(message-signature +mail/signature)
(message-auto-save-directory +mail/local-dir)
(message-directory +mail/local-dir)
:config
;; 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)
(advice-add #'notmuch-poll-and-refresh-this-buffer :after (advice-add #'notmuch-poll-and-refresh-this-buffer :after
@@ -1440,7 +1441,9 @@ for dired (even though dired doesn't really conflict with evil, there
are some corners I'd like to adjust). are some corners I'd like to adjust).
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package dired (use-package dired
:defer t
:straight nil :straight nil
:commands (dired find-dired dired-jump)
:hook :hook
(dired-mode-hook . dired-hide-details-mode) (dired-mode-hook . dired-hide-details-mode)
(dired-mode-hook . auto-revert-mode) (dired-mode-hook . auto-revert-mode)
@@ -1816,7 +1819,7 @@ calculation:
- Equation solvers for n-degree multi-variable polynomials - Equation solvers for n-degree multi-variable polynomials
- Embedded mode! - Embedded mode!
=calc-mode= is a calculator system within Emacs that provides a ~calc-mode~ is a calculator system within Emacs that provides a
diverse array of mathematical operations. It uses reverse polish 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).
@@ -1830,7 +1833,8 @@ algebraic notation mode).
(window-height . 0.18)) (window-height . 0.18))
:general :general
(leader (leader
"ac" #'calc) "ac" #'calc-dispatch
"tc" #'calc-embedded)
:init :init
(setq calc-algebraic-mode t) (setq calc-algebraic-mode t)
:config :config
@@ -2099,6 +2103,7 @@ There is no proper PDF viewing without this package.
=evil-collection= provides a setup for this mode, so use that. =evil-collection= provides a setup for this mode, so use that.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package pdf-tools (use-package pdf-tools
:straight t
:mode ("\\.[pP][dD][fF]" . pdf-view-mode) :mode ("\\.[pP][dD][fF]" . pdf-view-mode)
:display :display
("^.*pdf$" ("^.*pdf$"
@@ -2246,7 +2251,7 @@ Some bindings for org mode.
"fw" #'org-capture) "fw" #'org-capture)
(nmmap (nmmap
:keymaps 'org-mode-map :keymaps 'org-mode-map
[remap counsel-imenu] #'+org/swiper-goto) [remap imenu] #'+org/swiper-goto)
(local-leader (local-leader
:keymaps 'org-mode-map :keymaps 'org-mode-map
"t" #'org-todo "t" #'org-todo
@@ -2352,7 +2357,7 @@ a very tidy way to manage your time.
:after (org evil) :after (org evil)
:straight nil :straight nil
:init :init
(setq org-agenda-files (list (expand-file-name "~/Text")) (setq org-agenda-files (list (expand-file-name "~/Text") (expand-file-name "~/Text/Notes"))
org-agenda-window-setup 'current-window org-agenda-window-setup 'current-window
org-agenda-skip-deadline-prewarning-if-scheduled t) org-agenda-skip-deadline-prewarning-if-scheduled t)
:config :config
@@ -2402,9 +2407,8 @@ time a clock out occurs.")
#+end_src #+end_src
** C/C++ ** C/C++
Setup for C and C++ modes via the cc-mode package. C and C++ are Setup for C and C++ modes via the cc-mode package. C and C++ are
great languages for general purpose programming. Furthermore, they great languages for general purpose programming. My preferred choice
provide speed and finer control in trade of aesthetics and when I want greater control over memory management.
security-based abstractions.
*** Configuration *** Configuration
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package cc-mode (use-package cc-mode