(*)~changes

This commit is contained in:
2023-04-25 13:00:25 +01:00
parent 0d3c0b9d9c
commit 5dfa0b0c2a
9 changed files with 513 additions and 712 deletions

View File

@@ -184,9 +184,12 @@ any buffers in ~+oreo/keep-buffer~ and kills the rest.
#+end_src
* 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
lisp folder (look at [[file:elisp/personal-primary-theme.el][this file]]).
** Themes
*** Dark theme
My preferred dark theme is my own "personal-primary" theme which is
stored in the Emacs lisp folder (look at [[file:elisp/personal-primary-theme.el][this file]]). It tries to use
the primary colours for everything, leading to a colour -> meaning
relation.
I have an older version of this theme that uses a homogeneous colour
scheme ([[file:elisp/personal-theme.el][this file]])
@@ -199,6 +202,35 @@ scheme ([[file:elisp/personal-theme.el][this file]])
:config
(load-theme 'personal-primary t))
#+end_src
*** Light theme
I'm not very good at designing light themes as I don't really use
them. However they are necessary in high light situations where a
dark mode would strain the eyes too much. So I built a custom theme
on top of the default Emacs theme, "personal-light" (look at [[file:elisp/personal-light-theme.el][this
file]]).
I don't use it by default but I may need to switch between light and
dark easily, so here's a command to switch between them.
#+begin_src emacs-lisp
(use-package custom
:defer t
:straight nil
:commands +oreo/switch-theme
:init
(defvar +oreo/theme 'dark)
:config
(defun +oreo/switch-theme ()
(interactive)
(cond
((eq +oreo/theme 'dark)
(load-theme 'personal-light t)
(setq +oreo/theme 'light))
((eq +oreo/theme 'light)
(load-theme 'personal-primary t)
(setq +oreo/theme 'dark)))))
#+end_src
** Font size
Set font size to 140 if on my desktop (oldboy) or 175 if on my laptop
(spiderboy).
@@ -393,8 +425,8 @@ code.
;; General which key definitions for leaders
(general-def
:states '(normal motion)
"SPC" nil
"SPC ," '(nil :which-key "Local leader")
"SPC" 'nil
"\\" '(nil :which-key "Local leader")
"SPC c" '(nil :which-key "Code")
"SPC f" '(nil :which-key "File")
"SPC t" '(nil :which-key "Shell")
@@ -413,7 +445,7 @@ code.
(general-create-definer local-leader
:states '(normal motion)
:prefix "SPC ,")
:prefix "\\")
(general-create-definer code-leader
:states '(normal motion)
@@ -475,47 +507,46 @@ code.
*** Some binds in Emacs
Some bindings that I couldn't fit elsewhere easily.
#+begin_src emacs-lisp
(use-package emacs
:straight nil
:general
(general-def
"C-x d" #'delete-frame)
(use-package emacs
:straight nil
:general
(general-def
"C-x d" #'delete-frame)
(nmmap
"C--" #'text-scale-decrease
"C-=" #'text-scale-increase)
(nmmap
"C--" #'text-scale-decrease
"C-=" #'text-scale-increase)
(leader
"SPC" '(execute-extended-command :which-key "M-x")
"'" '(browse-url-emacs :which-key "Open url in Emacs")
"u" 'universal-argument
";" 'eval-expression
":" `(,(proc (interactive) (switch-to-buffer "*scratch*"))
:which-key "Switch to *scratch*")
"!" '(async-shell-command :which-key "Async shell command")
"h" '(help-command :which-key "Help"))
(leader
"SPC" '(execute-extended-command :which-key "M-x")
"'" '(browse-url-emacs :which-key "Open url in Emacs")
"u" 'universal-argument
";" 'eval-expression
":" `(,(proc (interactive) (switch-to-buffer "*scratch*"))
:which-key "Switch to *scratch*")
"!" '(async-shell-command :which-key "Async shell command")
"h" '(help-command :which-key "Help"))
(code-leader
"j" #'next-error
"k" #'previous-error
"c" #'compile
"C" #'recompile
"F" (list (proc (interactive) (find-file "~/Code/")) ':which-key "Open ~/Code/"))
(mode-leader
"t" #'+oreo/switch-theme)
(file-leader
"f" #'find-file
"F" #'find-file-other-frame
"s" #'save-buffer
"p" (list (proc (interactive) (find-file (concat user-emacs-directory "config.org")))
':which-key "Open config.org"))
(code-leader
"F" (list (proc (interactive) (find-file "~/Code/")) ':which-key "Open ~/Code/"))
(quit-leader
"q" #'save-buffers-kill-terminal
"c" #'+literate/compile-config
"l" #'+literate/load-config
"d" #'delete-frame)
(file-leader
"f" #'find-file
"F" #'find-file-other-frame
"s" #'save-buffer
"p" (list (proc (interactive) (find-file (concat user-emacs-directory "config.org")))
':which-key "Open config.org"))
(search-leader "i" #'imenu))
(quit-leader
"q" #'save-buffers-kill-terminal
"c" #'+literate/compile-config
"l" #'+literate/load-config
"d" #'delete-frame)
(search-leader "i" #'imenu))
#+end_src
** Evil
My editor journey started off with Vim rather than Emacs, so my brain
@@ -698,7 +729,7 @@ Setup for counsel. Load after ivy and helpful.
[remap describe-bindings] #'counsel-descbinds
[remap load-theme] #'counsel-load-theme)
:config
(setq ivy-initial-inputs-alist nil
(setq ivy-initial-inputs-alist '((org-insert-link . "^"))
counsel-describe-function-function #'helpful-callable
counsel-describe-variable-function #'helpful-variable
counsel-grep-swiper-limit 1500000
@@ -1000,36 +1031,27 @@ with abstracting a few things away.
(prog-mode-hook . abbrev-mode)
(text-mode-hook . abbrev-mode)
:init
(defmacro +autotyping/deff-abbrev (ABBREV-TABLE ABBREV EXPANSION)
"Wraps around define-abbrev to fill in some repeated stuff
when expansion is a function."
`(define-abbrev
,ABBREV-TABLE
,ABBREV
""
(proc (insert ,EXPANSION))))
(defmacro +abbrev/define-abbrevs (abbrev-table &rest abbrevs)
`(progn
,@(mapcar #'(lambda (abbrev)
`(define-abbrev
,abbrev-table
,(car abbrev)
""
(proc (insert ,(cadr abbrev)))))
abbrevs)))
(setq save-abbrevs nil)
:config
(+autotyping/deff-abbrev
(+abbrev/define-abbrevs
global-abbrev-table
"sdate"
(format-time-string "%Y-%m-%d" (current-time)))
(+autotyping/deff-abbrev
global-abbrev-table
"stime"
(format-time-string "%H:%M:%S" (current-time)))
(+autotyping/deff-abbrev
text-mode-abbrev-table
"sday"
(format-time-string "%A" (current-time)))
(+autotyping/deff-abbrev
text-mode-abbrev-table
"smon"
(format-time-string "%B" (current-time))))
("sdate"
(format-time-string "%Y-%m-%d" (current-time)))
("stime"
(format-time-string "%H:%M:%S" (current-time)))
("sday"
(format-time-string "%A" (current-time)))
("smon"
(format-time-string "%B" (current-time)))))
#+end_src
*** Skeletons
Defining some basic skeletons and a macro to help generate an abbrev
@@ -1225,8 +1247,9 @@ setups for programming without heavier packages like [[*Eglot][Eglot]].
Highlights the current line, much better than a blinking cursor.
#+begin_src emacs-lisp
(use-package hl-line
:defer t
:hook (text-mode-hook . hl-line-mode))
:straight t
:hook (text-mode-hook . hl-line-mode)
:hook (prog-mode-hook . hl-line-mode))
#+end_src
** Recentf
Recentf provides a method of keeping track of recently opened files.
@@ -2009,9 +2032,6 @@ don't need to write everything myself.
(display-buffer-same-window))
:general
(leader "g" '(magit-status :which-key "Magit"))
(nmmap
:keymaps 'magit-status-mode-map
"TAB" #'magit-section-toggle)
:init
(setq vc-follow-symlinks t)
(with-eval-after-load "autoinsert"
@@ -2197,7 +2217,12 @@ flyspell-mode should be hooked to text-mode.
(nmmap
:keymaps 'text-mode-map
(kbd "M-C") #'flyspell-correct-word-before-point
(kbd "M-c") #'flyspell-auto-correct-word))
(kbd "M-c") #'flyspell-auto-correct-word)
(local-leader
:keymaps 'flyspell-mode-map
"S" #'flyspell-region)
(mode-leader
"s" #'flyspell-mode))
#+end_src
*** Undo tree
Undo tree sits on top of the incredible Emacs undo capabilities.
@@ -2274,6 +2299,19 @@ context and easier to use.
(sp-local-pair sp-lisp-modes "(" ")" :unless '(:rem sp-point-before-same-p))
(require 'smartparens-config))
#+end_src
*** Thesaurus
=le-thesaurus= is a great extension for quickly searching up words for
synonyms or antonyms. I may need it anywhere so I bind it to all
keymaps.
#+begin_src emacs-lisp
(use-package le-thesaurus
:straight t
:general
(local-leader
:keymaps 'override
"[" #'le-thesaurus-get-synonyms
"]" #'le-thesaurus-get-antonyms))
#+end_src
* Programming modes
Packages that help with programming in general, providing IDE like
capabilities.
@@ -2375,7 +2413,8 @@ I hook it to prog-mode.
:init
(setq hl-todo-keyword-faces
'(("TODO" . "#E50000")
("WAIT" . "#00CC00")
("WIP" . "#ffa500")
("NOTE" . "#00CC00")
("FIXME" . "#d02090"))))
#+end_src
** Hide-show mode
@@ -2398,6 +2437,385 @@ I give won't do it justice.
:hook
(prog-mode-hook . aggressive-indent-mode))
#+end_src
* Org mode
2023-03-30: finally decided to give org mode its own section.
Org is, at its most basic, a markup language. Files use the ".org"
extension and use =org-mode= to write text, with the ability to export
to a few formats, all within Emacs. However, this is a massive
disservice to its incredible capabilities:
+ Complete spreadsheet system, with formulas (including
[[*Calculator][calc-mode]] integration)
+ Evaluation of code blocks, even using the results of them in exports
(to, say, a $\LaTeX$ or HTML document)
+ This includes exporting all code blocks of a document to a code
file, say all the emacs-lisp files in this document to ~config.el~
([[file:elisp/literate.el][literate]])
+ Complete calendar/todo system with deadlines, scheduling and
repeaters
+ Export to a variety of formats or make your own export engine using
the org AST!
+ Writing latex in document, with ability to render them on demand,
and exporting to PDFs through Latex
** Aesthetic defaults
Org has a ton of settings to tweak, which change your experience quite
a bit. My setup should be as portable as possible and (/sometimes/) I
need to access org mode files in other editors, so org files should be
as close to clear text as possible. This is the guiding philosophy
that essentially makes most of my options pretty immediate.
Some arbitrary notes:
+ By default =~/Text= is my directory for text files. I actually have
a repository that manages this directory for agenda files and other
documents
+ Indentation in file should not be allowed, i.e. text indentation,
as that forces other editors to read it a certain way as well. It
seems obtrusive hence it's off.
+ Org startup indented is on by default as most documents do benefit
from the indentation, but I do turn it off for some files via
~#+startup:noindent~
+ When opening an org document there can be a lot of headings, so I
set folding to just content
+ Org documents can also have a lot of latex previews, which make
opening some after a while a massive hassle. If I want to see the
preview, I'll do it myself, so turn it off.
+ Org manages windowing itself, to some extent, so I set those options
to be as unobtrusive as possible
#+begin_src emacs-lisp
(use-package org
:defer t
:straight t
:init
(setq
org-directory "~/Text"
org-adapt-indentation nil
org-indent-mode nil
org-startup-indented t
org-startup-folded 'content
org-startup-with-latex-preview nil
org-imenu-depth 10
org-src-window-setup 'current-window
org-indirect-buffer-display 'current-window
org-link-frame-setup '((vm . vm-visit-folder-other-frame)
(vm-imap . vm-visit-imap-folder-other-frame)
(file . find-file))))
#+end_src
** Latex options
Org mode has deep integration with latex, can export to PDF and even
display latex fragments in the document directly. I setup the
pdf-process, code listing options via minted and the format options
for latex fragments.
#+begin_src emacs-lisp
(use-package org
:defer t
:init
(setq org-format-latex-options '(:foreground default :background default :scale 2
:html-foreground "Black" :html-background "Transparent"
:html-scale 1.0 :matchers ("begin" "$1" "$" "$$" "\\(" "\\["))
org-latex-listings 'minted
org-latex-minted-langs '((emacs-lisp "common-lisp")
(ledger "text")
(cc "c++")
(cperl "perl")
(shell-script "bash")
(caml "ocaml"))
org-latex-packages-alist '(("" "minted"))
org-latex-pdf-process
'("latexmk -pdfxe -bibtex -f -shell-escape %f")
org-latex-minted-options '(("style" "colorful")
("linenos")
("frame" "single")
("mathescape")
("fontfamily" "courier")
("samepage" "false")
("breaklines" "true")
("breakanywhere" "true"))))
#+end_src
** Org Core Variables
Tons of variables for org-mode, including a ton of latex ones. Can't
really explain because it sets up quite a lot of local stuff. Also I
copy pasted the majority of this, tweaking it till it felt good. Doom
Emacs was very helpful here.
#+begin_src emacs-lisp
(use-package org
:init
(setq org-edit-src-content-indentation 0
org-goto-interface 'outline
org-imenu-depth 10
org-export-backends '(ascii html latex odt icalendar)
org-eldoc-breadcrumb-separator ""
org-enforce-todo-dependencies t
org-fontify-quote-and-verse-blocks t
org-fontify-whole-heading-line t
org-footnote-auto-label t
org-hide-leading-stars t
org-hide-emphasis-markers nil
org-image-actual-width nil
org-priority-faces '((?A . error) (?B . warning) (?C . success))
org-link-descriptive nil
org-tags-column 0
org-todo-keywords
'((sequence "TODO" "WIP" "DONE")
(sequence "PROJ" "WAIT" "COMPLETE"))
org-use-sub-superscripts '{}
org-babel-load-languages '((emacs-lisp . t)
(lisp . t)
(C . t)
(python . t)
(shell . t))))
#+end_src
** Org Core Functionality
Hooks, prettify-symbols and records for auto insertion.
#+begin_src emacs-lisp
(use-package org
:hook
(org-mode-hook . prettify-symbols-mode)
:display
("\\*Org Src.*"
(display-buffer-same-window))
:pretty
(org-mode-hook
("#+begin_src" . "")
("#+end_src" . ""))
:init
(with-eval-after-load "autoinsert"
(define-auto-insert '("\\.org\\'" . "Org skeleton")
'("Enter title: "
"#+title: " str | (buffer-file-name) "\n"
"#+author: " (read-string "Enter author: ") | user-full-name "\n"
"#+description: " (read-string "Enter description: ") | "Description" "\n"
"#+date: " (format-time-string "%Y-%m-%d" (current-time)) "\n"
"* " _))))
#+end_src
** Org Core Bindings
Some bindings for org mode.
#+begin_src emacs-lisp
(use-package org
:after counsel
:config
(defun +org/swiper-goto ()
(interactive)
(swiper "^\\* "))
:general
(file-leader
"w" #'org-capture
"l" #'org-store-link
"i" #'org-insert-last-stored-link)
(code-leader
"D" #'org-babel-detangle)
(nmmap
:keymaps 'org-mode-map
[remap imenu] #'+org/swiper-goto)
(local-leader
:keymaps 'org-mode-map
"l" '(nil :which-key "Links")
"'" '(nil :which-key "Tables")
"c" '(nil :which-key "Clocks"))
(local-leader
:keymaps 'org-mode-map
:infix "l"
"i" #'org-insert-link
"l" #'org-open-at-point)
(local-leader
:keymaps 'org-mode-map
:infix "'"
"a" #'org-table-align
"f" #'org-table-edit-formulas
"t" #'org-table-toggle-coordinate-overlays
"s" #'org-table-sum
"e" #'org-table-calc-current-TBLFM
"E" #'org-table-eval-formula)
(local-leader
:keymaps 'org-mode-map
"i" #'org-clock-clock-in
"o" #'org-clock-clock-out
"c" #'org-clock-in-last
"d" #'org-clock-display)
(local-leader
:keymaps 'org-mode-map
"d" #'org-date-from-calendar
"t" #'org-todo
"T" #'org-babel-tangle
"i" #'org-insert-structure-template
"p" #'org-latex-preview
"s" #'org-property-action
"e" #'org-export-dispatch
"o" #'org-edit-special))
#+end_src
** Agenda
Org agenda provides a nice viewing for schedules. With org mode it's
a very tidy way to manage your time.
#+begin_src emacs-lisp
(use-package org-agenda
:after org
:straight nil
:init
(defconst +org/agenda-root "~/Text"
"Root directory for all agenda files")
(setq org-agenda-files (list (expand-file-name +org/agenda-root))
org-agenda-window-setup 'current-window
org-agenda-skip-deadline-prewarning-if-scheduled t
org-agenda-skip-scheduled-if-done t
org-agenda-skip-deadline-if-done t
org-agenda-start-with-entry-text-mode nil)
:config
(evil-set-initial-state 'org-agenda-mode 'normal)
:general
(file-leader
"a" `(,(proc (interactive)
(find-file (completing-read "Enter directory: " org-agenda-files nil t)))
:which-key "Open agenda directory"))
(app-leader
"a" #'org-agenda)
(nmmap
:keymaps 'org-agenda-mode-map
"zd" #'org-agenda-day-view
"zw" #'org-agenda-week-view
"zm" #'org-agenda-month-view
"gd" #'org-agenda-goto-date
"RET" #'org-agenda-switch-to
"J" #'org-agenda-later
"K" #'org-agenda-earlier
"t" #'org-agenda-todo
"." #'org-agenda-goto-today
"," #'org-agenda-goto-date
"q" #'org-agenda-quit
"r" #'org-agenda-redo))
#+end_src
** Org clock-in
Org provides a nice timekeeping system that allows for managing how
much time is taken per task. It even has an extensive reporting
system to see how much time you spend on specific tasks or overall.
#+begin_src emacs-lisp
(use-package org-clock
:after org
:straight nil
:init
(defvar +org/clock-out-toggle-report nil
"Non-nil means update the first clock report in the file every
time a clock out occurs.")
:config
(advice-add #'org-clock-out
:after
(proc (interactive)
(if +org/clock-out-toggle-report
(org-clock-report t))))
:general
(local-leader
:keymaps 'org-mode-map
:infix "c"
"c" #'org-clock-in
"o" #'org-clock-out
"r" #'org-clock-report
"t" (proc (interactive)
(setq-local +org/clock-out-toggle-report
(not +org/clock-out-toggle-report)))))
#+end_src
** Org on save
If ~+org/compile-to-pdf-on-save-p~ is non-nil, then compile to
\(\LaTeX\) and run an async process to compile it to a PDF. Doesn't
make Emacs hang (like ~org-latex-export-to-pdf~) and doesn't randomly
crash (like the async handler for org-export). Works really well with
~pdf-view-mode~.
#+begin_src emacs-lisp
(use-package org
:defer t
:init
(defvar +org/compile-to-pdf-on-save-p
nil
"Non-nil to activate compile functionality.")
:general
(local-leader
:keymaps 'org-mode-map
"C" (proc (interactive)
(if (+org/compile-to-pdf-on-save-f)
(setq-local +org/compile-to-pdf-on-save-p nil)
(setq-local +org/compile-to-pdf-on-save-p t))))
:config
(+oreo/create-auto-save
(and (eq major-mode 'org-mode) +org/compile-to-pdf-on-save-p)
(start-process-shell-command "" "*pdflatex*" (concat "pdflatex -shell-escape "
(org-latex-export-to-latex)))))
#+end_src
** Org ref
#+begin_src emacs-lisp
(use-package org-ref
:straight t
:defer t
:init
(setq bibtex-files '("~/Text/bibliography.bib")
bibtex-completion-bibliography '("~/Text/bibliography.bib")
bibtex-completion-additional-search-fields '(keywords)))
#+end_src
*** Org ref ivy integration
Org ref requires ivy-bibtex to work properly with ivy, so we need to
set that up as well
#+begin_src emacs-lisp
(use-package ivy-bibtex
:straight t
:after org-ref
:config
(require 'org-ref-ivy))
#+end_src
** Org message
Org message allows for the use of org mode when composing mails,
generating HTML multipart emails. This integrates the WYSIWYG
experience with mail in Emacs while also providing powerful text
features with basically no learning curve (as long as you've already
learnt the basics of org).
#+begin_src emacs-lisp
(use-package org-msg
:hook (message-mode-hook . org-msg-mode)
:config
(setq org-msg-options "html-postamble:nil H:5 num:nil ^:{} toc:nil author:nil email:nil \\n:t tex:dvipng"
org-msg-greeting-name-limit 3)
(add-to-list 'org-msg-enforce-css
'(img latex-fragment-inline
((transform . ,(format "translateY(-1px) scale(%.3f)"
(/ 1.0 (if (boundp 'preview-scale)
preview-scale 1.4))))
(margin . "0 -0.35em")))))
#+end_src
** Org for evil
Evil org for some nice bindings.
#+begin_src emacs-lisp
(use-package evil-org
:hook (org-mode-hook . evil-org-mode))
#+end_src
** Org reveal
Org reveal allows one to export org files as HTML presentations via
reveal.js. Pretty nifty and it's easy to use.
#+begin_src emacs-lisp
(use-package ox-reveal
:defer t
:init
(setq org-reveal-root "https://cdn.jsdelivr.net/npm/reveal.js"
org-reveal-theme "sky"))
#+end_src
** Org fragtog
Toggle latex fragments in org mode so you get fancy maths symbols. I
use latex a bit in org mode as it is the premier way of getting
mathematical symbols rendered, but org mode > latex.
Delimited environments are aplenty, escaped brackets and dollar signs
are my favourite. Here's a snippet:
$\int_{-\infty}^{\infty}e^{-x^2}dx = \sqrt{\pi}$.
#+begin_src emacs-lisp
(use-package org-fragtog
:hook (org-mode-hook . org-fragtog-mode))
#+end_src
** Org superstar
Org superstar adds cute little Unicode symbols for headers, much
better than the default asterisks.
#+begin_src emacs-lisp
(use-package org-superstar
:hook (org-mode-hook . org-superstar-mode))
#+end_src
* Languages
Configuration for specific languages or file formats.
** PDF
@@ -2481,304 +2899,6 @@ the [[https://elpa.gnu.org/packages/nhexl-mode.html][page]] yourself.
:straight t
:mode "\\.bin")
#+end_src
** Org
Org mode
*** Org Core Variables
Tons of variables for org-mode, including a ton of latex ones. Can't
really explain because it sets up quite a lot of local stuff. Also I
copy pasted the majority of this, tweaking it till it felt good. Doom
Emacs was very helpful here.
#+begin_src emacs-lisp
(use-package org
:defer t
:custom
(org-directory "~/Text")
(org-edit-src-content-indentation 0)
(org-goto-interface 'outline)
(org-adapt-indentation nil)
(org-indent-mode nil)
(org-src-window-setup 'current-window)
(org-indirect-buffer-display 'current-window)
(org-export-backends '(ascii html latex odt icalendar))
(org-imenu-depth 10)
(org-link-frame-setup '((vm . vm-visit-folder-other-frame)
(vm-imap . vm-visit-imap-folder-other-frame)
(gnus . org-gnus-no-new-news)
(file . find-file-other-frame)
(wl . wl-other-frame)))
(org-eldoc-breadcrumb-separator "")
(org-enforce-todo-dependencies t)
(org-fontify-quote-and-verse-blocks t)
(org-fontify-whole-heading-line t)
(org-footnote-auto-label 'plain)
(org-hide-leading-stars t)
(org-hide-emphasis-markers nil)
(org-image-actual-width nil)
(org-priority-faces '((?A . error) (?B . warning) (?C . success)))
(org-startup-indented t)
(org-startup-with-latex-preview t)
(org-startup-folded 'content)
(org-tags-column 0)
(org-todo-keywords
'((sequence "TODO" "DONE")
(sequence "PROJ" "WAIT" "COMPLETE")))
(org-use-sub-superscripts '{})
(org-babel-load-languages '((emacs-lisp . t)
(lisp . t)
(C . t)
(python . t)
(shell . t)))
(org-format-latex-options '(:foreground default :background default :scale 2
:html-foreground "Black" :html-background "Transparent"
:html-scale 1.0 :matchers ("begin" "$1" "$" "$$" "\\(" "\\[")))
(org-latex-listings 'minted)
(org-latex-minted-langs '((emacs-lisp "common-lisp")
(ledger "text")
(cc "c++")
(cperl "perl")
(shell-script "bash")
(caml "ocaml")))
(org-latex-packages-alist '(("" "minted")))
(org-latex-pdf-process
'("latexmk -pdfxe -bibtex -f -shell-escape %f"))
(setq org-latex-minted-options '(("style" "colorful")
("linenos")
("frame" "single")
("mathescape")
("fontfamily" "courier")
("samepage" "false")
("breaklines" "true")
("breakanywhere" "true")
)))
#+end_src
*** Org Core Functionality
Hooks, prettify-symbols and records for auto insertion.
#+begin_src emacs-lisp
(use-package org
:hook
(org-mode-hook . prettify-symbols-mode)
:display
("\\*Org Src.*"
(display-buffer-same-window))
:pretty
(org-mode-hook
("#+begin_src" . "")
("#+end_src" . ""))
:init
(with-eval-after-load "autoinsert"
(define-auto-insert '("\\.org\\'" . "Org skeleton")
'("Enter title: "
"#+title: " str | (buffer-file-name) "\n"
"#+author: " (read-string "Enter author: ") | user-full-name "\n"
"#+description: " (read-string "Enter description: ") | "Description" "\n"
"#+date: " (format-time-string "%Y-%m-%d" (current-time)) "\n"
"* " _))))
#+end_src
*** Org Core Bindings
Some bindings for org mode.
#+begin_src emacs-lisp
(use-package org
:after counsel
:config
(defun +org/swiper-goto ()
(interactive)
(swiper "^\\* "))
:general
(file-leader
"w" #'org-capture
"l" #'org-store-link
"i" #'org-insert-last-stored-link)
(code-leader
"D" #'org-babel-detangle)
(nmmap
:keymaps 'org-mode-map
[remap imenu] #'+org/swiper-goto)
(local-leader
:keymaps 'org-mode-map
:infix "l"
"i" #'org-insert-link
"l" #'org-open-at-point)
(local-leader
:keymaps 'org-mode-map
:infix "'"
"a" #'org-table-align
"f" #'org-table-edit-formulas
"t" #'org-table-toggle-coordinate-overlays
"s" #'org-table-sum
"e" #'org-table-eval-formula)
(local-leader
:keymaps 'org-mode-map
"t" #'org-todo
"T" #'org-babel-tangle
"i" #'org-insert-structure-template
"p" #'org-latex-preview
"s" #'org-property-action
"e" #'org-export-dispatch
"o" #'org-edit-special))
#+end_src
*** Org agenda
Org agenda provides a nice viewing for schedules. With org mode it's
a very tidy way to manage your time.
#+begin_src emacs-lisp
(use-package org-agenda
:after (org evil)
:straight nil
:init
(defconst +org/agenda-root "~/Text"
"Root directory for all agenda files")
(setq org-agenda-files (list (expand-file-name +org/agenda-root) (expand-file-name "~/Projects/lpv/"))
org-agenda-window-setup 'current-window
org-agenda-skip-deadline-prewarning-if-scheduled t
org-agenda-skip-scheduled-if-done t
org-agenda-skip-deadline-if-done t
org-agenda-start-with-entry-text-mode nil)
:config
(evil-set-initial-state 'org-agenda-mode 'normal)
:general
(file-leader
"a" `(,(proc (interactive)
(find-file (completing-read "Enter directory: " org-agenda-files nil t)))
:which-key "Open agenda directory"))
(app-leader
"aa" #'org-agenda)
(nmmap
:keymaps 'org-agenda-mode-map
"zd" #'org-agenda-day-view
"zw" #'org-agenda-week-view
"zm" #'org-agenda-month-view
"gd" #'org-agenda-goto-date
"RET" #'org-agenda-switch-to
"J" #'org-agenda-later
"K" #'org-agenda-earlier
"t" #'org-agenda-todo
"." #'org-agenda-goto-today
"," #'org-agenda-goto-date
"q" #'org-agenda-quit
"r" #'org-agenda-redo))
#+end_src
*** Org clock-in
Org provides a nice timekeeping system that allows for managing how
much time is taken per task. It even has an extensive reporting
system to see how much time you spend on specific tasks or overall.
#+begin_src emacs-lisp
(use-package org-clock
:after org
:straight nil
:init
(defvar +org/clock-out-toggle-report nil
"Non-nil means update the first clock report in the file every
time a clock out occurs.")
:config
(advice-add #'org-clock-out
:after
(proc (interactive)
(if +org/clock-out-toggle-report
(org-clock-report t))))
:general
(local-leader
:keymaps 'org-mode-map
:infix "c"
"c" #'org-clock-in
"o" #'org-clock-out
"r" #'org-clock-report
"t" (proc (interactive)
(setq-local +org/clock-out-toggle-report
(not +org/clock-out-toggle-report)))))
#+end_src
*** Org on save
If ~+org/compile-to-pdf-on-save-p~ is non-nil, then compile to
\(\LaTeX\) and run an async process to compile it to a PDF. Doesn't
make Emacs hang (like ~org-latex-export-to-pdf~) and doesn't randomly
crash (like the async handler for org-export). Works really well with
~pdf-view-mode~.
#+begin_src emacs-lisp
(use-package org
:defer t
:init
(defvar +org/compile-to-pdf-on-save-p
nil
"Non-nil to activate compile functionality.")
:general
(local-leader
:keymaps 'org-mode-map
"C" (proc (interactive)
(if (+org/compile-to-pdf-on-save-f)
(setq-local +org/compile-to-pdf-on-save-p nil)
(setq-local +org/compile-to-pdf-on-save-p t))))
:config
(+oreo/create-auto-save
(and (eq major-mode 'org-mode) +org/compile-to-pdf-on-save-p)
(start-process-shell-command "" "*pdflatex*" (concat "pdflatex -shell-escape "
(org-latex-export-to-latex)))))
#+end_src
*** Org ref
#+begin_src emacs-lisp
(use-package org-ref
:straight t
:defer t
:init
(setq bibtex-files '("~/Text/bibliography.bib")
bibtex-completion-bibliography '("~/Text/bibliography.bib")
bibtex-completion-additional-search-fields '(keywords)))
#+end_src
*** Org message
Org message allows for the use of org mode when composing mails,
generating HTML multipart emails. This integrates the WYSIWYG
experience with mail in Emacs while also providing powerful text
features with basically no learning curve (as long as you've already
learnt the basics of org).
#+begin_src emacs-lisp
(use-package org-msg
:hook (message-mode-hook . org-msg-mode)
:config
(setq org-msg-options "html-postamble:nil H:5 num:nil ^:{} toc:nil author:nil email:nil \\n:t tex:dvipng"
org-msg-greeting-name-limit 3)
(add-to-list 'org-msg-enforce-css
'(img latex-fragment-inline
((transform . ,(format "translateY(-1px) scale(%.3f)"
(/ 1.0 (if (boundp 'preview-scale)
preview-scale 1.4))))
(margin . "0 -0.35em")))))
#+end_src
*** Org for evil
Evil org for some nice bindings.
#+begin_src emacs-lisp
(use-package evil-org
:hook (org-mode-hook . evil-org-mode))
#+end_src
*** Org reveal
Org reveal allows one to export org files as HTML presentations via
reveal.js. Pretty nifty and it's easy to use.
#+begin_src emacs-lisp
(use-package ox-reveal
:after org
:init
(setq org-reveal-root "https://cdn.jsdelivr.net/npm/reveal.js"
org-reveal-theme "sky"))
#+end_src
*** Org fragtog
Toggle latex fragments in org mode so you get fancy maths symbols. I
use latex a bit in org mode as it is the premier way of getting
mathematical symbols rendered, but org mode > latex.
Delimited environments are aplenty, escaped brackets and dollar signs
are my favourite. Here's a snippet:
$\int_{-\infty}^{\infty}e^{-x^2}dx = \sqrt{\pi}$.
#+begin_src emacs-lisp
(use-package org-fragtog
:hook (org-mode-hook . org-fragtog-mode))
#+end_src
*** Org superstar
Org superstar adds cute little Unicode symbols for headers, much
better than the default asterisks.
#+begin_src emacs-lisp
(use-package org-superstar
:hook (org-mode-hook . org-superstar-mode))
#+end_src
** C/C++
Setup for C and C++ modes via the cc-mode package. C and C++ are
great languages for general purpose programming. My preferred choice
@@ -2998,10 +3118,15 @@ Just setup a style and some pretty symbols.
** Haskell
Haskell is a static lazy functional programming language (what a
mouthful). It's quite a beautiful language and really learning it will
change the way you think about programming.
change the way you think about programming. However, my preferred
functional language is still unfortunately Lisp so no extra brownie
points there.
Here I configure the REPL for Haskell via the
~haskell-interactive-mode~ as well.
~haskell-interactive-mode~. I also load my custom package
[[file:elisp/haskell-multiedit.el][haskell-multiedit]] which allows a user to create temporary
~haskell-mode~ buffers that, upon completion, will run in the REPL.
Even easier than making your own buffer.
#+begin_src emacs-lisp
(use-package haskell-mode
:hook
@@ -3150,7 +3275,8 @@ development on Emacs.
"s" #'+shell/toggle-sly
"c" #'sly-compile-file
"a" #'sly-apropos
"d" #'sly-describe-symbol)
"d" #'sly-describe-symbol
"E" #'sly-eval-defun)
(local-leader
:keymaps 'lisp-mode-map
:infix "e"