From e8048fa548281832f014355408d0152d9ecf16a3 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Thu, 28 Dec 2023 14:16:03 -0600 Subject: [PATCH] fixing a lot of little things --- README.org | 109 +++++++++++++++++++--------- init.el | 206 ++++++++++++++++------------------------------------- 2 files changed, 137 insertions(+), 178 deletions(-) diff --git a/README.org b/README.org index efaff3e7..adfdad9e 100644 --- a/README.org +++ b/README.org @@ -208,7 +208,12 @@ I will also add my personal scripts to emacs' PATH Let's also set org-mode as the scratch buffer mode #+begin_src emacs-lisp (setq initial-major-mode 'org-mode) -(setq initial-scratch-message "#+TITLE: SCRATCH\n#+DESCRIPTION: This buffer is for temporary things") +(setq initial-scratch-message "#+TITLE: SCRATCH\n#+DESCRIPTION: This buffer is for temporary things\n") +#+end_src + +This is to make sure Emacs doesn't add a newline in files that I don't want it to. A lot of major modes change this which is fine since this mostly only applies to some small specific files that mostly only open in =fundamental-mode=. +#+begin_src emacs-lisp +(setq require-final-newline nil) #+end_src ** Let's bootstrap straight.el @@ -598,6 +603,11 @@ This evil-collection package includes a lot of other evil based things. "open the emacs config to edit" (interactive) (find-file (expand-file-name "README.org" user-emacs-directory))) + + (defun chris/find-videos () + (interactive) + (find-file (expand-file-name "vids" "~"))) + (defun chris/open-bible () "find a bible to open" (interactive) @@ -677,6 +687,7 @@ This evil-collection package includes a lot of other evil based things. "tl" '(toggle-truncate-lines :which-key "truncate lines") "ts" '(ispell :which-key "spell check") "ff" '(find-file :which-key "find file") + "fv" '(chris/find-videos :which-key "find file") "fb" '(chris/open-bible :which-key "find bible book") "fr" '(consult-recent-file :which-key "recent file") "fs" '(save-buffer :which-key "save") @@ -930,7 +941,7 @@ Part of this config includes some special capture templates for my work as a you :jump-to-captured t :empty-lines 1) ("l" "TFC Lesson" plain - (function chris/org-caputre-denote-file-path) + (function chris/org-capture-denote-file-path) (file ".templates/lessontemplate.org") :prepend nil :jump-to-captured t @@ -981,7 +992,6 @@ Part of this config includes some special capture templates for my work as a you (sequence "[ ](T)" "[-](S)" "[?](W)" "|" "[X](D)")) org-agenda-files '("~/docs/todo/todo.org" - "~/docs/notes/nvtfc_social_media.org" "~/dev/lumina/TODO.org" "~/dev/tfcconnection/TODO.org" "~/docs/notes/lessons/") @@ -1157,7 +1167,7 @@ Part of this config includes some special capture templates for my work as a you "q" 'org-edit-src-abort)) #+end_src -We need to create a lesson capture function to find our lesson files differently each time we run our TFC plan capture. This is the most unique part of my capture template. This function uses =org-roam-node-read= to pick the lesson file that I need to add my lesson plan to. This way the lesson itself is created before the plan. +We need to create a lesson capture function to find our lesson files differently each time we run our TFC plan capture. This is the most unique part of my capture template. This function uses =denote= to pick the lesson file that I need to add my lesson plan to. This way the lesson itself is created before the plan. #+begin_src emacs-lisp (defun chris/denote-capture-lesson-file () "Function to return the lesson file that is needed for TFC plan capture and move to correct position for plan insertion" @@ -1172,7 +1182,7 @@ We need to create a lesson capture function to find our lesson files differently (goto-char (point-min)) (search-forward "* PLAN"))) -(defun chris/org-caputre-denote-file-path () +(defun chris/org-capture-denote-file-path () "Function returning the file placement using denote for capture" (interactive) (denote-subdirectory) @@ -1249,7 +1259,7 @@ Here we are going to add org-roam. This is a note-takers paradise by adding an a Basic Org-Roam setup. We select the directory and the basic width of the Org-Roam buffer so that it doesn't take too much space on my laptop. We also want to exclude certain files from Org-Roam. All files are synced between machines using syncthing and kept in a version history. I'd like to exclude the version history from Org-Roam using =org-roam-file-exclude-regexp=. We also need to setup some capture templates to use some specific setups with my journalling. These include a space for my [[file:../../org/homework_for_life.org][Homework For Life]], tasks for the day, and how I can love on my family. -#+BEGIN_SRC emacs-lisp +#+BEGIN_SRC emacs-lisp :tangle no (use-package org-roam :after org :ensure t @@ -1396,6 +1406,9 @@ In order to use it, I need to go to http://localhost:8080 #+END_SRC *** Denote +:PROPERTIES: +:ID: 20231224T062442.525926 +:END: I might try switching to and using denote instead of Org Roam. Denote doesn't use a DB and instead uses a clever naming scheme to make sure that all files are connectable. The one downside of denote is that the links are specific to denote instead of plain org links. #+begin_src emacs-lisp (use-package denote @@ -1406,19 +1419,49 @@ I might try switching to and using denote instead of Org Roam. Denote doesn't us denote-modules '(project xref ffap) denote-known-keywords '("emacs" "bible" "jesus" "tfc" "lesson" "it" "dev")) + (defun chris/denote-rename-buffer-with-prefix (&optional buffer) + "Rename denote buffers with title and then with the prefix D>." + (if (denote-file-is-note-p (buffer-file-name)) + (progn (denote-rename-buffer-with-title) + (rename-buffer (concat "D> " (buffer-name (or buffer (current-buffer) title :unique))))))) + + (denote-rename-buffer-mode +1) + (setq denote-rename-buffer-function 'chris/denote-rename-buffer-with-prefix) + (setq denote-org-front-matter - "#+TITLE: %1$s -#+AUTHOR: Chris Cochrun -#+CREATED: %2$s -#+filetags: %3$s -#+identifier: %4$s -") + "#+TITLE: %1$s\n#+AUTHOR: Chris Cochrun\n#+CREATED: %2$s\n#+filetags: %3$s\n#+identifier: %4$s\n") + + (add-hook 'dired-mode-hook 'denote-dired-mode) + + (defvar denote-faces--file-name-regexp + (concat "\\(?1:[0-9]\\{8\\}\\)\\(?2:T[0-9]\\{6\\}\\)" + "\\(?:\\(?3:==\\)\\(?4:[[:alnum:][:nonascii:]=]*?\\)\\)?" + "\\(?:\\(?5:--\\)\\(?6:[[:alnum:][:nonascii:]-]*?\\)\\)?" + "\\(?:\\(?7:__\\)\\(?8:[[:alnum:][:nonascii:]_-]*?\\)\\)?" + "\\(?9:\\..*\\)?$") + "Regexp of file names for fontification.") + + + (defconst denote-faces-file-name-keywords + `((,(concat "[\t\s]+" denote-faces--file-name-regexp) + (1 'denote-faces-date) + (2 'denote-faces-time) + (3 'denote-faces-delimiter nil t) + (4 'denote-faces-signature nil t) + (5 'denote-faces-delimiter nil t) + (6 'denote-faces-title nil t) + (7 'denote-faces-delimiter nil t) + (8 'denote-faces-keywords nil t) + (9 'denote-faces-extension nil t ))) + "Keywords for fontification of file names.") + :general (chris/leader-keys :states 'normal :keymaps 'override "nf" 'denote-open-or-create - "nb" 'denote-backlinks)) + "nb" 'denote-backlinks + "nk" 'denote-keywords-add)) #+end_src *** Org-Superstar @@ -2025,15 +2068,6 @@ Optional BACKEND must be `re-reveal' or a backend derived from it." file))) #+end_src -*** Ox-Spectacle -Spectacle.js is another beautiful slideshow builder that org can export to using ox-spectacle. -#+begin_src emacs-lisp :tangle no -(use-package ox-spectacle - :config - - ) -#+end_src - *** ox-zola I'm going to start a website for my own ramblings, tutorials and links. To do this I'll likely use Zola since it's built in Rust. #+begin_src emacs-lisp :tangle no @@ -2046,16 +2080,6 @@ I'm going to start a website for my own ramblings, tutorials and links. To do th ** AI GPTEL is a package that uses chatGPT to get some text generation in org-mode -#+begin_src emacs-lisp :tangle no -(use-package gptel - :ensure t - :commands (gptel-send - gptel) - :config - (setq gptel-default-mode 'org-mode - gptel-api-key "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")) -#+end_src - *** Ellama Idk, let's try this i guess @@ -4387,7 +4411,7 @@ Let's use pdf-tools for a lot better interaction with pdfs. (defun chris/setup-nov-mode (interactive) - (visual-fill-column-mode) + (visual-fill-column-mode +1) (display-line-numbers-mode -1) (variable-pitch-mode +1) (setq visual-fill-column-width 130 @@ -5018,14 +5042,29 @@ I am going to try and use LanguageTool to fix grammatical issues. #+end_src ** MyBible +:PROPERTIES: +:ID: 20231221T141041.368526 +:END: MyBible is going to be set of functions for creating and using a bible app within Emacs. Let's see if we can't make it work. #+begin_src emacs-lisp (defvar bible-books '(genesis exodus leviticus numbers dueteronomy joshua judges ruth 1-samuel 2-samuel 1-kings 2-kings 1-chronicles 2-chronicles ezra nehemiah esther job psalms proverbs ecclesiastes song-of-solomon isaiah jeremiah lamentations ezekiel daniel hosea joel amos obadiah jonah micah nahum habakkuk zephaniah haggai zechariah malachi matthew mark luke john acts romans 1-corinthians 2-corinthians galatians ephesians phillipians colossians 1-thessalonians 2-thessalonians 1-timothy 2-timothy titus philemon hebrews james 1-peter 2-peter 1-john 2-john 3-john jude revelation)) +(defun chris/org-get-tree (&optional file) + "Get the tree of the current org buffer or optionally a file." + (interactive) + (let ((list nil)))) + +(defun chris/make-chapters () + (interactive) + (org-narrow-to-element) + (search-forward "chapter") + (beginning-of-line) + (insert "** ")) + (defun chris/find-verse () (interactive) - (find-file "/home/chris/docs/bibles/esv.org") - (list (imenu-choose-buffer-index))) + (org-ql-select "/home/chris/docs/bibles/esv.org" "Jesus") + (goto-char (cdr (imenu-choose-buffer-index)))) #+end_src ** Performance diff --git a/init.el b/init.el index bef90eed..455ed96e 100644 --- a/init.el +++ b/init.el @@ -90,7 +90,9 @@ (add-to-list 'exec-path "/home/chris/.cargo/bin") (setq initial-major-mode 'org-mode) -(setq initial-scratch-message "#+TITLE: SCRATCH\n#+DESCRIPTION: This buffer is for temporary things") +(setq initial-scratch-message "#+TITLE: SCRATCH\n#+DESCRIPTION: This buffer is for temporary things\n") + +(setq require-final-newline nil) (dolist (path load-path) (when (string-match-p "/nix/store/[a-z0-9]\\{32\\}-emacs-packages-deps.*" path) @@ -301,6 +303,11 @@ "open the emacs config to edit" (interactive) (find-file (expand-file-name "README.org" user-emacs-directory))) + + (defun chris/find-videos () + (interactive) + (find-file (expand-file-name "vids" "~"))) + (defun chris/open-bible () "find a bible to open" (interactive) @@ -380,6 +387,7 @@ "tl" '(toggle-truncate-lines :which-key "truncate lines") "ts" '(ispell :which-key "spell check") "ff" '(find-file :which-key "find file") + "fv" '(chris/find-videos :which-key "find file") "fb" '(chris/open-bible :which-key "find bible book") "fr" '(consult-recent-file :which-key "recent file") "fs" '(save-buffer :which-key "save") @@ -622,7 +630,7 @@ much faster. The hope is to also make this a faster version of imenu." :jump-to-captured t :empty-lines 1) ("l" "TFC Lesson" plain - (function chris/org-caputre-denote-file-path) + (function chris/org-capture-denote-file-path) (file ".templates/lessontemplate.org") :prepend nil :jump-to-captured t @@ -673,7 +681,6 @@ much faster. The hope is to also make this a faster version of imenu." (sequence "[ ](T)" "[-](S)" "[?](W)" "|" "[X](D)")) org-agenda-files '("~/docs/todo/todo.org" - "~/docs/notes/nvtfc_social_media.org" "~/dev/lumina/TODO.org" "~/dev/tfcconnection/TODO.org" "~/docs/notes/lessons/") @@ -861,7 +868,7 @@ much faster. The hope is to also make this a faster version of imenu." (goto-char (point-min)) (search-forward "* PLAN"))) -(defun chris/org-caputre-denote-file-path () +(defun chris/org-capture-denote-file-path () "Function returning the file placement using denote for capture" (interactive) (denote-subdirectory) @@ -915,135 +922,6 @@ much faster. The hope is to also make this a faster version of imenu." (org-super-agenda-mode +1) (setq org-super-agenda-header-map nil)) -(use-package org-roam - :after org - :ensure t - :init - (setq org-roam-v2-ack t) - :config - (setq org-roam-directory "~/docs/notes" - org-roam-buffer-width 0.25 - org-roam-list-files-commands '(fd rg find fdfind) - org-roam-file-exclude-regexp '(".stversion/|logseq/|presentations/|.stfolder/|.*~.*|.*sync.*|bibles/") - org-roam-db-location "~/.emacs.d/org-roam.db" - org-roam-completion-everywhere t - org-roam-dailies-directory "dailies/" - org-roam-capture-templates - '(("d" "default" entry "\n* %?" - :if-new (file+head "${slug}.org" - "#+TITLE: ${title}\n#+AUTHOR: Chris Cochrun\n#+CREATED: %<%D - %I:%M %p>\n#+CATEGORY: todo\n\n%a") - :unnarrowed t) - ("b" "bible" entry "\n* %?" - :if-new (file+head "${slug}.org" - "#+TITLE: ${title}\n#+AUTHOR: Chris Cochrun\n#+CREATED: %<%D - %I:%M %p>\n#+CATEGORY: bible\n- tags :biblestudy:%^G\n\n") - :unnarrowed t) - ("l" "TFC Lesson" plain (file ".templates/lessontemplate.org") - :if-new (file+head "lessons/${slug}.org" - "#+TITLE: ${title}\n#+AUTHOR: Chris Cochrun\n#+CREATED: %<%D - %I:%M %p>\n#+CATEGORY: lesson\n") - :unnarrowed t)) - org-roam-dailies-capture-templates - '(("d" "daily" plain "%?" - :immediate-finish nil - :file-name "%<%Y-%m-%d>" - :head "#+TITLE: %<%Y-%m-%d>\n#+AUTHOR: Chris Cochrun\n#+CREATED: %<%D - %I:%M %p>\n\n* HFL\n* Tasks\n* Family\n** How Do I Love Abbie?" - :target (file+head "%<%Y-%m-%d>.org" - "#+TITLE: %<%Y-%m-%d>\n#+AUTHOR: Chris Cochrun\n#+CREATED: %<%D - %I:%M %p>\n\n* HFL\n* Tasks\n* Family\n** How Do I Love Abbie?\n* Bible") - :unnarrowed t - ) - ("b" "biblical daily" plain "%?" - :file-name "%<%Y-%m-%d>-bib" - :target (file+head "%<%Y-%m-%d>-bib.org" "#+TITLE: %<%Y-%m-%d> - Biblical\n#+AUTHOR: Chris Cochrun\n#+CREATED: %<%D - %I:%M %p>\n\n* Notes") - :unnarrowed t) - ("m" "meeting" plain "%?" - :file-name "%<%Y-%m-%d>-meeting-${slug}" - :target (file+head "%<%Y-%m-%d>-meeting-${slug}.org" "#+TITLE: %<%Y-%m-%d> - ${slug} - #+AUTHOR: Chris Cochrun - #+CREATED: %<%D - %I:%M %p> - - * Attendees - - - - * Notes") - :unnarrowed t))) - - (setq org-roam-node-display-template - (concat "${title:*} " - (propertize "${tags:10}" 'face 'org-tag))) - - (defun chris/org-roam-node-create () - "Create an org roam node underneath this org node" - (interactive) - (+org/insert-item-below 1) - (org-id-get-create) - (org-roam-alias-add)) - (defun chris/org-roam-node-id-create () - "Make the basic org node and org roam one by adding an id and creating an alias" - (interactive) - (org-id-get-create) - (org-roam-alias-add)) - ;; (set-face-attribute 'magit-section-highlight nil :inherit 'variable-pitch) - -(defun chris/consult-ripgrep-files-with-matches (&optional dir initial) - "Use consult-find style to return matches with \"rg --file-with-matches \". No live preview." - (interactive "P") - (let ((consult-find-command "rg --null --ignore-case -g presentations --type org --max-columns=500 --no-heading --line-buffered --line-number . -e ARG OPTS")) - (consult-find dir initial))) - -(defun chris/org-roam-rg-search () - "Search org-roam directory using consult-ripgrep. With live-preview." - (interactive) - (let ((consult-ripgrep-command "rg --null --ignore-case --type org --line-buffered --color=always --max-columns=500 --no-heading --line-number . -e ARG OPTS")) - (consult-ripgrep org-roam-directory))) - -(defun chris/org-roam-rg-file-search () - "Search org-roam directory using consult-find with \"rg --file-with-matches \". No live preview." - (interactive) - (chris/consult-ripgrep-files-with-matches org-roam-directory)) - - -(defun chris/org-roam-refile-node-to-file () - "Take the node at point and refile it into a new org roam file" - (interactive) - (if (org-before-first-heading-p) - (message "Not in or on an org heading") - (save-excursion - ;; If inside heading contents, move the point back to the heading - ;; otherwise `org-agenda-get-some-entry-text' won't work. - (unless (org-on-heading-p) (org-previous-visible-heading 1)) - (let ((heading (substring-no-properties (thing-at-point 'line))) - (contents (substring-no-properties - (org-agenda-get-some-entry-text - (point-marker) - most-positive-fixnum))) - (node (concat heading contents))) - (message "Copied: %s" heading) - (kill-new node) - (org-roam-node-find) - (delete-line) - (newline) - (yank))))) - - (org-roam-setup) - :general - (chris/leader-keys - :states '(normal visual) - :keymaps 'override - "nf" '(org-roam-node-find :which-key "org roam ff") - "nr" 'org-roam-buffer-toggle - "ni" 'chris/org-roam-node-create - "nl" 'org-roam-node-insert - "nc" 'org-roam-capture - "nt" 'org-roam-dailies-goto-today - "ng" 'org-roam-graph - "na" 'org-roam-alias-add - "in" 'org-roam-node-insert - "ns" 'chris/org-roam-rg-search - "nA" 'chris/org-roam-node-id-create) - (chris/leader-keys - :states 'visual - :keymaps 'override - "in" 'org-roam-node-insert)) - (use-package websocket) (use-package org-roam-ui :after org-roam @@ -1061,19 +939,49 @@ much faster. The hope is to also make this a faster version of imenu." denote-modules '(project xref ffap) denote-known-keywords '("emacs" "bible" "jesus" "tfc" "lesson" "it" "dev")) + (defun chris/denote-rename-buffer-with-prefix (&optional buffer) + "Rename denote buffers with title and then with the prefix D>." + (if (denote-file-is-note-p (buffer-file-name)) + (progn (denote-rename-buffer-with-title) + (rename-buffer (concat "D> " (buffer-name (or buffer (current-buffer) title :unique))))))) + + (denote-rename-buffer-mode +1) + (setq denote-rename-buffer-function 'chris/denote-rename-buffer-with-prefix) + (setq denote-org-front-matter - "#+TITLE: %1$s -#+AUTHOR: Chris Cochrun -#+CREATED: %2$s -#+filetags: %3$s -#+identifier: %4$s -") + "#+TITLE: %1$s\n#+AUTHOR: Chris Cochrun\n#+CREATED: %2$s\n#+filetags: %3$s\n#+identifier: %4$s\n") + + (add-hook 'dired-mode-hook 'denote-dired-mode) + + (defvar denote-faces--file-name-regexp + (concat "\\(?1:[0-9]\\{8\\}\\)\\(?2:T[0-9]\\{6\\}\\)" + "\\(?:\\(?3:==\\)\\(?4:[[:alnum:][:nonascii:]=]*?\\)\\)?" + "\\(?:\\(?5:--\\)\\(?6:[[:alnum:][:nonascii:]-]*?\\)\\)?" + "\\(?:\\(?7:__\\)\\(?8:[[:alnum:][:nonascii:]_-]*?\\)\\)?" + "\\(?9:\\..*\\)?$") + "Regexp of file names for fontification.") + + + (defconst denote-faces-file-name-keywords + `((,(concat "[\t\s]+" denote-faces--file-name-regexp) + (1 'denote-faces-date) + (2 'denote-faces-time) + (3 'denote-faces-delimiter nil t) + (4 'denote-faces-signature nil t) + (5 'denote-faces-delimiter nil t) + (6 'denote-faces-title nil t) + (7 'denote-faces-delimiter nil t) + (8 'denote-faces-keywords nil t) + (9 'denote-faces-extension nil t ))) + "Keywords for fontification of file names.") + :general (chris/leader-keys :states 'normal :keymaps 'override "nf" 'denote-open-or-create - "nb" 'denote-backlinks)) + "nb" 'denote-backlinks + "nk" 'denote-keywords-add)) (use-package org-present :commands org-present @@ -3256,7 +3164,7 @@ targets." (defun chris/setup-nov-mode (interactive) - (visual-fill-column-mode) + (visual-fill-column-mode +1) (display-line-numbers-mode -1) (variable-pitch-mode +1) (setq visual-fill-column-width 130 @@ -3699,10 +3607,22 @@ interfere with the default `bongo-playlist-buffer'." (defvar bible-books '(genesis exodus leviticus numbers dueteronomy joshua judges ruth 1-samuel 2-samuel 1-kings 2-kings 1-chronicles 2-chronicles ezra nehemiah esther job psalms proverbs ecclesiastes song-of-solomon isaiah jeremiah lamentations ezekiel daniel hosea joel amos obadiah jonah micah nahum habakkuk zephaniah haggai zechariah malachi matthew mark luke john acts romans 1-corinthians 2-corinthians galatians ephesians phillipians colossians 1-thessalonians 2-thessalonians 1-timothy 2-timothy titus philemon hebrews james 1-peter 2-peter 1-john 2-john 3-john jude revelation)) +(defun chris/org-get-tree (&optional file) + "Get the tree of the current org buffer or optionally a file." + (interactive) + (let ((list nil)))) + +(defun chris/make-chapters () + (interactive) + (org-narrow-to-element) + (search-forward "chapter") + (beginning-of-line) + (insert "** ")) + (defun chris/find-verse () (interactive) - (find-file "/home/chris/docs/bibles/esv.org") - (list (imenu-choose-buffer-index))) + (org-ql-select "/home/chris/docs/bibles/esv.org" "Jesus") + (goto-char (cdr (imenu-choose-buffer-index)))) ;; Reduce rendering/line scan work for Emacs by not rendering cursors or regions ;; in non-focused windows.