From b8f7717e92fe87383bc86cae621a987b52baf7b1 Mon Sep 17 00:00:00 2001
From: Chris Cochrun <chris@cochrun.xyz>
Date: Fri, 21 Jun 2024 11:19:49 -0500
Subject: [PATCH] some modifications to bible stuff

---
 README.org | 34 ++++++++++++++------------
 bible.el   | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 init.el    | 35 ++++++++++++++++++++-------
 3 files changed, 114 insertions(+), 25 deletions(-)

diff --git a/README.org b/README.org
index af76ca63..90f8c1bf 100644
--- a/README.org
+++ b/README.org
@@ -12,10 +12,10 @@ Date: Sat, 27 Apr 2024 22:36:33 -0500
   - [[#fix-nixos][Fix NixOS]]
   - [[#spell-check][Spell Check]]
   - [[#proced][Proced]]
-  - [[#bluetooth][Bluetooth]]
   - [[#keep-folders-clean][Keep Folders Clean]]
   - [[#ligatures][Ligatures]]
   - [[#keybindings][Keybindings]]
+  - [[#bluetooth][Bluetooth]]
   - [[#org-mode][Org Mode]]
   - [[#ai][AI]]
   - [[#jinx][Jinx]]
@@ -309,7 +309,6 @@ All the icons is super pretty and needed for doom-modeline.
 Probably the prettiest and best modeline I've found.
 #+begin_src emacs-lisp
 (use-package doom-modeline
-  :ensure t
   :init
   (doom-modeline-mode 0)
   (setq doom-modeline-height 25
@@ -464,16 +463,6 @@ Let's turn auto update on for proced
 (setq proced-auto-update-flag t)
 #+end_src
 
-** Bluetooth
-I think I like this interface to controlling bluetooth the most
-#+begin_src emacs-lisp
-(use-package bluetooth
-  :after general
-  :general
-  (chris/leader-keys
-    "oT" 'bluetooth-list-devices))
-#+end_src
-
 ** Keep Folders Clean
 
 Let's use =no-littering= in order to stop emacs from filling all our folders with junk.
@@ -739,7 +728,7 @@ This evil-collection package includes a lot of other evil based things.
     "ss" '(consult-line :which-key "consult search")
     "sr" '(consult-ripgrep :which-key "consult ripgrep")
     "sd" '(dictionary-search :which-key "search the dictionary")
-    "sv" '(org-bible-find-verse-imenu :which-key "imenu")
+    "sv" '(org-bible-jump :which-key "imenu")
     "oP" '(proced :which-key "proced")
     "ov" '(vterm :which-key "vterm")
     "wo" '(other-window :which-key "other window")
@@ -803,6 +792,16 @@ This evil-collection package includes a lot of other evil based things.
     "C-<tab>" 'indent-for-tab-command))
 #+end_src
 
+** Bluetooth
+I think I like this interface to controlling bluetooth the most
+#+begin_src emacs-lisp
+(use-package bluetooth
+  :after general
+  :general
+  (chris/leader-keys
+    "oT" 'bluetooth-list-devices))
+#+end_src
+
 ** Org Mode
 Org-Mode needs to be loaded pretty high in the file so that we are ensuring things get picked up in the correct order. This has been a problem for me in the past so I prefer it right after setting some keybindings and then much later loading things like =roam= =super-agenda= and others.
 
@@ -1458,7 +1457,7 @@ I might try switching to and using denote instead of Org Roam. Denote doesn't us
 #+begin_src emacs-lisp
 (use-package denote
   :config
-  (require 'denote-org-dblock)
+  (require 'denote-org-extras)
   (setq denote-directory "/home/chris/docs/notes"
         denote-dired-directories '("/home/chris/docs/notes")
         denote-dired-directories-include-subdirectories t
@@ -3307,6 +3306,11 @@ Also here are some lisp specific stuff
            "gh" 'paredit-backward-slurp-sexp
            "C-l" 'paredit-forward
            "C-h" 'paredit-backward)
+  ('normal emacs-lisp-mode-map
+           "gl" 'paredit-forward-slurp-sexp
+           "gh" 'paredit-backward-slurp-sexp
+           "C-l" 'paredit-forward
+           "C-h" 'paredit-backward)
   ('normal lisp-shared-mode-map
            "gl" 'paredit-forward-slurp-sexp
            "gh" 'paredit-backward-slurp-sexp
@@ -3646,7 +3650,7 @@ Friar is a fennel repl in the awesome repl. It allows you to interact with Aweso
 #+end_src
 *** Clojure
 I'm gonnna dabble in using clojure for the website
-#+begin_src emacs-lisp :tangle no
+#+begin_src emacs-lisp
 ;; First install the package:
 (use-package flycheck-clj-kondo
   :ensure t)
diff --git a/bible.el b/bible.el
index 0383e601..c12648c7 100644
--- a/bible.el
+++ b/bible.el
@@ -1,5 +1,5 @@
 (defvar org-bible-directory "~/docs/bibles")
-(defvar org-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))
+(defvar org-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" "philipians" "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"))
 
 (defvar org-bible-default "~/docs/bibles/esv.org")
 (defvar org-bible-selected org-bible-default)
@@ -11,6 +11,74 @@
   (let ((location (list (imenu-choose-buffer-index))))
     (imenu-default-goto-function nil (cdr (car location)))))
 
+(defun org-bible-chapters (book)
+  "Get the chapters of the book in a list"
+  (save-excursion
+    (let ((book (org-bible-book-find book)))
+      (org-bible-children book))))
+
+(defun org-bible-verses (chapter book)
+  "Get the verses of the chapter in a list"
+  (save-excursion
+    (let ((chapter (org-bible-chapter-find chapter book)))
+      (message "chapter: %s" chapter)
+      (org-bible-children chapter))))
+
+(defun org-bible-children (item)
+  "Get the children of the current item in the form of a point"
+  (save-excursion
+    (org-with-wide-buffer
+     (goto-char item)
+     (when (org-goto-first-child)
+       (cl-loop collect (org-get-heading t t)
+                while (outline-get-next-sibling))))))
+
+(defun org-bible-chapter-find (chapter book)
+  (let ((book (concat "* " (string-replace "-" " " book))))
+    (org-with-wide-buffer
+     (save-excursion
+       (widen)
+       (goto-char 1)
+       (search-forward book)
+       (search-forward chapter)
+       (point)))))
+
+(defun org-bible-verse-find (verse chapter book)
+  (let ((book (concat "* " (string-replace "-" " " book))))
+    (org-with-wide-buffer
+     (save-excursion
+       (widen)
+       (goto-char 1)
+       (search-forward book)
+       (search-forward chapter)
+       (search-forward verse)
+       (point)))))
+
+(defun org-bible-book-find (book)
+  (let ((book (concat "* " (string-replace "-" " " book))))
+    (org-with-wide-buffer
+     (save-excursion (widen)
+                     (goto-char 1)
+                     (search-forward book)
+                     (point)))))
+      
+
+(defun org-bible-jump ()
+  "Jump to passage"
+  (interactive)
+  (with-current-buffer (find-file org-bible-selected)
+    (let* ((book (completing-read "Book: " org-bible-books))
+           (chapter (completing-read "Chapter: " (org-bible-chapters book)))
+           (verse (completing-read "Verse: " (org-bible-verses chapter book))))
+      (goto-char (org-bible-verse-find verse chapter book))
+      (beginning-of-line)
+      (pulsar-recenter-top))))
+
+(defun org-bible-select ()
+  "Pick a different bible that is formatted in org-mode"
+  (interactive)
+  (let ((bible (completing-read "Pick a bible version: " '("ESV" "CSB" "NASB"))))))
+
 ;; (define-minor-mode org-bible-mode
 ;;   "Toggles the org bible minor mode"
 ;;   nil
diff --git a/init.el b/init.el
index 96ed45e8..a4295a51 100644
--- a/init.el
+++ b/init.el
@@ -129,7 +129,6 @@
 (use-package all-the-icons)
 
 (use-package doom-modeline
-  :ensure t
   :init
   (doom-modeline-mode 0)
   (setq doom-modeline-height 25
@@ -228,12 +227,6 @@
 
 (setq proced-auto-update-flag t)
 
-(use-package bluetooth
-  :after general
-  :general
-  (chris/leader-keys
-    "oT" 'bluetooth-list-devices))
-
 (use-package no-littering)
 
 ;; no-littering doesn't set this by default so we must place
@@ -468,7 +461,7 @@
     "ss" '(consult-line :which-key "consult search")
     "sr" '(consult-ripgrep :which-key "consult ripgrep")
     "sd" '(dictionary-search :which-key "search the dictionary")
-    "sv" '(org-bible-find-verse-imenu :which-key "imenu")
+    "sv" '(org-bible-jump :which-key "imenu")
     "oP" '(proced :which-key "proced")
     "ov" '(vterm :which-key "vterm")
     "wo" '(other-window :which-key "other window")
@@ -531,6 +524,12 @@
     "TAB" 'indent-according-to-mode
     "C-<tab>" 'indent-for-tab-command))
 
+(use-package bluetooth
+  :after general
+  :general
+  (chris/leader-keys
+    "oT" 'bluetooth-list-devices))
+
 (setq lpr-command "lpr -o sides=two-sided-long-edge -# ")
 (defun chris/org-mode-setup ()
   (interactive)
@@ -1007,7 +1006,7 @@ much faster. The hope is to also make this a faster version of imenu."
 
 (use-package denote
   :config
-  (require 'denote-org-dblock)
+  (require 'denote-org-extras)
   (setq denote-directory "/home/chris/docs/notes"
         denote-dired-directories '("/home/chris/docs/notes")
         denote-dired-directories-include-subdirectories t
@@ -2453,6 +2452,11 @@ targets."
            "gh" 'paredit-backward-slurp-sexp
            "C-l" 'paredit-forward
            "C-h" 'paredit-backward)
+  ('normal emacs-lisp-mode-map
+           "gl" 'paredit-forward-slurp-sexp
+           "gh" 'paredit-backward-slurp-sexp
+           "C-l" 'paredit-forward
+           "C-h" 'paredit-backward)
   ('normal lisp-shared-mode-map
            "gl" 'paredit-forward-slurp-sexp
            "gh" 'paredit-backward-slurp-sexp
@@ -2669,6 +2673,19 @@ targets."
 (use-package fennel-mode
   :mode ("\\.fnl\\'" . fennel-mode))
 
+;; First install the package:
+(use-package flycheck-clj-kondo
+  :ensure t)
+
+;; then install the checker as soon as `clojure-mode' is loaded
+(use-package clojure-mode
+  :ensure t
+  :config
+  (require 'flycheck-clj-kondo))
+
+(use-package cider
+  :after clojure-mode)
+
 (use-package yaml-mode
   :mode ("\\.yml\\'" . yaml-mode))