astro's literate .emacs.d
Date:
This is my literate emacs file. When tangled, it gives post-init.el and should be used with James Cherti's minimal-emacs.d.
Config
🔗Lexical Binding
🔗;;; -*- no-byte-compile: t; lexical-binding: t -*-
Compile-Angel
🔗Keep compile-angel at the top!
(use-package compile-angel
:demand t
:config
(setq package-native-compile nil)
(setq compile-angel-verbose t)
(push "/init.el" compile-angel-excluded-files)
(push "/early-init.el" compile-angel-excluded-files)
(push "/pre-init.el" compile-angel-excluded-files)
(push "/post-init.el" compile-angel-excluded-files)
(push "/pre-early-init.el" compile-angel-excluded-files)
(push "/post-early-init.el" compile-angel-excluded-files)
(compile-angel-on-load-mode 1))
Use-Package
🔗(eval-when-compile (require 'use-package))
Filepaths
🔗(defvar my/journal-dir "~/org/journal" "Directory for my journals.")
(defvar my/roam-dir "~/org" "Directory for my org-roam notes")
(defvar my/bookmarks-file "~/org/bookmarks.org" "Bookmarks File")
(setq org-refile-targets
'((("~/org/journal/todo-masterlist.org") :maxlevel . 2)
(("~/org/archive/workspace_archive.org") :maxlevel . 1)))
Auto Revert
🔗Auto-revert in Emacs is a feature that automatically updates the contents of a buffer to reflect changes made to the underlying file on disk.
(use-package autorevert
:ensure nil
:commands (auto-revert-mode global-auto-revert-mode)
:hook
(after-init . global-auto-revert-mode)
:init
;; (setq auto-revert-verbose t)
(setq auto-revert-interval 3)
(setq auto-revert-remote-files nil)
(setq auto-revert-use-notify t)
(setq auto-revert-avoid-polling nil))
Recentf
🔗maintains a list of recently accessed files
(use-package recentf
:ensure nil
:commands (recentf-mode recentf-cleanup)
:hook
(after-init . recentf-mode)
:init
(setq recentf-auto-cleanup (if (daemonp) 300 'never))
(setq recentf-exclude
(list "\\.tar$" "\\.tbz2$" "\\.tbz$" "\\.tgz$" "\\.bz2$"
"\\.bz$" "\\.gz$" "\\.gzip$" "\\.xz$" "\\.zip$"
"\\.7z$" "\\.rar$"
"COMMIT_EDITMSG\\'"
"\\.\\(?:gz\\|gif\\|svg\\|png\\|jpe?g\\|bmp\\|xpm\\)$"
"-autoloads\\.el$" "autoload\\.el$"))
:config
(add-hook 'kill-emacs-hook #'recentf-cleanup -90))
A cleanup depth of -90 ensures that `recentf-cleanup' runs before `recentf-save-list', allowing stale entries to be removed before the list is saved by `recentf-save-list', which is automatically added to `kill-emacs-hook' by `recentf-mode'.
Savehist
🔗(use-package savehist
:ensure nil
:commands (savehist-mode savehist-save)
:hook
(after-init . savehist-mode)
:init
(setq history-length 300)
(setq savehist-autosave-interval 600))
Save-place-mode
🔗save-place-mode enables Emacs to remember the last location within a file upon reopening. This feature is particularly beneficial for resuming work at the precise point where you previously left off.
(use-package saveplace
:ensure nil
:commands (save-place-mode save-place-local-mode)
:hook
(after-init . save-place-mode)
:init
(setq save-place-limit 400))
Auto-save-mode
🔗Enable `auto-save-mode' to prevent data loss.
(setq auto-save-default t)
Trigger an auto-save after 300 keystrokes
(setq auto-save-interval 300)
Trigger an auto-save 30 seconds of idle time.
(setq auto-save-timeout 30)
undo-fu
🔗lightweight wrapper around Emacs' built-in undo system, providing more convenient undo/redo functionality.
(use-package undo-fu
:commands (undo-fu-only-undo
undo-fu-only-redo
undo-fu-only-redo-all
undo-fu-disable-checkpoint)
:config
(global-set-key (kbd "C-/") 'undo-fu-only-undo)
(global-set-key (kbd "C-S-/") 'undo-fu-only-redo))
undo-fu-session
🔗package complements undo-fu by enabling the saving and restoration of undo history across Emacs sessions, even after restarting.
(use-package undo-fu-session
:commands undo-fu-session-global-mode
:hook (after-init . undo-fu-session-global-mode))
buffer-terminator
🔗(use-package buffer-terminator
:custom
(buffer-terminator-verbose nil)
(buffer-terminator-inactivity-timeout (* 30 60)) ; 30 minutes
(buffer-terminator-interval (* 10 60)) ; 10 minutes
:config
(buffer-terminator-mode 1))
Corfu
🔗(use-package corfu
:commands (corfu-mode global-corfu-mode)
:hook ((prog-mode . corfu-mode)
(shell-mode . corfu-mode)
(eshell-mode . corfu-mode))
:custom
(read-extended-command-predicate #'command-completion-default-include-p)
(text-mode-ispell-word-completion nil)
(tab-always-indent 'complete)
:config
(global-corfu-mode))
Cape
🔗(use-package cape
:commands (cape-dabbrev cape-file cape-elisp-block)
:bind ("C-c p" . cape-prefix-map)
:init
(add-hook 'completion-at-point-functions #'cape-dabbrev)
(add-hook 'completion-at-point-functions #'cape-file)
(add-hook 'completion-at-point-functions #'cape-elisp-block))
Vertico
🔗Vertico provides a vertical completion interface
(use-package vertico
:config
(vertico-mode)
(setq vertico-count 8))
Orderless
🔗(use-package orderless
:custom
(completion-styles '(orderless basic))
(completion-category-defaults nil)
(completion-category-overrides '((file (styles partial-completion)))))
Prescient
🔗(use-package prescient
:ensure t)
Marginalia
🔗(use-package marginalia
:commands (marginalia-mode marginalia-cycle)
:hook (after-init . marginalia-mode))
Embark
🔗(use-package embark
:commands (embark-act
embark-dwim
embark-export
embark-collect
embark-bindings
embark-prefix-help-command)
:bind
(("C-." . embark-act)
("C-;" . embark-dwim)
("C-h B" . embark-bindings))
:init
(setq prefix-help-command #'embark-prefix-help-command)
:config
(add-to-list 'display-buffer-alist
'("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*"
nil
(window-parameters (mode-line-format . none)))))
Embark-Consult
🔗(use-package embark-consult
:hook
(embark-collect-mode . consult-preview-at-point-mode))
Consult
🔗Consult offers a suite of commands for efficient searching, previewing, and interacting with buffers, file contents, and more, improving various tasks.
(use-package consult
:bind (
("C-c M-x" . consult-mode-command)
("C-c h" . consult-history)
("C-c k" . consult-kmacro)
("C-c m m" . consult-man)
("C-c m i" . consult-info)
([remap Info-search] . consult-info)
("C-x M-:" . consult-complex-command)
("C-x b" . consult-buffer)
("C-x 4 b" . consult-buffer-other-window)
("C-x 5 b" . consult-buffer-other-frame)
("C-x t b" . consult-buffer-other-tab)
("C-x r b" . consult-bookmark)
("M-y" . consult-yank-pop)
;; M-g bindings in `goto-map'
("M-g g" . consult-goto-line)
("M-g o" . consult-outline)
("M-g m" . consult-mark)
("M-g k" . consult-global-mark)
("M-g i" . consult-imenu)
("M-g I" . consult-imenu-multi)
;; M-s bindings in `search-map'
("M-s d" . consult-find)
("M-s c" . consult-locate)
("M-s g" . consult-grep)
("M-s r" . consult-ripgrep)
("M-s l" . consult-line)
("M-s L" . consult-line-multi)
("M-s k" . consult-keep-lines)
("M-s u" . consult-focus-lines)
;; Isearch integration
("M-s e" . consult-isearch-history)
:map isearch-mode-map
("M-e" . consult-isearch-history)
("M-s e" . consult-isearch-history)
("M-s l" . consult-line)
("M-s L" . consult-line-multi)
;; Minibuffer history
:map minibuffer-local-map
("M-s" . consult-history)
("M-r" . consult-history))
:hook (completion-list-mode . consult-preview-at-point-mode)
:init
(setq register-preview-delay 0.5
register-preview-function #'consult-register-format))
Treemacs
🔗A file and project explorer for Emacs that displays a structured tree layout
(use-package treemacs
:commands (treemacs
treemacs-select-window
treemacs-delete-other-windows
treemacs-select-directory
treemacs-bookmark
treemacs-find-file
treemacs-find-tag)
:bind
(:map global-map
("M-0" . treemacs-select-window)
("C-x t 1" . treemacs-delete-other-windows)
("C-x t t" . treemacs)
("C-x t d" . treemacs-select-directory)
("C-x t B" . treemacs-bookmark)
("C-x t C-t" . treemacs-find-file)
("C-x t M-t" . treemacs-find-tag))
:init
(with-eval-after-load 'winum
(define-key winum-keymap (kbd "M-0") #'treemacs-select-window))
:config
(setq treemacs-collapse-dirs (if treemacs-python-executable 3 0)
treemacs-deferred-git-apply-delay 0.5
treemacs-directory-name-transformer #'identity
treemacs-display-in-side-window t
treemacs-eldoc-display 'simple
treemacs-file-event-delay 2000
treemacs-file-extension-regex treemacs-last-period-regex-value
treemacs-file-follow-delay 0.2
treemacs-file-name-transformer #'identity
treemacs-follow-after-init t
treemacs-expand-after-init t
treemacs-find-workspace-method 'find-for-file-or-pick-first
treemacs-git-command-pipe ""
treemacs-goto-tag-strategy 'refetch-index
treemacs-header-scroll-indicators '(nil . "^^^^^^")
treemacs-hide-dot-git-directory t
treemacs-indentation 2
treemacs-indentation-string " "
treemacs-is-never-other-window nil
treemacs-max-git-entries 5000
treemacs-missing-project-action 'ask
treemacs-move-files-by-mouse-dragging t
treemacs-move-forward-on-expand nil
treemacs-no-png-images nil
treemacs-no-delete-other-windows t
treemacs-project-follow-cleanup nil
treemacs-persist-file (expand-file-name ".cache/treemacs-persist" user-emacs-directory)
treemacs-position 'left
treemacs-read-string-input 'from-child-frame
treemacs-recenter-distance 0.1
treemacs-recenter-after-file-follow nil
treemacs-recenter-after-tag-follow nil
treemacs-recenter-after-project-jump 'always
treemacs-recenter-after-project-expand 'on-distance
treemacs-litter-directories '("/node_modules" "/.venv" "/.cask")
treemacs-project-follow-into-home nil
treemacs-show-cursor nil
treemacs-show-hidden-files t
treemacs-silent-filewatch nil
treemacs-silent-refresh nil
treemacs-sorting 'alphabetic-asc
treemacs-select-when-already-in-treemacs 'move-back
treemacs-space-between-root-nodes t
treemacs-tag-follow-cleanup t
treemacs-tag-follow-delay 1.5
treemacs-text-scale nil
treemacs-user-mode-line-format nil
treemacs-user-header-line-format nil
treemacs-wide-toggle-width 70
treemacs-width 35
treemacs-width-increment 1
treemacs-width-is-initially-locked t
treemacs-workspace-switch-cleanup nil)
(treemacs-follow-mode t)
(treemacs-filewatch-mode t)
(treemacs-fringe-indicator-mode 'always)
(pcase (cons (not (null (executable-find "git")))
(not (null treemacs-python-executable)))
(`(t . t)
(treemacs-git-mode 'deferred))
(`(t . _)
(treemacs-git-mode 'simple)))
(treemacs-hide-gitignored-files-mode nil))
Visual/UI Stuff
🔗Displays line number and column number in the modeline
(setq line-number-mode t)
(setq column-number-mode t)
(setq mode-line-position-column-line-format '("%l:%C"))
Font size
elisp(set-face-attribute 'default nil :height 170)Theming I'm very partial to doom-themes. Past favourites have been: doom-rouge
elisp(use-package doom-themes :ensure t :config (load-theme 'doom-laserwave t))
(use-package doom-modeline
:init (doom-modeline-mode 1))
- Enable visual-line-mode This wraps text neatly.
(global-visual-line-mode 1)
Face for highlighting keybindings
🔗(defface my/button-face
'((t (:inherit icon-button :box (:line-width -1 :style released-button))))
"Face that looks like a raised button.")
(defun my/org-fontify-hidden-buttons ()
"Fontify [~ ... ~] blocks and hide outer markers."
(font-lock-add-keywords
nil
'(("\\(\\[~\\)\\(.*?\\)\\(~\\]\\)"
(1 '(face default invisible t))
(2 'my/button-face)
(3 '(face default invisible t))))))
(add-hook 'org-mode-hook #'my/org-fontify-hidden-buttons)
Basic Stuff
🔗can maintain the "rhythm" so to speak
(repeat-mode 1)
can just type 'y' or 'n' instead of a whole word
(fset 'yes-or-no-p 'y-or-n-p)
Calendar
🔗calfw
🔗I sometimes use calfw to display all the events. For most purposes though, the built-in calendar is more than sufficient.
(use-package calfw
:ensure t
:demand t)
(use-package calfw-org
:ensure t
:demand t)
CSV Mode
🔗Don't use it as much; might retire
(use-package csv-mode
:commands (csv-mode
csv-align-mode
csv-guess-set-separator)
:mode ("\\.csv\\'" . csv-mode)
:hook ((csv-mode . csv-align-mode)
(csv-mode . csv-guess-set-separator))
:custom
(csv-align-max-width 100)
(csv-separators '("," ";" " " "|" "\t")))
Org Stuff
🔗The real meat of the dotfiles. I use org extensively.
(add-to-list 'warning-suppress-types '(org-element org-element-parser))
The following hides emphasis markers (like *, ~ ) pairs well with org-appear mode
(setq org-hide-emphasis-markers t)
org-appear mode shows the emphasis markers only when the mark is at the word with emphasis
(use-package org-appear
:after org
:custom (add-hook 'org-mode-hook 'org-appear-mode))
Org Agenda
🔗keybinding for accessing org-agenda
(global-set-key (kbd "C-c a") 'org-agenda)
Shows 3 previous days + the next 7 days
(setq org-agenda-span 10
org-agenda-start-on-weekday nil
org-agenda-start-day "-3d")
I use a singular agenda-file.
(setq org-agenda-files '("~/org/journal/todo-masterlist.org"))
Org Export Stuff
🔗(setq org-export-creator-string "")
(setq org-export-with-author nil)
(setq org-export-with-tags nil)
(setq org-export-with-toc nil)
(setq org-export-with-todo-keywords nil)
(setq org-export-with-broken-links t)
Export to ICS
🔗to make sure that non-todo items with a scheduled/deadline are exported to the ics!!
(setq org-icalendar-use-scheduled '(event-if-not-todo todo-start))
(setq org-icalendar-use-deadline '(event-if-not-todo event-if-todo todo-due))
(setq org-icalendar-scheduled-summary-prefix " ")
Org Todos to ical export
(setq org-icalendar-include-todo t)
APA7 Papers // Latex
🔗Ox-Latex
🔗(with-eval-after-load 'ox-latex
(add-to-list 'org-latex-classes
'("apa7"
"\\documentclass[stu,12pt]{apa7}"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}"))))
Citar
🔗(use-package citar
:no-require
:custom
(org-cite-global-bibliography '("~/org/My Library.bib"))
(org-cite-insert-processor 'citar)
(org-cite-follow-processor 'citar)
(org-cite-activate-processor 'citar)
(citar-bibliography org-cite-global-bibliography)
(org-cite-export-processors
'((md . (csl "~/org/extra/references-meta/apa.csl"))
(odt . (csl "~/org/extra/references-meta/apa.csl"))
(latex . (csl "~/org/extra/references-meta/apa.csl"))
(t . (csl "~/org/extra/references-meta/apa.csl"))))
:bind
(:map org-mode-map :package org ("C-c b" . #'org-cite-insert)))
Tectonic
🔗use tectonic because it downloads all modules that are necessary on the fly
(setq org-latex-pdf-process '("tectonic %f"))
Sync Blog Posts
🔗(defun my-sync-blog-posts ()
(interactive)
(let ((src (file-name-as-directory (expand-file-name "~/org/blog/")))
(dst (file-name-as-directory (expand-file-name "~/projects/blog/src/posts/"))))
(make-directory dst t)
(call-process "rsync" nil "*rsync-sync*" t
"-a" "--delete" src dst)
(dolist (file (directory-files-recursively dst "\\.org\\'"))
(my-strip-org-id-links-in-file file))
(message "Synced and stripped id links.")))
Strip Org Id Links from File
🔗(defun my-strip-org-id-links-in-file (file)
(with-temp-buffer
(insert-file-contents file)
(goto-char (point-min))
(while (re-search-forward "\\[\\[id:[^]]+\\]\\[\\([^]]+\\)\\]\\]" nil t)
(replace-match "\\1" t))
(write-region (point-min) (point-max) file)))
Org Hugo
🔗(use-package ox-hugo
:ensure t
:pin melpa
:after ox)
Org Appear
🔗(use-package org-appear
:after org
:custom (add-hook 'org-mode-hook 'org-appear-mode))
Org Structure Template
🔗(require 'org-tempo)
(setq org-structure-template-alist
'(("a" . "aside")
("se" . "src elisp :results none") ("sh" . "src html")
("l" . "export latex") ("q" . "quote") ("s" . "src")
("n" . "note") ("pa" . "aside :noexport") ("w" . "warning")))
Org Modern
🔗(use-package org-modern)
(with-eval-after-load 'org (global-org-modern-mode))
Org Capture
🔗(setq org-capture-templates
'(("c" "college related stuff")
("cs" "scheduled college todo" entry
(file "~/org/journal/todo-masterlist.org")
"** TODO %? :college: \n SCHEDULED: %^t")
("cd" "deadline college todo" entry
(file "~/org/journal/todo-masterlist.org")
"** TODO %? :college: \n DEADLINE: %^t")
("ct" "general college todo" entry
(file "~/org/journal/todo-masterlist.org")
"** TODO %? :college:")
("t" "General Todo" entry
(file "~/org/journal/todo-masterlist.org")
"** TODO %? %^g")
("e" "Event" entry
(file "~/org/journal/todo-masterlist.org" "Events")
"** TODO %? %^g\n %^t")
("b" "bookmark" entry
(file "~/org/journal/bookmarks.org" "Inbox")
"** %? %^g \n :PROPERTIES: \n :CREATED: %t \n:END:")
("w" "orgprotocol bookmark" entry
(file+headline "~/org/journal/bookmarks.org" "Inbox")
"** [[%:link][%:description]] %i %?\n:PROPERTIES:\n:CREATED: %t\n:END:")))
Org Roam
🔗(use-package org-roam
:ensure t
:custom
(org-roam-directory (file-truename "~/org"))
(org-roam-capture-templates
'(("d" "default" plain "%?"
:if-new (file+head
"${slug}.org"
"#+title: ${title}\n#+created: %(format-time-string \"%Y-%m-%d\")\n#+filetags:\n#+lastmod:\n")
:unnarrowed t)))
:bind (("C-c n l" . org-roam-buffer-toggle)
("C-c n f" . org-roam-node-find)
("C-c n g" . org-roam-graph)
("C-c n i" . org-roam-node-insert)
("C-c n c" . org-roam-capture))
:config
(setq org-roam-node-display-template (concat "${title:*} " (propertize "${tags:10}" 'face 'org-tag)))
(org-roam-db-autosync-mode))
(setq org-roam-file-exclude-regexp '("data/" ".stfolder/" "archive/" "auto-save-list/" ".backup/" "harp-profile-harp-org.org" ".stversions"))
Find orphaned org roam nodes
🔗(defun my-find-org-roam-orphans ()
(interactive)
(let* ((org-roam--db (sqlite-open org-roam-db-location))
(org-roam-orphans (sqlite-select org-roam--db
"select * from nodes n where not exists (select null from links l where n.id = l.source) and not exists (select null from links l where n.id = l.dest);")))
(sqlite-close org-roam--db)
(find-file (completing-read "Orphan node: "
(mapcar (lambda (rec) (string-replace "\"" "" (cadr rec))) org-roam-orphans)))))
Org Roam UI
🔗(use-package org-roam-ui
:ensure t
:after org-roam)
Org Roam Timeline
🔗Great little package, don't use now though
(use-package org-roam-timeline)
Org Journal
🔗(use-package org-journal
:ensure t
:custom
(org-journal-dir (expand-file-name my/journal-dir))
(org-journal-file-type 'monthly)
(org-journal-file-format "%Y-%m-%b.org")
(org-journal-date-format "%A, %d %B %Y")
(org-journal-carryover-items ""))
(setq org-journal-file-header
(lambda (time)
(concat
":PROPERTIES:\n"
":ID: " (format-time-string "month-%Y-%m" time) "\n"
":END:\n"
"#+title: " (format-time-string "%B %Y" time) "\n"
"#+startup: folded\n"
"#+filetags: :private:\n"
"#+lastmod:\n\n")))
Org Download
🔗(use-package org-download)
(setq org-download-image-dir "images")
Other Org Stuff
🔗(use-package org-web-tools)
(use-package org-transclusion)
Org Protocol
🔗(require 'org-protocol)
Org Mindmap
🔗(use-package org-mindmap
:vc (:url "https://github.com/krvkir/org-mindmap.git" :rev :newest)
:after org)
Custom
🔗(add-to-list
'safe-local-variable-values
'(eval progn
(add-hook 'before-save-hook #'my/org-update-lastmod nil 'local)))
(add-to-list
'safe-local-variable-values
'(eval add-hook 'after-save-hook (lambda nil (org-icalendar-export-to-ics)) nil
t))
(defun my-org-confirm-babel-evaluate (lang body)
(not (string= lang "plantuml"))) ;don't ask for plantuml
(setq org-confirm-babel-evaluate #'my-org-confirm-babel-evaluate)
Mermaid
🔗(use-package ob-mermaid
:defer t)
Custom font face for admonitions
🔗(defface my-org-aside-face
'((t :foreground "SkyBlue1" :weight bold)) "")
(defface my-org-warning-face
'((t :foreground "orange red" :weight bold)) "")
(defface my-org-note-face
'((t :foreground "DeepSkyBlue" :weight bold)) "")
(defun my-org-admonition-matcher (limit)
(when (re-search-forward "^#\\+begin_\\(aside\\|warning\\|note\\)\\b.*$" limit t)
(let* ((type (match-string 1))
(face (pcase type
("aside" 'my-org-aside-face)
("warning" 'my-org-warning-face)
("note" 'my-org-note-face)))
(label (capitalize type)))
(put-text-property (match-beginning 0) (match-end 0)
'display
(propertize label 'face face))
t)))
(defun my-org-enable-admonitions ()
(font-lock-add-keywords nil '((my-org-admonition-matcher)) t)
(font-lock-flush))
(add-hook 'org-mode-hook #'my-org-enable-admonitions)
phscroll
🔗(use-package phscroll
:vc (:url "https://github.com/misohena/phscroll")
:after org
:init
(setq org-startup-truncated nil)
:config
(org-phscroll-activate))
org-grid
🔗(use-package org-grid
:load-path "custom/")
Plantuml Mode
🔗(use-package plantuml-mode
:config
(setq plantuml-default-exec-mode 'jar)
(setq plantuml-jar-path "~/plantuml.jar")
(setq org-plantuml-jar-path (expand-file-name "~/.emacs.d/plantuml.jar")))
(add-to-list 'org-src-lang-modes '("plantuml" . plantuml))
(org-babel-do-load-languages 'org-babel-load-languages '((plantuml . t) (python . t) (mermaid . t)))
Wikinfo
🔗(use-package wikinfo)
(use-package wikinforg
:load-path "custom/")
My custom functions
🔗To open this file (my literate-init.org)
(defun my/open-literate-init-file ()
"open the literate init file." (interactive)
(find-file (expand-file-name "literate-init.org" user-emacs-directory)))
To open the tangled post-init.el file
(defun my/open-init-file ()
"open the init file." (interactive)
(find-file (expand-file-name "post-init.el" user-emacs-directory)))
Open my org directory (~/org) in dired
(defun open-org-roam-directory-in-dired ()
"Open the org-roam-directory in Dired."
(interactive)
(let ((dir "~/org"))
(dired dir)))
To open my todo-masterlist.org file
(defun my/open-todo-master ()
"Open the master todo file from journal" (interactive)
(find-file (expand-file-name "todo-masterlist.org" my/journal-dir)))
To update the "#+lastmod:" field in org files with the date whenever modified and saved
(defun my/org-update-lastmod ()
"Update the last modified timestamp in the current buffer."
(interactive)
(when (derived-mode-p 'org-mode)
(save-excursion
(goto-char (point-min))
(let ((time-str (format-time-string "%Y-%m-%d %H:%M:%S")))
(if (re-search-forward "^#\\+lastmod:.*$" nil t)
(replace-match (concat "#+lastmod: " time-str) t t)
(goto-char (point-max))
(unless (bolp) (insert "\n"))
(insert "#+lastmod: " time-str "\n"))))))
Keybindings
🔗(global-set-key (kbd "C-c c") 'org-capture)
(global-set-key (kbd "C-c j") 'org-journal-new-entry)
(global-set-key (kbd "C-c o j") 'org-journal-open-current-journal-file)
(global-set-key (kbd "C-c l") 'org-goto-calendar)
(global-set-key (kbd "C-z") 'scratch-buffer)
(global-set-key (kbd "C-c o t") #'my/open-todo-master)
(global-set-key (kbd "C-c o n") 'open-org-roam-directory-in-dired)
(global-set-key (kbd "C-c o i") #'my/open-init-file)
(global-set-key (kbd "C-c o l") #'my/open-literate-init-file)
Uniline
🔗(use-package uniline)
Popper
🔗(use-package popper
:ensure t
:bind (("s-`" . popper-toggle)
("s-<tab>" . popper-cycle)
("s-M-`" . popper-toggle-type))
:init
(setq popper-reference-buffers
'("\\*Messages\\*"
"Output\\*$"
help-mode
compilation-mode
"Warning"
"Backtrace"
))
(popper-mode +1))