Bunch of miscellaneous changes

This commit is contained in:
Ian Keane 2024-09-18 19:00:11 -04:00
parent 4fd402bfd4
commit 75350cb528

View file

@ -37,9 +37,9 @@ To get started, run =C-c C-v t=
(require 'package) (require 'package)
(setq package-archives (setq package-archives
'(("melpa" . "https://melpa.org/packages/") '(("melpa" . "https://melpa.org/packages/")
("org" . "https://orgmode.org/elpa/") ("org" . "https://orgmode.org/elpa/")
("elpa" . "https://elpa.gnu.org/packages/"))) ("elpa" . "https://elpa.gnu.org/packages/")))
(package-initialize) (package-initialize)
;; Initialize use-package on non-linux platforms ;; Initialize use-package on non-linux platforms
@ -49,7 +49,7 @@ To get started, run =C-c C-v t=
(require 'use-package) (require 'use-package)
(setq use-package-always-ensure t) (setq use-package-always-ensure t)
(package-refresh-contents) ;; (package-refresh-contents)
(use-package savehist (use-package savehist
:init :init
@ -110,6 +110,7 @@ Eventually I'll set this up so that all these directories are set in the config
(ian/ensure-directory "~/notes/roam") (ian/ensure-directory "~/notes/roam")
(ian/ensure-directory "~/notes/deft") (ian/ensure-directory "~/notes/deft")
(ian/ensure-directory "~/notes/code") (ian/ensure-directory "~/notes/code")
(ian/ensure-directory "~/notes/work")
(ian/ensure-directory "~/.config/emacs/video") (ian/ensure-directory "~/.config/emacs/video")
(ian/ensure-directory "~/.config/emacs/audio") (ian/ensure-directory "~/.config/emacs/audio")
@ -127,20 +128,25 @@ Eventually I'll set this up so that all these directories are set in the config
"Eval the region if anything is selected, otherwise eval the whole buffer." "Eval the region if anything is selected, otherwise eval the whole buffer."
(interactive) (interactive)
(if mark-active (if mark-active
(eval-region (region-beginning) (region-end)) (eval-region (region-beginning) (region-end))
(eval-buffer))) (eval-buffer)))
(defun ian/conditional-imenu () (defun ian/conditional-imenu ()
"Call `consult-org-heading` in Org mode, otherwise `consult-imenu`." "Call `consult-org-heading` in Org mode, otherwise `consult-imenu`."
(interactive) (interactive)
(if (eq major-mode 'org-mode) (if (eq major-mode 'org-mode)
(consult-org-heading) (consult-org-heading)
(consult-imenu))) (consult-imenu)))
(defun ian/reload-config () (defun ian/reload-config ()
"Reload the Emacs configuration." "Reload the Emacs configuration."
(interactive) (interactive)
(load-file user-init-file)) (load-file user-init-file))
(defun ian/open-from-project-root (filename)
"Open a file from the root of the current Projectile project."
(interactive)
(find-file (expand-file-name filename (projectile-project-root))))
#+end_src #+end_src
** Evil-want-keybinding ** Evil-want-keybinding
Setting this in the :init of evil doesn't work for some reason. It has to be early in the file Setting this in the :init of evil doesn't work for some reason. It has to be early in the file
@ -155,15 +161,16 @@ Setting this in the :init of evil doesn't work for some reason. It has to be ear
:config :config
;; Global settings (defaults) ;; Global settings (defaults)
(setq doom-themes-enable-bold t ; if nil, bold is universally disabled (setq doom-themes-enable-bold t ; if nil, bold is universally disabled
doom-themes-enable-italic t) ; if nil, italics is universally disabled doom-themes-enable-italic t) ; if nil, italics is universally disabled
;; Enable flashing mode-line on errors ;; Enable flashing mode-line on errors
(setq doom-themes-treemacs-theme "doom-atom") ; use "doom-colors" for less minimal icon theme (setq doom-themes-treemacs-theme "doom-atom") ; use "doom-colors" for less minimal icon theme
(doom-themes-treemacs-config) (doom-themes-treemacs-config)
;; Corrects (and improves) org-mode's native fontification. ;; Corrects (and improves) org-mode's native fontification.
(doom-themes-org-config)) (doom-themes-org-config))
(set-frame-font "DejaVu Sans Mono 16") ;; (set-frame-font "DejaVu Sans Mono 16")
(add-to-list 'default-frame-alist
'(font . "DejaVu Sans Mono-16"))
;; (load-theme 'doom-oceanic-next t) ;; (load-theme 'doom-oceanic-next t)
(use-package base16-theme) (use-package base16-theme)
@ -283,6 +290,7 @@ Setting this in the :init of evil doesn't work for some reason. It has to be ear
:diminish :diminish
:config :config
(evil-set-undo-system 'undo-tree) (evil-set-undo-system 'undo-tree)
(setq undo-tree-history-directory-alist '(("." . "~/.config/emacs/undo")))
(global-undo-tree-mode 1)) (global-undo-tree-mode 1))
@ -692,12 +700,14 @@ I know these could be bound on a per-package basis, but since this is my primary
;; Org mode ;; Org mode
"o" '(:ignore t :which-key "org") "o" '(:ignore t :which-key "org")
"ol" '(org-store-link :which-key "Store link") "ol" '(org-store-link :which-key "Store link")
"oc" '(org-capture :which-key "Capture")
"oC" '(org-capture-goto-target :which-key "Goto Capture") "oC" '(org-capture-goto-target :which-key "Goto Capture")
"oo" '(org-open-at-point :which-key "Open link") "oo" '(org-open-at-point :which-key "Open link")
"ot" '(org-babel-tangle :which-key "Tangle") "ot" '(org-babel-tangle :which-key "Tangle")
"oy" '(+org/export-to-clipboard :which-key "Export to clipboard") "oy" '(+org/export-to-clipboard :which-key "Export to clipboard")
"oY" '(+org/export-to-clipboard-as-rich-text :which-key "Export to clipboard (rich)") "oY" '(+org/export-to-clipboard-as-rich-text :which-key "Export to clipboard (rich)")
"oc" '(:ignore t :which-key "Capture")
"ocn" '(ian/capture-to-notes-org :which-key "Capture to local notes")
"oct" '(ian/capture-to-todo-org :which-key "Capture to local todo")
"oe" '(:ignore t :which-key "export") "oe" '(:ignore t :which-key "export")
"oeh" '(org-html-export-to-html :which-key "Export Org to HTML") "oeh" '(org-html-export-to-html :which-key "Export Org to HTML")
"oa" '(:ignore t :which-key "attach") "oa" '(:ignore t :which-key "attach")
@ -723,9 +733,12 @@ I know these could be bound on a per-package basis, but since this is my primary
;; Reference buffers ;; Reference buffers
"r" '(:ignore t :which-key "reference buffers") "r" '(:ignore t :which-key "reference buffers")
"rs" '(scratch-buffer :which-key "Scratch") "rs" '(scratch-buffer :which-key "Scratch")
"rm" '(view-echo-area-messages :which-key "Messages") "rm" '(view-echo-area-messages :which-key "Messages")
"rc" '(view-lossage :which-key "Commands History") "rc" '(view-lossage :which-key "Commands History")
"rn" '((lambda () (interactive) (ian/open-from-project-root "notes.org")) :which-key "Notes")
"rt" '((lambda () (interactive) (ian/open-from-project-root "todo.org")) :which-key "Todo")
"rl" '((lambda () (interactive) (find-file "~/notes/work/time.org")) :which-key "Time Log")
;; Shell ;; Shell
"s" '(:ignore t :which-key "shell") "s" '(:ignore t :which-key "shell")
@ -846,6 +859,151 @@ I know these could be bound on a per-package basis, but since this is my primary
(setq org-todo-keywords '((sequence "TODO(t)" "NEXT(n)" "EVENT(e)" "|" "DONE(d!)" "CANCELLED(c@)"))) (setq org-todo-keywords '((sequence "TODO(t)" "NEXT(n)" "EVENT(e)" "|" "DONE(d!)" "CANCELLED(c@)")))
#+end_src #+end_src
** Capture templates
#+begin_src emacs-lisp
(defun ian/capture-to-notes-org ()
"Capture the current region (if selected) or a link to the point into 'notes.org' at the top of the Projectile project directory."
(interactive)
(let* ((selected-text (if (use-region-p)
(buffer-substring-no-properties (mark) (point))
nil))
(file-path (buffer-file-name))
(project-root (projectile-project-root))
(notes-file (expand-file-name "notes.org" project-root))
(link (format "[[file:%s::%d][Link to %s::%d]]\n\n"
file-path
(line-number-at-pos)
(file-name-nondirectory file-path)
(line-number-at-pos)))
(template (if selected-text
(concat "* %?\n:PROPERTIES:\n:CAPTURED: %U\n:END:\n#+BEGIN_SRC\n" selected-text "\n#+END_SRC\n\n" link)
(concat "* %?\n:PROPERTIES:\n:CAPTURED: %U\n:END:\n" link)))
(org-capture-entry `("r" "Capture" entry
(file ,notes-file)
,template)))
(org-capture nil "r")
(with-current-buffer (find-file-noselect notes-file)
(save-buffer))))
(defun ian/capture-to-todo-org ()
"Capture the current region (if selected) or a link to the point into 'todo.org' at the top of the Projectile project directory."
(interactive)
(let* ((selected-text (if (use-region-p)
(buffer-substring-no-properties (mark) (point))
nil))
(file-path (buffer-file-name))
(project-root (projectile-project-root))
(notes-file (expand-file-name "todo.org" project-root))
(link (format "[[file:%s::%d][Link to %s::%d]]\n\n"
file-path
(line-number-at-pos)
(file-name-nondirectory file-path)
(line-number-at-pos)))
(template (if selected-text
(concat "* %?\n:PROPERTIES:\n:CAPTURED: %U\n:END:\n#+BEGIN_SRC\n" selected-text "\n#+END_SRC\n\n" link)
(concat "* %?\n:PROPERTIES:\n:CAPTURED: %U\n:END:\n" link)))
(org-capture-entry `("r" "Capture" entry
(file ,notes-file)
,template)))
(org-capture nil "r")
(with-current-buffer (find-file-noselect notes-file)
(save-buffer))))
(defun checklist-daily-capture ()
"Generates daily checklist content."
(concat "* Daily Checklist\n"
"- [ ] Brush teeth\n"
"- [ ] Stretch\n"
"- [ ] Clean 20m\n"))
(defun weekday-specific-daily-capture (day-of-week)
"Generate checklist content which is specific to the weekday"
(cond
((string= day-of-week "Monday")
(concat ""))
((string= day-of-week "Tuesday")
(concat "* Tuesday Checklist\n"
"- [ ] Rollout trash\n"))
((string= day-of-week "Thursday")
(concat
"- [ ] Water Houseplants\n"))
((string= day-of-week "Friday")
(concat ""))
((string= day-of-week "Saturday")
(concat ""))
((string= day-of-week "Sunday")
(concat "* Sunday Checklist\n"
"- [ ] Start Sourdough\n"))
))
(defun workout-daily-capture (day-of-week)
"Generate workout table content based on DAY-OF-WEEK."
(concat
"* Workout\n"
"| Exercise | Weight | Sets | Reps | Notes |\n"
"|----------+--------+------+------+-------|\n"
(cond
((string= day-of-week "Monday")
(concat
"| VSQ | | | | |\n"
"| CGB | | | | |\n"
"| BTN | | | | |\n"
"| OHP | | | | |\n"
"| SC | | | | |\n"))
((string= day-of-week "Tuesday")
(concat
"| RDL | | | | |\n"
"| ROW | | | | |\n"
"| WCHP | | | | |\n"
"| CU | | | | |\n"))
((string= day-of-week "Thursday")
(concat
"| BP | | | | |\n"
"| JMP | | | | |\n"
"| SQ | | | | |\n"
"| SC | | | | |\n"))
((string= day-of-week "Friday")
(concat
"| DL | | | | |\n"
"| WPU | | | | |\n"
"| CU | | | | |\n"))
(t "Rest Day\n"))))
(defun diet-daily-capture ()
"Capture for calorie tracking"
(concat
"* Diet\n"
"- Weight :: \n"
"| Food | Calories | Total |\n"
"|------|----------|-------|\n"
"| | | |\n"))
(defun spending-daily-capture ()
"Capture for spending"
(concat
"* Spending\n"
"| Expense | Price | Total |\n"
"|---------|-------|-------|\n"
"| | | |\n"))
(setq org-roam-dailies-capture-templates
`(("d" "Daily Routine" entry
,(concat
"* Scheduled Today\n\n"
"%(weekday-specific-daily-capture \"%<%A>\")\n"
"%(checklist-daily-capture)\n"
"%(workout-daily-capture \"%<%A>\")\n"
"%(diet-daily-capture)\n"
"%(spending-daily-capture)\n")
:target (file+head "%<%Y-%m-%d>.org" "#+title: %<%Y-%m-%d>\n"))))
#+end_src
#+RESULTS:
| d | Daily Routine | entry | * Scheduled Today |
* Project management * Project management
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package projectile) ; todo config inside use-package (use-package projectile) ; todo config inside use-package
@ -1131,11 +1289,11 @@ Uses the external fish program to provide fish-style completions to eshell etc
#+end_src #+end_src
* Git * Git
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package magit)
(use-package magit-todos)
(use-package git-gutter+ (use-package git-gutter+
:diminish) :diminish)
(global-git-gutter+-mode t) (global-git-gutter+-mode t)
(use-package magit)
(use-package magit-todos)
(setq magit-display-buffer-function 'magit-display-buffer-same-window-except-diff-v1) (setq magit-display-buffer-function 'magit-display-buffer-same-window-except-diff-v1)
(use-package git-timemachine) (use-package git-timemachine)
@ -1293,6 +1451,8 @@ Scrutinize which processes are gumming up emacs
- init popup buffer binding? spc r i? - init popup buffer binding? spc r i?
- org-roam buffer in popup (follow) - org-roam buffer in popup (follow)
- [[https://old.reddit.com/r/emacs/comments/o04it0/share_your_prettifysymbolsalist/][prettify-symbols-mode]] - [[https://old.reddit.com/r/emacs/comments/o04it0/share_your_prettifysymbolsalist/][prettify-symbols-mode]]
- create 'context' keybinding
- map smerge mode
** Embark ** Embark
- open file in other window - open file in other window
@ -1402,3 +1562,43 @@ variables and their documentations).
- [[https://www.youtube.com/watch?v=0C16LLHGYzk&t=1882s][Converting a literate config to guix home]] - [[https://www.youtube.com/watch?v=0C16LLHGYzk&t=1882s][Converting a literate config to guix home]]
- [[https://www.youtube.com/playlist?list=PLEoMzSkcN8oM-kA19xOQc8s0gr0PpFGJQ][Emacs mail playlist]] - [[https://www.youtube.com/playlist?list=PLEoMzSkcN8oM-kA19xOQc8s0gr0PpFGJQ][Emacs mail playlist]]
- [[https://www.youtube.com/watch?v=qk2Is_sC8Lk][Embark]] - [[https://www.youtube.com/watch?v=qk2Is_sC8Lk][Embark]]
** Annoyances
- set require-final-newline = nil
- fix gitgutter behavior
- remove extra line file modifying behavior
- fix missing snippets in note-taking mode
- always open treemacs from most recent window
- prevent :wq from killing frame
*** Ediff
- vertical
- no new frame
- bind magit-ediff-compare
#+begin_src emacs-lisp
(setq ediff-window-setup-function #'ediff-setup-windows-plain)
#+end_src
- bind ediff two files
- fix fuzzy searching for functions
- bind =SPC -= to dired-jump
- fix markdown-mode (doesn't start with .md files automatically)
- bind magit-log-buffer-file (handles selection-based history)
- adaptive wrap (plus fix visual-line-mode to always load)
- [[https://elpa.gnu.org/packages/adaptive-wrap.html]]
- install / configure consult-org-roam
- map default-text-scale-increase/decrease (better than regular text scaling)
- set default-text-scale-amount to 5 instead of 10
- map outline-toggle-children in tf mode
- map ripgrep in parent dir
- map ripgrep in (dired select)
- add .git to ripgrep ignore
- fix vterm
- make the popup frame-wide
- fix spc v t
- maybe just make spc tab open shell and exclude it from ace managed windows
- make eshell pretty
- when toggling shell, enter insert mode
- migrate to wezterm, impelement popup term
- look into letting org fold blocks or folding bracket blocks in general cases
- try (add-hook 'magit-post-refresh-hook 'git-gutter+:refresh)
- make treemacs enter always open in most recent buffer
- add meeting log to reference reaches