33 KiB
- Systems and custom functions
$whoami
, a big neckbeard, that’s who- Sonic arts
- Miscellaneous changes to make to the basic config
use-package
- Packages, modes, etc.
- Aesthetics
- Startup
Systems and custom functions
(if (string-equal system-type "android")
(setq fileroot "/storage/emulated/0/Sync/")
(setq fileroot "~/Documents/drive/"))
Firstly, tell Emacs where to look for custom functions (via EmacsWiki).
(defun load-directory (dir)
"Add all files in a directory to load-path"
(let ((load-it (lambda (f)
(load-file (concat (file-name-as-directory dir) f)))))
(mapc load-it (directory-files dir nil "\\.el$"))))
(load-directory "~/.emacs.d/custom/")
(load-directory (concat (file-name-as-directory fileroot) "admin/emacs/custom/"))
$whoami
, a big neckbeard, that’s who
Set name and location based on who I’m being right now.
(if (string-equal user-login-name "3055822")
(load-file (concat (file-name-as-directory fileroot) "admin/emacs/identity-work.el"))
(if workhours
(load-file (concat (file-name-as-directory fileroot) "admin/emacs/identity-work.el"))
(load-file (concat (file-name-as-directory fileroot) "admin/emacs/identity-home.el"))))
Sonic arts
Stop Emacs making sounds. I don’t think it ever made sounds before, but everyone is very insistent about the need to stop Emacs making sounds.
(setq ring-bell-function 'ignore)
(setq visible-bell t)
Also suppress certain warnings that would otherwise come up all the time and contribute very little to the experience.
(setq ad-redefinition-action 'accept)
(setq python-indent-guess-indent-offset-verbose nil)
(setq byte-compile-warnings '(cl-functions))
Miscellaneous changes to make to the basic config
I don’t want finding files to be case-sensitive, same as in zsh
:
(setq completion-ignore-case t)
(setq read-file-name-completion-ignore-case t)
(setq read-buffer-completion-ignore-case t)
Make the window frame look nice and clean. Scroll bars behave pointlessly on Windows anyway. Not hiding the menu bar because I’m not quite that leet yet. One day …
(setq inhibit-startup-screen t)
(tool-bar-mode -1)
(unless (string-equal system-type "android")
(scroll-bar-mode -1))
(tooltip-mode -1)
Make everything just a little tiny bit transparent unless I’m using the boring Windows desktop.
(unless (string-equal system-type "android")
(unless (string-equal user-login-name "3055822")
(set-frame-parameter (selected-frame) 'alpha 95)
(add-to-list 'default-frame-alist '(alpha . 95))))
Stop creating all those ~
files everywhere. Put them somewhere that I can ignore them.
(setq backup-directory-alist '(("." . "~/.emacs.d/backups")))
This gives buffers sensible names.
(require 'uniquify)
(setq uniquify-buffer-name-style 'forward)
Give me an excuse to use regex more often (from Better Defaults).
(global-set-key (kbd "C-s") 'isearch-forward-regexp)
(global-set-key (kbd "C-r") 'isearch-backward-regexp)
(global-set-key (kbd "C-M-s") 'isearch-forward)
(global-set-key (kbd "C-M-r") 'isearch-backward)
Go back to the same place in a file.
(save-place-mode 1)
Turn on automatic bracket/quotation mark matching.
(electric-pair-mode 1)
Stop init.el
getting forcibly appended with package information.
(defun package--save-selected-packages (&rest opt) nil)
SOMETIMES I WANT TO UPCASE OR DOWNCASE AN ENTIRE REGION, WHAT OF IT.
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
And to narrow to them.
(put 'narrow-to-region 'disabled nil)
It’s 2022 2023 nearly the second half of 2024.
(setq python-shell-interpreter "python3")
Make new directories automatically (from Emacs Redux).
(defun er-auto-create-missing-dirs ()
"Make new directories automatically"
(let ((target-dir (file-name-directory buffer-file-name)))
(unless (file-exists-p target-dir)
(make-directory target-dir t))))
(add-to-list 'find-file-not-found-functions #'er-auto-create-missing-dirs)
Indent using spaces.
(setq-default indent-tabs-mode nil)
OS-specific stuff
On Linux, I have to tell Emacs to use Chrome Vivaldi for web links.
(when (string-equal system-type "gnu/linux")
(setq browse-url-browser-function 'browse-url-generic
browse-url-generic-program "vivaldi"))
Honestly I don’t know if I’ll ever use macOS again, but in case I do, I need the meta key to work.
(when (string-equal system-type "darwin")
(setq ns-alternate-modifier 'meta)
(setq ns-right-alternate-modifier 'none))
Windows likes to set the default directory to the folder where the Emacs binary is stored, which it probably thinks is helpful, but is in fact Very Stupid.
(when (string-equal system-type "windows-nt")
(setq default-directory "~/"))
Android has enormous issues with keybindings, so requiring yes-or-no-p
where possible helps a bit.
(when (string-equal system-type "android")
(defalias 'y-or-n-p 'yes-or-no-p))
use-package
Set up package handling, including use-package
. Some of the org
tools I use are from Non-GNU ELPA, I think. Most of this is the standard use-package
setup stuff.
(unless (string-equal system-type "android")
(package-initialize)
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/") t)
(add-to-list 'package-archives '("nongnu" . "https://elpa.nongnu.org/nongnu/"))
(setq package-check-signature nil)
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(require 'use-package-ensure)
(setq use-package-always-ensure t))
Packages, modes, etc.
atomic-chrome
Use Emacs to type into the browser.
(unless (string-equal system-type "android")
(use-package atomic-chrome
:config
(atomic-chrome-start-server)
(setq atomic-chrome-default-major-mode 'markdown-mode)))
bibtex
I use BibLaTeX for better compatibility with accented characters and generally being more sensible.
(unless (string-equal system-type "android")
(use-package bibtex
:mode ("\\.bib" . bibtex-mode)
:config
(setq bibtex-dialect 'biblatex)))
calibredb
This may work only on Linux (it uses SQL???), but my ebooks are only on Linux so that’s ok.
(when (string-equal system-type "gnu/linux")
(use-package calibredb
:defer t
:config
(setq calibredb-root-dir "~/Documents/calibre/books")
(setq calibredb-db-dir (expand-file-name "metadata.db" calibredb-root-dir))
(setq calibredb-library-alist '(("~/Documents/calibre/books")
("~/Documents/calibre/ficrecs")))
(setq calibredb-sort-by 'author)
(setq calibredb-order 'asc)))
csv-mode
(unless (string-equal system-type "android")
(use-package csv-mode
:mode
(("\\.csv\\'" . csv-mode))
:hook
(csv-mode . csv-align-mode)
:config
(setq csv-align-max-width 1000)))
deft
Let me search my journal files when I’m not at work, and reading notes otherwise. Set regexp search by default.
(unless (string-equal system-type "android")
(use-package deft
:config
(setq deft-extensions '("org" "md"))
(if (string-equal user-login-name "3055822")
(progn
(setq deft-directory deft-secret-filepath)
(setq deft-use-filename-as-title t))
(setq deft-directory "~/Documents/drive/org/journal"))
(setq deft-current-sort-method 'title)
(setq deft-incremental-search nil)
(setq deft-recursive t)))
dimmer
Dims inactive buffers. Adjustments for modus-themes
as suggested.
(unless (string-equal system-type "android")
(use-package dimmer
:config
(setq dimmer-fraction 0.4)
(setq dimmer-adjustment-mode :foreground)
(setq dimmer-use-colorspace :rgb)
(dimmer-mode 1)))
doom-modeline
Much nicer-looking modeline, and still my favourite over newer, trendier options. Last time I tried installing this from MELPA it made Emacs crash; I don’t know if this is fixed yet.
(unless (string-equal system-type "android")
(use-package doom-modeline
:init
(doom-modeline-mode 1)
:config
(setq doom-modeline-buffer-file-name-style 'buffer-name)
(setq doom-modeline-minor-modes t)
(setq doom-modeline-enable-word-count t)
(setq doom-modeline-continuous-word-count-modes '(markdown-mode gfm-mode))
(setq doom-modeline-buffer-encoding nil)))
git-gutter
Shows, or at least purports to show, git diff
in the left margin if the file is being tracked by git
.
(unless (string-equal system-type "android")
(use-package git-gutter
:config
(global-git-gutter-mode 1)
(set-face-foreground 'git-gutter:added "forest green")
(set-face-foreground 'git-gutter:modified "goldenrod")
(set-face-foreground 'git-gutter:deleted "brown")
(setq git-gutter:added-sign "+"
git-gutter:modified-sign "×"
git-gutter:deleted-sign "-")))
isearch
From here:
(setq isearch-lazy-count t)
(setq lazy-count-prefix-format nil)
(setq lazy-count-suffix-format " (%s/%s)")
lastfm
(unless (string-equal system-type "android")
(unless (string-equal user-login-name "3055822")
(use-package lastfm)))
markdown-mode
I kind of hate markdown but I still have to use it sometimes.
(unless (string-equal system-type "android")
(use-package markdown-mode
:mode (("README\\.md\\'" . gfm-mode)
("\\.md\\'" . markdown-mode)
("\\.markdown\\'" . markdown-mode))
:hook
(markdown-mode . auto-fill-mode)
:config
(setq markdown-asymmetric-header t)
:custom
(markdown-header-scaling t)
:custom-face
(markdown-header-face ((t (:inherit (default font-lock-function-name-face) :weight bold))))))
mastodon
I’d just like to interject for a moment. What you’re referring to as Mastodon is in fact the fediverse (i.e., in this case, Pleroma).
(unless (string-equal system-type "android")
(use-package mastodon
:config
(setq mastodon-instance-url "https://ple.praze.net")))
minions
Lists minor modes in a menu.
(unless (string-equal system-type "android")
(use-package minions
:config
(minions-mode)))
mu4e
I really only use this for DW posts, but I’m constantly surprised by how well it works. This package is the reason I can’t upgrade to emacs28
, because it doesn’t currently seem to work; also, it uses cl
, which is deprecated, hence suppressing warnings about it above.
(when (string-equal system-type "gnu/linux")
(add-to-list 'load-path "/usr/share/emacs/site-lisp/mu4e")
(setq mu4e-sent-folder "/Fastmail/sent"
mu4e-drafts-folder "/Fastmail/drafts"
smtpmail-default-smtp-server "smtp.fastmail.com"
smtpmail-smtp-server "smtp.fastmail.com"
smtpmail-smtp-service 587)
(require 'mu4e)
(setq send-mail-function 'smtpmail-send-it))
neotree
Show a nice filetree with icons. I use this much less often than I should.
(unless (string-equal system-type "android")
(use-package neotree
:init
(global-set-key [f8] 'neotree-toggle)
:config
(setq neo-theme (if (display-graphic-p) 'icons 'arrow))))
nXML-mode
Attempting to do TEI stuff at work but I can’t link directly to the .rnc
file here; have to list it in a schemas.xml
file first, which references the .rnc
file locally (not sure how we would do an absolute filepath for this).
(unless (string-equal system-type "android")
(setq rng-schema-locating-files
'("schemas.xml" "~/.emacs.d/tei/schemas.xml" "c:/Program Files/Emacs/x86_64/share/emacs/27.1/etc/schema/schemas.xml"))
(defun indent-the-file ()
(interactive)
(indent-region (point-min) (point-max)))
(add-hook 'nxml-mode-hook
(lambda () (local-set-key (kbd "C-c C-i") 'indent-the-file)))
(add-hook 'nxml-mode-hook
(lambda () (local-set-key (kbd "<tab>") 'completion-at-point))))
Show path of current element (from here).
(unless (string-equal system-type "android")
(defun nxml-where ()
"Display the hierarchy of XML elements the point is on as a path."
(interactive)
(let ((path nil))
(save-excursion
(save-restriction
(widen)
(while (and (< (point-min) (point)) ;; Doesn't error if point is at beginning of buffer
(condition-case nil
(progn
(nxml-backward-up-element) ; always returns nil
t)
(error nil)))
(setq path (cons (xmltok-start-tag-local-name) path)))
(if (called-interactively-p t)
(message "/%s" (mapconcat 'identity path "/"))
(format "/%s" (mapconcat 'identity path "/")))))))
(defun xml-find-file-hook ()
(when (derived-mode-p 'nxml-mode)
(which-function-mode t)
(setq which-func-mode t)
(add-hook 'which-func-functions 'nxml-where t t)))
(add-hook 'find-file-hook 'xml-find-file-hook t))
nov
For reading ebooks. Only on Linux because I (supposedly) use it with my calibre library.
(when (string-equal system-type "gnu/linux")
(use-package nov
:init
(add-to-list 'auto-mode-alist '("\\.epub\\'" . nov-mode)))
(defun my-nov-font-setup ()
"Set the font for nov-mode"
(face-remap-add-relative 'variable-pitch :family "Liberation Serif"
:height 2.0))
(add-hook 'nov-mode-hook 'my-nov-font-setup))
org
my love
Initial settings
I want to indent under headings, I don’t want pointless line breaks when text can just wrap sensibly in the window, and I want to be able to ignore asterisks etc. when I skip to the beginning of lines.
(add-hook 'org-mode-hook 'org-indent-mode)
(add-hook 'org-mode-hook 'visual-line-mode)
(setq org-special-ctrl-a/e t)
Display images in org
buffers. I’ve increased the width to 500px because 300 was quite small. I’m assuming this doesn’t work on mobile, but why?
(unless (string-equal system-type "android")
(setq org-display-inline-images t)
(setq org-redisplay-inline-images t)
(setq org-startup-with-inline-images "inlineimages")
(setq org-image-actual-width '(500)))
Some agenda settings.
(setq org-agenda-show-current-time-in-grid nil)
(setq org-extend-today-until 3)
(setq org-agenda-skip-scheduled-if-done t)
(setq org-agenda-skip-deadline-if-done t)
(setq org-agenda-skip-timestamp-if-done t)
(setq org-agenda-breadcrumbs-separator " ▸ ") ; requires org 9.3
(setq calendar-day-name-array ["de Sul" "de Lun" "de Meurth" "de Mergher"
"de Yow" "de Gwener" "de Sadorn"])
(setq calendar-day-abbrev-array ["Su" "L" "Mth" "Mr" "Y" "G" "Sa"])
(setq calendar-month-name-array ["mis Genver" "mis Whevrel" "mis Meur’"
"mis Ebrel" "mis Me" "mis Efen"
"mis Gorefen" "mis Est" "mis Gwyngala"
"mis Hedra" "mis Du" "mis Kevardhu"])
(setq org-agenda-time-grid
'((daily today require-timed remove-match)
(800 1000 1200 1400 1600 1800 2000)
"......" "----------------"))
(setq org-agenda-time-leading-zero t)
Set general TODO keywords.
(setq org-todo-keywords
'((sequence "TODO" "|" "DONE" "CANCELLED")))
Track when I complete todos.
(setq org-log-done 'time)
Export settings
This can set certain headlines not to be exported. I haven’t used it yet but it sounds useful.
(unless (string-equal system-type "android")
(use-package org-contrib)
(require 'ox-extra)
(ox-extras-activate '(ignore-headlines)))
Add a couple of classes for LaTeX export.
(unless (string-equal system-type "android")
(add-to-list 'org-latex-classes
'("article-std"
"\\documentclass{article}
[NO-DEFAULT-PACKAGES]
\\input{$HOME/.emacs.d/header.tex} %$\n% latexbib"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")))
(add-to-list 'org-latex-classes
'("memoir"
"\\documentclass[11pt,a5paper,extrafontsizes]{memoir}
[NO-DEFAULT-PACKAGES]
\\usepackage[namechapters]{optional}
\\input{$HOME/.emacs.d/fic-export-files/header.tex} %$"
("\\chapter{%s}" . "\\chapter*{%s}")
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}"))))
Settings for export, mostly for DW post previews but also fic?? And work I guess, I do that sometimes.
(setq org-export-headline-levels 6)
(setq org-html-head-include-default-style nil)
(setq org-html-head "<link rel=\"stylesheet\" type=\"text/css\" href=\"https://tre.praze.net/main.css\" />")
(setq org-footnote-define-inline t)
(setq org-export-with-creator nil)
(setq org-export-with-toc nil)
(setq org-export-time-stamp-file nil)
(unless (string-equal system-type "android")
(if (string-equal user-login-name "3055822")
(progn
(setq org-export-with-author nil)
(setq org-latex-default-class "article-std"))
(if workhours
(progn
(setq org-export-with-author nil)
(setq org-latex-default-class "article-std"))
(setq org-latex-default-class "memoir")))
(setq org-latex-compiler "xelatex"))
(setq org-html-validation-link nil)
(setq org-html-doctype "html5")
Export non-breaking spaces properly; from, believe it or not, the Org Manual.
(defun my-html-filter-nobreaks (text backend info)
"Keep non-breaking spaces in HTML org export"
(when (org-export-derived-backend-p backend 'html)
(replace-regexp-in-string " " " " text)))
(if (string-equal system-type "android")
(setq org-export-filter-plain-text-functions
'my-html-filter-nobreaks)
(add-to-list 'org-export-filter-plain-text-functions
'my-html-filter-nobreaks))
(unless (string-equal system-type "android")
(defun my-latex-filter-nobreaks (text backend info)
"Keep non-breaking spaces in LaTeX org export"
(when (org-export-derived-backend-p backend 'latex)
(replace-regexp-in-string " " "~" text)))
(add-to-list 'org-export-filter-plain-text-functions
'my-latex-filter-nobreaks))
Packages
org-agenda-property
Let properties be inherited by subheadings. I use this a lot for :LOCATION:
on recurring events.
(unless (string-equal system-type "android")
(use-package org-agenda-property))
org-journal
Automate a tiny part of something I was previously doing manually.
(unless (string-equal system-type "android")
(if (string-equal user-login-name "3055822")
(progn
(use-package org-journal
:bind
("C-c j" . org-journal-new-entry)
:config
(setq org-journal-dir "~/Documents/drive/org")
(setq org-journal-file-type 'yearly)
(setq org-journal-file-format "journal-dump-%Y.org")
(setq org-journal-find-file 'find-file)
(setq org-journal-date-format "%Y-%m-%d")
(setq org-journal-time-format "%H:%M\n")))
(progn
(defun org-journal-file-header-func (time)
"Set the header for org-journal files"
(concat "<" (format-time-string "%Y-%m-%d %a") ">\n\n"))
(use-package org-journal
:bind
("C-c j" . org-journal-new-entry)
:config
(setq org-journal-dir "~/Documents/drive/org/journal")
(setq org-journal-file-format "%Y/%m/%Y-%m-%d.org")
(setq org-journal-find-file 'find-file)
(setq org-journal-date-format "journal")
(setq org-journal-time-format "%H:%M\n")
(setq org-journal-file-header 'org-journal-file-header-func)))))
org-modern
Use org-modern
. Fix for issue with table widths.
(unless (string-equal system-type "android")
(use-package org-modern
:hook
(org-mode . org-modern-mode))
(set-face-attribute 'org-table nil :inherit 'fixed-pitch)
(custom-set-variables '(org-modern-table nil)))
org-noter
RIP interleave
, but this does ok as a replacement.
(unless (string-equal system-type "android")
(use-package org-noter
:config
(setq org-noter-property-doc-file "INTERLEAVE_PDF"
org-noter-property-note-location "INTERLEAVE_PAGE_NOTE")))
org-sidebar
Display the file outline in a sidebar.
(unless (string-equal system-type "android")
(use-package org-sidebar
:bind
("C-c C-x s" . org-sidebar-tree)))
org-wc
Display word counts next to org headings.
(unless (string-equal system-type "android")
(use-package org-wc
:bind
("C-c C-x w" . org-wc-display)))
Agenda settings
Set the keybinding, set the week to start on Monday because I’m not the University of Oxford.
(global-set-key (kbd "C-c a") 'org-agenda)
(setq calendar-week-start-day 1)
(setq org-agenda-start-on-weekday nil)
Set the files to be included.
(if (string-equal system-type "android")
(if workhours
(setq org-agenda-files '("/storage/emulated/0/Sync/org/calendar/admin.org" "/storage/emulated/0/Sync/org/calendar/music.org" "/storage/emulated/0/Sync/org/calendar/work.org" "/storage/emulated/0/Sync/org/calendar/acwri.org"))
(setq org-agenda-files '("/storage/emulated/0/Sync/org/calendar/admin.org" "/storage/emulated/0/Sync/org/calendar/music.org" "/storage/emulated/0/Sync/org/calendar/personal.org")))
(progn
(add-to-list 'org-agenda-files "~/Documents/drive/org/calendar/music.org")
(add-to-list 'org-agenda-files "~/Documents/drive/org/calendar/admin.org")
(if (string-equal user-login-name "3055822")
(progn
(add-to-list 'org-agenda-files "~/Documents/drive/org/calendar/work.org")
(add-to-list 'org-agenda-files "~/Documents/drive/org/calendar/acwri.org"))
(progn
(add-to-list 'org-agenda-files "~/Documents/drive/org/calendar/home.org")
(if workhours
(progn
(add-to-list 'org-agenda-files "~/Documents/drive/org/calendar/work.org")
(add-to-list 'org-agenda-files "~/Documents/drive/org/calendar/acwri.org"))
(add-to-list 'org-agenda-files "~/Documents/drive/org/calendar/personal.org"))))))
Set how the agenda looks.
(setq org-agenda-prefix-format
'((todo . "%-2c %b")
(tags . "%-2c %b")
(agenda . "%-2c %?-12t%?-12s")))
(setq org-use-property-inheritance (quote ("LOCATION")))
(setq org-agenda-todo-ignore-scheduled 'future)
Add period information to the agenda header (this has a very weird output, completely different when you insert a function from just using text, utterly bizarre).
(setq org-agenda-custom-commands
'(("a" "Slightly modified agenda view"
((agenda ""
((org-agenda-overriding-header (periodise))))))))
Use a horizontal line to divide each day from the next.
(unless (string-equal system-type "android")
(setq org-agenda-format-date (lambda (date) (concat "\n"
(make-string (window-width) 9472)
"\n"
(org-agenda-format-date-aligned date)))))
Set up habit display.
(add-to-list 'org-modules 'org-habit t)
(setq org-habit-show-all-today t)
Set the calendar day headers to the same language as the agenda.
(setq calendar-day-header-array ["Sl" "Ln" "Mt" "Mr" "Yw" "Gw" "Sd"])
Refile
(when (string-equal system-type "gnu/linux")
(setq org-refile-use-outline-path 'file))
paren
Highlights matching bracket.
(show-paren-mode +1)
pdf-tools
and doc-view
Use the superior package for viewing PDFs on the superior operating system, and use a less reliable one otherwise. Ghostscript has to be installed on Windows, but it’s indispensable anyway.
(unless (string-equal system-type "android")
(if (string-equal system-type "windows-nt")
(use-package doc-view
:config
(setq doc-view-ghostscript-program "gswin32c"))
(use-package pdf-tools
:config
(pdf-tools-install)
(define-key pdf-view-mode-map (kbd "C-s") 'isearch-forward)
(add-hook 'pdf-view-mode-hook (lambda () (cua-mode 0)))
(setq pdf-view-resize-factor 1.1))))
recentf
Gives me a dialog with recently opened files. Package management stuff has to be manually excluded for obvious reasons. Surely I don’t have to call add-to-list
separately every time, but I haven’t found a more sensible way of doing it.
(recentf-mode 1)
(setq recentf-max-menu-items 20)
(setq recentf-max-saved-items 20)
(global-set-key (kbd "C-x C-r") 'recentf-open-files)
(add-to-list 'recentf-exclude
(expand-file-name "~/.emacs.d/elpa/*"))
(add-to-list 'recentf-exclude
(expand-file-name "~/.emacs.d/bookmarks"))
tex
As previously described, “the big boy”. I know little about most of these settings, but I think they’re the default ones.
(unless (string-equal system-type "android")
(use-package tex
:ensure auctex
:mode ("\\.tex\\'" . latex-mode)
:init
(add-hook 'LaTeX-mode-hook 'turn-on-auto-fill)
(add-hook 'TeX-after-compilation-finished-functions
#'TeX-revert-document-buffer)
:config
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq-default TeX-master nil)
(setq-default TeX-engine 'xetex)
(setq-default TeX-PDF-mode t)
(setq TeX-view-program-selection '((output-pdf "PDF Tools"))
TeX-source-correlate-start-server t)))
typo
Automatically use smart quotes. (Can’t be set to text-mode-hook
, unfortunately, as this messes things up in LaTeX; but the only other text-modes I use are org
and Markdown, I think.) Also, best to unset this mode in source blocks in org
, hook taken from here.
(unless (string-equal system-type "android")
(use-package typo
:custom
(typo-global-mode 1)
:hook
(org-mode . typo-mode)
(markdown-mode . typo-mode))
(defun unsmart-hook ()
"Turn off smart quotes for source blocks within org mode"
(add-hook 'typo-disable-electricity-functions 'org-in-src-block-p nil :local))
(add-hook 'org-mode-hook 'unsmart-hook))
web-mode
This is good for auto indentation, folding, killing elements, apparently XPath?? but I’ve failed to make faces work like they do in normal html-mode
.
(unless (string-equal system-type "android")
(use-package web-mode
:mode (("\\.html?\\'" . web-mode)
("\\.css" . web-mode))
:config
(setq web-mode-markup-indent-offset 2)
(setq web-mode-css-indent-offset 2)
(setq web-mode-enable-html-entities-fontification t)
(setq web-mode-enable-current-element-highlight t)
:bind
("C-c /" . web-mode-element-close)))
yasnippet
Per-mode text expansion. What a lifechanger.
(unless (string-equal system-type "android")
(use-package yasnippet
:config
(setq yas-snippet-dirs '("~/.emacs.d/snippets"))
(setq yas-triggers-in-field t))
(yas-global-mode 1))
Aesthetics
Packages
all-the-icons
Shows nice icons in the modeline and in neotree
. Fonts need to be installed manually on Windows, possibly because of permissions issues or because of where the Emacs binary lives or maybe both those things.
(unless (string-equal system-type "android")
(use-package all-the-icons
:config
(unless (string-equal system-type "windows-nt")
(when (not (member "all-the-icons" (font-family-list)))
(all-the-icons-install-fonts t)))))
emojify
Support for various types of emoge.
(unless (string-equal system-type "android")
(use-package emojify
:hook
(text-mode . emojify-mode)
(org-agenda-mode . emojify-mode)))
hl-line
Highlights current line.
(global-hl-line-mode 1)
Theme/colours
Set a theme from modus-themes
. This is built in for version 28 and above.
(unless (string-equal system-type "android")
(use-package modus-themes))
(setq modus-themes-bold-constructs t)
(setq modus-themes-italic-constructs t)
(setq modus-themes-mixed-fonts t)
(setq modus-themes-org-blocks 'gray-background)
(load-theme 'modus-operandi-tinted t)
Fonts
Use Noto fonts to match my system fonts on Linux. This has to be done differently on Windows for some reason.
(unless (string-equal system-type "android")
(if (string-equal system-type "windows-nt")
(custom-set-faces
'(default ((t (:family "Noto Mono" :foundry "outline" :slant normal :weight normal :height 98 :width normal))))
'(italic ((t (:slant italic))))
'(variable-pitch ((t (:family "Noto Sans" :height 90))))
'(fixed-pitch ((t (:family "Noto Mono" :height 90)))))
(custom-set-faces
'(italic ((t (:slant italic))))
'(variable-pitch ((t (:family "Noto Sans" :height 90))))
'(fixed-pitch ((t (:family "Noto Mono" :height 100))))
'(modus-themes-fixed-pitch ((t (:family "Noto Mono" :height 100)))))))
Use the mixed-pitch
package to determine the font intelligently in modes that contain both text and prog elements.
(unless (string-equal system-type "android")
(use-package mixed-pitch
:hook
(LaTeX-mode . mixed-pitch-mode)
(org-mode . mixed-pitch-mode)
(markdown-mode . mixed-pitch-mode)))
Startup
Set the *scratch*
buffer to org-mode
.
(setq initial-major-mode 'org-mode)
Tell me what version of Emacs I’m using so I know if there are packages I can’t use.
(setq initial-scratch-message
(concat "# emacs " (number-to-string emacs-major-version) " on " (symbol-name system-type) "\n\n"))
Finally, because org
gets very confused by all these settings, give it a friendly reload.
(org-reload)