;; Emacs 29? EWS leverages functionality from the latest Emacs version. (when (< emacs-major-version 29) (error "Emacs Writing Studio requires Emacs version 29 or later")) ;; Custom settings in a separate file and load the custom settings (setq custom-file (expand-file-name "custom.el" user-emacs-directory)) (when (file-exists-p custom-file) (load custom-file)) ;; Set package archives (use-package package :config (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/")) (package-initialize)) ;; Package Management (use-package use-package :custom (use-package-always-ensure t) (package-native-compile t) (warning-minimum-level :emergency)) ;; Load EWS functions (load-file (concat (file-name-as-directory user-emacs-directory) "ews.el")) ;; Check for missing external software ;; ;; - soffice (LibreOffice): View and create office documents ;; - zip: Unpack ePub documents ;; - pdftotext (poppler-utils): Convert PDF to text ;; - djvu (DjVuLibre): View DjVu files ;; - curl: Reading RSS feeds ;; - divpng: Part of LaTeX ;; - dot (GraphViz): Create note network diagrams ;; - convert (ImageMagick): Convert image files ;; - gm (GraphicsMagick): Convert image files ;; - latex (TexLive, MacTex or MikTeX): Preview LaTex and export Org to PDF ;; - hunspell: Spellcheck. Also requires a hunspell dictionary ;; - grep: Search inside files ;; - ripgrep: Faster alternative for grep ;; - gs (GhostScript): View PDF files ;; - mutool (MuPDF): View PDF files ;; - mpg321, ogg123 (vorbis-tools), mplayer, mpv, vlc: Media players (ews-missing-executables '("soffice" "zip" "pdftotext" "ddjvu" "curl" "dvipng" "dot" ("convert" "gm") "latex" "hunspell" ("grep" "ripgrep") ("gs" "mutool") ("mpg321" "ogg123" "mplayer" "mpv" "vlc"))) ;;; LOOK AND FEEL ;; Keyboard-centric user interface removing tool, menu and scroll bars (tool-bar-mode -1) (menu-bar-mode -1) (scroll-bar-mode -1) ;; Short answers only please (setq use-short-answers t) ;; Spacious padding (use-package spacious-padding :custom (line-spacing 3) :init (spacious-padding-mode 1)) ;; Modus Themes (use-package modus-themes :custom (modus-themes-italic-constructs t) (modus-themes-bold-constructs t) (modus-themes-mixed-fonts t) (modus-themes-to-toggle '(modus-operandi-tinted modus-vivendi-tinted)) :init (load-theme 'modus-operandi-tinted :no-confirm) :bind (("C-c w t t" . modus-themes-toggle) ("C-c w t s" . modus-themes-select))) (use-package mixed-pitch :hook (text-mode . mixed-pitch-mode)) ;; Window management ;; Split windows sensibly (setq split-width-threshold 120 split-height-threshold nil) ;; Keep window sizes balanced (use-package balanced-windows :config (balanced-windows-mode)) ;; MINIBUFFER COMPLETION ;; Enable vertico (use-package vertico :init (vertico-mode) :custom (vertico-sort-function 'vertico-sort-history-alpha)) ;; Persist history over Emacs restarts. (use-package savehist :init (savehist-mode)) ;; Search for partial matches in any order (use-package orderless :custom (completion-styles '(orderless basic)) (completion-category-defaults nil) (completion-category-overrides '((file (styles partial-completion))))) ;; Enable richer annotations using the Marginalia package (use-package marginalia :init (marginalia-mode)) ;; Improve keyboard shortcut discoverability (use-package which-key :config (which-key-mode) :custom (which-key-max-description-length 40)) ;; Improved help buffers (use-package helpful :bind (("C-h x" . helpful-command) ("C-h k" . helpful-key) ("C-h v" . helpful-variable))) ;;; Text mode settings (use-package text-mode :ensure nil :hook (text-mode . visual-line-mode) :init (delete-selection-mode t) :custom (sentence-end-double-space nil) (scroll-error-top-bottom t) (save-interprogram-paste-before-kill t)) ;; Check spelling with flyspell and hunspell (use-package flyspell :custom (ispell-silently-savep t) (ispell-program-name "hunspell") (flyspell-default-dictionary "en_AU") (flyspell-case-fold-duplications t) (flyspell-issue-message-flag nil) (org-fold-core-style 'overlays) ;; Fix Org mode bug :hook (text-mode . flyspell-mode) :bind (("C-c w s s" . ispell) ("C-;" . flyspell-auto-correct-previous-word))) ;;; Ricing Org mode (use-package org :custom (org-startup-indented t) (org-hide-emphasis-markers t) (org-startup-with-inline-images t) (org-image-actual-width '(450)) (org-fold-catch-invisible-edits 'error) (org-startup-with-latex-preview t) (org-pretty-entities t) (org-use-sub-superscripts "{}") (org-id-link-to-org-use-id t)) ;; Show hidden emphasis markers (use-package org-appear :hook (org-mode . org-appear-mode)) ;; LaTeX previews (use-package org-fragtog :after org :hook (org-mode . org-fragtog-mode) :custom (org-format-latex-options (plist-put org-format-latex-options :scale 2) (plist-put org-format-latex-options :foreground 'auto) (plist-put org-format-latex-options :background 'auto))) ;; Org modern: Most features disables for beginnng users (use-package org-modern :hook (org-mode . org-modern-mode) :custom (org-modern-table nil) (org-modern-keyword nil) (org-modern-timestamp nil) (org-modern-priority nil) (org-modern-checkbox nil) (org-modern-tag nil) (org-modern-block-name nil) (org-modern-keyword nil) (org-modern-footnote nil) (org-modern-internal-target nil) (org-modern-radio-target nil) (org-modern-statistics nil) (org-modern-progress nil)) ;; INSPIRATION ;; Doc-View (use-package doc-view :custom (doc-view-resolution 300) (large-file-warning-threshold (* 50 (expt 2 20)))) ;; Read ePub files (use-package nov :init (add-to-list 'auto-mode-alist '("\\.epub\\'" . nov-mode))) ;; Reading LibreOffice files ;; Fixing a bug in Org Mode pre 9.7 ;; Org mode clobbers associations with office documents (use-package ox-odt :ensure nil :config (add-to-list 'auto-mode-alist '("\\.\\(?:OD[CFIGPST]\\|od[cfigpst]\\)\\'" . doc-view-mode-maybe))) ;; Managing Bibliographies (use-package bibtex :custom (bibtex-user-optional-fields '(("keywords" "Keywords to describe the entry" "") ("file" "Relative or absolute path to attachments" "" ))) (bibtex-align-at-equal-sign t) :config (ews-bibtex-register) :bind (("C-c w b r" . ews-bibtex-register))) ;; Biblio package for adding BibTeX records (use-package biblio :bind (("C-c w b b" . ews-bibtex-biblio-lookup))) ;; Citar to access bibliographies (use-package citar :custom (citar-bibliography ews-bibtex-files) (org-cite-global-bibliography ews-bibtex-files) (org-cite-insert-processor 'citar) (org-cite-follow-processor 'citar) (org-cite-activate-processor 'citar) :bind (("C-c w b o" . citar-open))) ;; Read RSS feeds with Elfeed (use-package elfeed :custom (elfeed-db-directory (expand-file-name "elfeed" user-emacs-directory)) (elfeed-show-entry-switch 'display-buffer) :bind ("C-c w e" . elfeed)) ;; Configure Elfeed with org mode (use-package elfeed-org :config (elfeed-org) :custom (rmh-elfeed-org-files (list (concat (file-name-as-directory (getenv "HOME")) "Documents/elfeed.org")))) ;; Easy insertion of weblinks (use-package org-web-tools :bind (("C-c w w" . org-web-tools-insert-link-for-url))) ;; Emacs Multimedia System (use-package emms :init (require 'emms-setup) (require 'emms-mpris) (emms-all) (emms-default-players) (emms-mpris-enable) :custom (emms-browser-covers #'emms-browser-cache-thumbnail-async) :bind (("C-c w m b" . emms-browser) ("C-c w m e" . emms) ("C-c w m p" . emms-play-playlist ) ("" . emms-previous) ("" . emms-next) ("" . emms-pause))) (use-package openwith :config (openwith-mode t) :custom (openwith-association nil)) ;; Fleeting notes (use-package org :bind (("C-c c" . org-capture) ("C-c l" . org-store-link))) ;; Capture templates (setq org-capture-templates '(("f" "Fleeting note" item (file+headline org-default-notes-file "Notes") "- %?") ("p" "Permanent note" plain (file denote-last-path) #'denote-org-capture :no-save t :immediate-finish nil :kill-buffer t :jump-to-captured t) ("t" "New task" entry (file+headline org-default-notes-file "Tasks") "* TODO %i%?"))) ;; Denote (use-package denote :custom (denote-sort-keywords t) :hook (dired-mode . denote-dired-mode) :custom-face (denote-faces-link ((t (:slant italic)))) :bind (("C-c w d b" . denote-find-backlink) ("C-c w d d" . denote-date) ("C-c w d f" . denote-find-link) ("C-c w d h" . denote-org-extras-link-to-heading) ("C-c w d i" . denote-link-or-create) ("C-c w d I" . denote-org-extras-dblock-insert-links) ("C-c w d k" . denote-keywords-add) ("C-c w d K" . denote-keywords-remove) ("C-c w d l" . denote-link-find-file) ("C-c w d n" . denote) ("C-c w d r" . denote-rename-file) ("C-c w d R" . denote-rename-file-using-front-matter))) ;; Consult-Notes for easy access (use-package consult-notes :custom (consult-narrow-key ":") (consult-notes-file-dir-sources `(("Denote Notes" ?n ,denote-directory))) :bind (("C-c w h" . consult-org-heading) ("C-c w f" . consult-notes) ("C-c w g" . consult-notes-search-in-all-notes))) ;; Citar-Denote to manage literature notes (use-package citar-denote :demand t :custom (citar-open-always-create-notes t) :init (citar-denote-mode) :bind (("C-c w b c" . citar-create-note) ("C-c w b n" . citar-denote-open-note) ("C-c w b x" . citar-denote-nocite) :map org-mode-map ("C-c w b k" . citar-denote-add-citekey) ("C-c w b K" . citar-denote-remove-citekey) ("C-c w b d" . citar-denote-dwim) ("C-c w b e" . citar-denote-open-reference-entry))) ;; Explore and manage your Denote collection (use-package denote-explore :bind (;; Statistics ("C-c w x c" . denote-explore-count-notes) ("C-c w x C" . denote-explore-count-keywords) ("C-c w x b" . denote-explore-keywords-barchart) ("C-c w x x" . denote-explore-extensions-barchart) ;; Random walks ("C-c w x r" . denote-explore-random-note) ("C-c w x l" . denote-explore-random-link) ("C-c w x k" . denote-explore-random-keyword) ;; Denote Janitor ("C-c w x d" . denote-explore-identify-duplicate-notes) ("C-c w x z" . denote-explore-zero-keywords) ("C-c w x s" . denote-explore-single-keywords) ("C-c w x o" . denote-explore-sort-keywords) ("C-c w x r" . denote-explore-rename-keywords) ;; Visualise denote ("C-c w x n" . denote-explore-network) ("C-c w x v" . denote-explore-network-regenerate) ("C-c w x D" . denote-explore-degree-barchart))) ;; Set some Org mode shortcuts (use-package org :bind (:map org-mode-map ("C-c w n" . ews-org-insert-notes-drawer) ("C-c w p" . ews-org-insert-screenshot) ("C-c w c" . ews-org-count-words))) ;; Distraction-free writing (use-package olivetti :demand t :bind (("C-c w o" . ews-olivetti))) ;; Undo Tree (use-package undo-tree :config (global-undo-tree-mode) :custom (undo-tree-auto-save-history nil) :bind (("C-c w u" . undo-tree-visualize))) ;; Export citations with Org Mode (require 'oc-natbib) (require 'oc-csl) (setq org-cite-csl-styles-dir ews-bibtex-directory org-cite-export-processors '((latex natbib "apalike2" "authoryear") (t csl "apa6.csl"))) ;; Lookup words in online dictionary (use-package dictionary :custom (dictionary-server "dict.org") :bind (("C-c w s d" . dictionary-lookup-definition))) ;; Writegood-Mode for buzzwords, passive writing and repeated word word detection (use-package writegood-mode :bind (("C-c w s r" . writegood-reading-ease)) :hook (text-mode . writegood-mode)) ;; ediff (use-package edif :ensure nil :custom (ediff-keep-variants nil) (ediff-split-window-function 'split-window-horizontally) (ediff-window-setup-function 'ediff-setup-windows-plain)) (use-package fountain-mode) (use-package markdown-mode) ;; Generic Org Export Settings (use-package org :custom (org-export-with-drawers nil) (org-export-with-todo-keywords nil) (org-export-with-broken-links t) (org-export-with-toc nil) (org-export-with-smart-quotes t) (org-export-date-timestamp-format "%e %B %Y")) (use-package ox-latex :ensure nil :demand t :custom ;; Multiple LaTeX passes for bibliographies (org-latex-pdf-process '("pdflatex -interaction nonstopmode -output-directory %o %f" "bibtex %b" "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f" "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f")) ;; Clean temporary files after export (org-latex-logfiles-extensions (quote ("lof" "lot" "tex~" "aux" "idx" "log" "out" "toc" "nav" "snm" "vrb" "dvi" "fdb_latexmk" "blg" "brf" "fls" "entoc" "ps" "spl" "bbl" "tex" "bcf")))) ;; LaTeX templates (with-eval-after-load 'ox-latex (add-to-list 'org-latex-classes '("crc" "\\documentclass[krantz2]{krantz} \\usepackage{lmodern} \\usepackage[authoryear]{natbib} \\usepackage{nicefrac} \\usepackage[bf,singlelinecheck=off]{caption} \\captionsetup[table]{labelsep=space} \\captionsetup[figure]{labelsep=space} \\usepackage{Alegreya} \\usepackage[scale=.8]{sourcecodepro} \\usepackage[breaklines=true]{minted} \\usepackage{rotating} \\usepackage[notbib, nottoc,notlot,notlof]{tocbibind} \\usepackage{amsfonts, tikz, tikz-layers} \\usetikzlibrary{fadings, quotes, shapes, calc, decorations.markings} \\usetikzlibrary{patterns, shadows.blur} \\usetikzlibrary{shapes,shapes.geometric,positioning} \\usetikzlibrary{arrows, arrows.meta, backgrounds} \\usepackage{imakeidx} \\makeindex[intoc] \\renewcommand{\\textfraction}{0.05} \\renewcommand{\\topfraction}{0.8} \\renewcommand{\\bottomfraction}{0.8} \\renewcommand{\\floatpagefraction}{0.75} \\renewcommand{\\eqref}[1]{(Equation \\ref{#1})} \\renewcommand{\\LaTeX}{LaTeX}" ("\\chapter{%s}" . "\\chapter*{%s}") ("\\section{%s}" . "\\section*{%s}") ("\\subsection{%s}" . "\\subsection*{%s}") ("\\subsubsection{%s}" . "\\paragraph*{%s}")))) (use-package ox-epub :demand t) ;; ADVANCED NDOCUMENTED EXPORT SETTINGS FOR EWS ;; Use GraphViz for flow diagrams (org-babel-do-load-languages 'org-babel-load-languages '((dot . t))) ; this line activates dot ;;; ADMINISTRATION ;; Bind org agenda command (use-package org :custom (org-log-into-drawer t) :bind (("C-c a" . org-agenda))) ;; FILE MANAGEMENT (use-package dired :ensure nil :commands (dired dired-jump) :custom (dired-listing-switches "-goah --group-directories-first --time-style=long-iso") (dired-dwim-target t) (delete-by-moving-to-trash t) :init (put 'dired-find-alternate-file 'disabled nil)) ;; Hide hidden files (use-package dired-hide-dotfiles :hook (dired-mode . dired-hide-dotfiles-mode) :bind (:map dired-mode-map ("." . dired-hide-dotfiles-mode))) (setq backup-directory-alist `(("." . ,(expand-file-name "backups/" user-emacs-directory))) version-control t delete-old-versions t create-lockfiles nil) ; No lock files ;; Recent files (use-package recentf :config (recentf-mode t) (run-at-time nil (* 5 60) (lambda () (let ((save-silently t)) (recentf-save-list)))) :custom (recentf-max-saved-items 50) :bind (("C-c w r" . recentf-open))) ;; Bookmarks (use-package bookmark :custom (bookmark-save-flag 1) :bind ("C-x r D" . bookmark-delete))