Last active
February 20, 2025 22:51
-
-
Save danstn/528510439e321d6f8eb46307a43bf505 to your computer and use it in GitHub Desktop.
Emacs config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Set custom file | |
(setq custom-file "~/.emacs.custom.el") | |
;; enable melpa | |
(add-to-list 'package-archives | |
'("melpa" . "https://melpa.org/packages/") t) | |
;; load emacs lisp packages | |
(package-initialize) | |
(setq confirm-kill-emacs 'y-or-n-p) | |
;; typography | |
(set-frame-font "Iosevka 16" nil t) | |
(setq help-window-select t) | |
;; disable tool, menu and scroll bars | |
(tool-bar-mode 0) | |
(menu-bar-mode 0) | |
(scroll-bar-mode 0) | |
(when (eq system-type 'gnu/linux) | |
(add-to-list 'default-frame-alist '(undecorated . t)) | |
) | |
;; disable bell | |
(setq ring-bell-function 'ignore) | |
;; enable line column indicator | |
;; (global-display-fill-column-indicator-mode) | |
;; (setq-default fill-column 80) | |
;; show line numbers | |
(column-number-mode 1) | |
(global-display-line-numbers-mode 1) | |
;; highlight matching parens | |
(show-paren-mode 1) | |
;; disable splash, backup file and other misc settings | |
(setq-default inhibit-splash-screen t | |
make-backup-files nil | |
tab-width 4 | |
indent-tabs-mode nil | |
compilation-scroll-output t) | |
;; packages | |
;; -------- | |
(use-package evil | |
:ensure t | |
:config | |
(evil-mode 1)) | |
(use-package evil-org | |
:ensure t | |
:after org | |
:hook (org-mode . (lambda () evil-org-mode)) | |
:config | |
(require 'evil-org-agenda) | |
(evil-org-agenda-set-keys)) | |
(use-package company | |
:ensure t | |
:hook (after-init . global-company-mode)) | |
(setq company-show-quick-access t) | |
(use-package doom-themes | |
:ensure t | |
:config | |
(load-theme 'doom-sourcerer t)) | |
(use-package ledger-mode | |
:ensure t) | |
(use-package go-mode | |
:ensure t) | |
(use-package which-key | |
:ensure t) | |
(which-key-mode) | |
;; enable ido | |
(use-package vertico | |
:ensure t | |
:custom | |
(vertico-scroll-margin 2) ;; Different scroll margin | |
;; (vertico-count 20) ;; Show more candidates | |
(vertico-resize nil) ;; Grow and shrink the Vertico minibuffer | |
;; (vertico-cycle t) ;; Enable cycling for `vertico-next/previous' | |
:init | |
(vertico-mode)) | |
(use-package orderless | |
:ensure t | |
:custom | |
;; Configure a custom style dispatcher (see the Consult wiki) | |
;; (orderless-style-dispatchers '(+orderless-consult-dispatch orderless-affix-dispatch)) | |
;; (orderless-component-separator #'orderless-escapable-split-on-space) | |
(completion-styles '(orderless basic)) | |
(completion-category-defaults nil) | |
(completion-category-overrides '((file (styles partial-completion))))) | |
(use-package magit | |
:ensure t) | |
(use-package git-gutter | |
:ensure t | |
:hook (git-gutter-mode) | |
:config | |
(setq git-gutter:update-interval 0.02)) | |
(use-package git-gutter-fringe | |
:ensure t | |
:config | |
(define-fringe-bitmap 'git-gutter-fr:added [224] nil nil '(center repeated)) | |
(define-fringe-bitmap 'git-gutter-fr:modified [224] nil nil '(center repeated)) | |
(define-fringe-bitmap 'git-gutter-fr:deleted [128 192 224 240] nil nil 'bottom)) | |
;; theme cycling | |
(defvar my-themes '(modus-operandi doom-sourcerer) | |
"List of themes to cycle through") | |
(defun my/cycle-themes () | |
"Cycle through themes" | |
(interactive) | |
(let ((next-theme (pop my-themes))) | |
(mapc #'disable-theme custom-enabled-themes) | |
(load-theme next-theme t) | |
(message "Switched to theme: %s" next-theme) | |
(nconc my-themes (list next-theme)))) | |
(global-set-key (kbd "C-x t") 'my/cycle-themes) | |
;; org | |
;; -------- | |
;; bind agenda key | |
(global-set-key (kbd "C-c a") 'org-agenda) | |
(global-set-key (kbd "C-c c") 'org-capture) | |
(setq org-todo-keywords | |
'((sequence "INBOX(i)" "NEXT(n)" "IN PROGRESS(p)" "WAITING(w)" "SOMEDAY(s)" "|" "DONE(d)" "CANCELLED(c)"))) | |
(setq org-todo-keyword-faces | |
'( | |
("INBOX" . "red") | |
("NEXT" . "blue") | |
("IN PROGRESS" . "orange") | |
("WAITING" . "red") | |
("DONE" . (:foreground "darkgreen")) | |
("SOMEDAY" . (:foreground "darkgray" :weight bold)) | |
("CANCELLED" . (:foreground "gray" :weight bold)) | |
)) | |
(setq org-agenda-custom-commands | |
'( ;; overview | |
("g" "GTD overview" | |
( | |
(todo "INBOX" ((org-agenda-overriding-header "Inbox"))) | |
(todo "NEXT" ((org-agenda-overriding-header "Next"))) | |
(todo "IN PROGRESS" ((org-agenda-overriding-header "In Progress"))) | |
(agenda "" ((org-agenda-start-on-weekday 1) | |
(org-agenda-span 7))) | |
(todo "WAITING" ((org-agenda-overriding-header "Waiting"))) | |
(todo "SOMEDAY" ((org-agenda-overriding-header "Someday"))) | |
(todo "DONE" ( | |
(org-agenda-overriding-header "Done") | |
)) | |
(todo "CANCELLED" ((org-agenda-overriding-header "Cancelled"))) | |
) | |
( ;; settings | |
;;(org-agenda-prefix-format "\t")) | |
) | |
))) | |
;; set default target file for notes | |
(setq org-directory "~/org") | |
(setq org-default-notes-file (concat org-directory "/gtd.org")) | |
;; automatically add timestamp when marking todos as done | |
(setq org-log-done 'time) | |
;; capture templates | |
(setq org-capture-templates | |
'(("i" "Inbox" entry (file+headline "~/org/gtd.org" "GTD") | |
"* INBOX %? \nCREATED: %U" | |
:prepend t | |
:empty-lines-before 1 | |
:empty-lines-after 1 | |
:before-finalize org-update-parent-todo-statistics) | |
("j" "Journal" entry (file "~/org/journal.org") | |
"* %?\nCREATED: %U" | |
:prepend t | |
:empty-lines-before 1 | |
:empty-lines-after 1) | |
("m" "Meeting" entry (file+headline "~/org/meetings.org" "MEETINGS") | |
"* %?\nDATE: %U" | |
:prepend t | |
:empty-lines-before 1 | |
:empty-lines-after 1) | |
("f" "Fact" item (file+headline "~/org/facts.org" "FACTS") | |
"- %u %?" | |
:prepend t))) | |
;; set monday as first day in calendar | |
(setq calendar-week-start-day 1) | |
(setq org-agenda-include-deadlines 1) | |
;; include diary | |
(setq org-agenda-include-diary t) | |
(setq org-agenda-files '("~/org/")) | |
(setq org-use-fast-todo-selection 'expert) | |
(custom-set-faces | |
'(org-level-1 ((t (:height 1.5 :italic t :foreground "highlight")))) | |
'(org-level-2 ((t (:height 1.3 :bold t)))) | |
'(org-level-3 ((t (:height 1.2)))) | |
) | |
(org-babel-do-load-languages | |
'org-babel-load-languages | |
'((python . t))) | |
;; my functions | |
;; ------------ | |
(defun my/gen-token (&optional prefix) | |
"Generate a unique token with an optional single letter prefix and a 6-character random alphanumeric string." | |
(let* ((prefix (or prefix "")) | |
(chars "abcdefghijklmnopqrstuvwxyz0123456789") | |
(token (apply 'string (mapcar (lambda (_) (aref chars (random (length chars)))) (number-sequence 1 6))))) | |
(if (string-empty-p prefix) | |
token | |
(concat prefix "_" token)))) | |
;; automatically switch to the newly split window | |
(global-set-key (kbd "C-x 2") (lambda () (interactive) (split-window-below) (other-window 1))) | |
(global-set-key (kbd "C-x 3") (lambda () (interactive) (split-window-right) (other-window 1))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment