2 Commits c84c0a7902 ... a536ecc278

Autore SHA1 Messaggio Data
  Fred Gilham a536ecc278 Summary commit 1 mese fa
  Fred Gilham b309e6d5b7 fix following verse references (from search) and cross references 1 mese fa
1 ha cambiato i file con 231 aggiunte e 205 eliminazioni
  1. 231 205
      bible.el

+ 231 - 205
bible.el

@@ -82,7 +82,7 @@
 (global-eldoc-mode -1)
 
 ;;;; Requirements
-(require 'cl-lib)
+(require 'cl-lib) ; Required by `dom' and `shr', might as well use it.
 (require 'dom)
 (require 'shr)
 (require 'menu+ nil t) ; If you have it, it looks nice.
@@ -187,7 +187,6 @@ See `bible--display-lemma-hebrew'."
 
 (defcustom bible-hebrew-lexicon-short
   "StrongsRealHebrew"
-;;  "StrongsHebrew"
   "Lexicon used for displaying definitions of Hebrew words in tooltips."
   :type '(string :tag "Lexicon module (e.g. \"StrongsRealHebrew\")")
   :local nil
@@ -334,8 +333,8 @@ See `bible--display-lemma-hebrew'."
 
 ;;;;; Misc key bindings
 
-(define-key bible-map "T" 'bible-select-text)
-(define-key bible-map "C" 'bible-select-commentary)
+(define-key bible-map "T" 'bible-select-text-module)
+(define-key bible-map "C" 'bible-select-commentary-module)
 (define-key bible-map "w" 'bible-toggle-word-study)
 (define-key bible-map "l" 'bible-toggle-red-letter)
 
@@ -457,12 +456,12 @@ See `bible--display-lemma-hebrew'."
 
 ;;;;; Module choice keymaps.
 (defconst bible-text-map (make-keymap))
-(define-key bible-text-map [mouse-1] 'bible-pick-text)
-(define-key bible-text-map (kbd "RET") 'bible-pick-text)
+(define-key bible-text-map [mouse-1] 'bible-pick-text-module)
+(define-key bible-text-map (kbd "RET") 'bible-pick-text-module)
 
 (defconst bible-commentary-map (make-keymap))
-(define-key bible-commentary-map [mouse-1] 'bible-pick-commentary)
-(define-key bible-commentary-map (kbd "RET") 'bible-pick-commentary)
+(define-key bible-commentary-map [mouse-1] 'bible-pick-commentary-module)
+(define-key bible-commentary-map (kbd "RET") 'bible-pick-commentary-module)
 
 
 ;;;; Variable definitions
@@ -635,7 +634,7 @@ to all of them.")
 
 ;;;;; Book / chapter
 
-(defvar-local bible--current-book (assoc "Genesis" bible--books)
+(defvar-local bible--current-book-entry (assoc "Genesis" bible--books)
   "Current book data (name . chapter).")
 
 (defvar-local bible--current-book-name "Genesis"
@@ -731,6 +730,8 @@ Mostly in Psalms, like `Of David' or the like.")
 (defvar-local bible-search-range-this-query nil)
 (defvar-local bible-search-matches 0)
 
+(defvar bible-reference-buffer nil)
+
 ;;;;; Variables used in constructing cross-references.
 (defvar-local bible-current-xref-book nil)
 (defvar-local bible-current-xref-chapter nil)
@@ -749,18 +750,20 @@ Mostly in Psalms, like `Of David' or the like.")
 (defun bible-next-search-item ()
   "Go to next item in list of found verses."
   (interactive)
-  (search-forward-regexp bible--verse-regexp))
+  (search-forward-regexp bible--verse-regexp nil t))
 
 (defun bible-previous-search-item ()
   "Go to previous item in list of found verses."
   (interactive)
-  (search-backward-regexp bible--verse-regexp))
+  (when (search-backward-regexp bible--verse-regexp nil t)
+    (beginning-of-line)))
 
 (defun bible-toggle-display-xml ()
   "Toggle XML display."
   (interactive)
   (setq-local bible-debugme (not bible-debugme))
-  (bible--display))
+  (bible--display)
+  (goto-char (point-min)))
 
 (defun bible-toggle-text-direction ()
   "Switch between left-to-right and right-to-left text direction."
@@ -782,96 +785,101 @@ Mostly in Psalms, like `Of David' or the like.")
 
 ;;;;; Commands (interactive)
 
-(defun bible-open (&optional buffer book-name chapter verse module)
+;;;###autoload
+(defun bible-open (&optional book-name chapter verse module buffer)
   "Create and open a `bible' buffer.
 Optional arguments BOOK-NAME, CHAPTER and VERSE, when supplied, give the
 starting verse reference for the buffer. If no optional location
 arguments are supplied, Genesis 1:1 is used. Optional argument MODULE
-specifies the module to use."
+specifies the module to use. Optional argument BUFFER will use that
+buffer instead of creating a new one."
   (interactive)
   (with-current-buffer (or buffer (get-buffer-create "*bible*"))
     (bible)
     (when module (setq-local bible-text module))
     (setq-local bible-buffer-type 'text
                 mode-name (concat "Text " bible-text))
-    (bible--set-location
+    (bible--set-location 
      (assoc (or book-name "Genesis") bible--books)
      (or chapter 1)
-     verse)
+     (or verse 1))
     (cl-pushnew (current-buffer) bible--text-buffers)
     (set-window-buffer (get-buffer-window (current-buffer)) (current-buffer))))
 
-(defun commentary-open (&optional buffer book-name chapter verse module)
+(defun commentary-open (&optional book-name chapter verse module buffer)
   "Create and open a `commentary' buffer.
 Optional argument MODULE specifies the commentary module to use.
 Optional arguments BOOK-NAME, CHAPTER and VERSE, when supplied, give the
 starting verse reference for the buffer. If no optional location
-arguments are supplied, Genesis 1:1 is used."
+arguments are supplied, Genesis 1:1 is used.
+Optional argument BUFFER gives a buffer into which to render the text."
   (interactive)
   (let ((old-buffer (current-buffer)))
     (unless old-buffer (error "No current buffer! How did this happen!"))
     (with-current-buffer (or buffer (get-buffer-create "*comm*"))
       (bible)
-      (when module (setq-default bible-commentary module))
+      (when module
+        (setq-local bible-commentary module))
       (setq-local bible-buffer-type 'commentary
-                  bible-associated-buffer (cl-first bible--text-buffers)
-                  bible-text (default-value 'bible-commentary)
-                  mode-name (concat "Commentary " bible-text))
+                  bible-text bible-commentary
+                  mode-name (concat "Commentary " bible-text)
+                  ;; This is used for chasing cross-references. 
+                  bible-associated-buffer (cl-first bible--text-buffers))
       (bible--set-location
        (assoc (or book-name "Genesis") bible--books)
        (or chapter 1)
-       verse)
+       (or verse 1))
       (cl-pushnew (current-buffer) bible--commentary-buffers)
       (set-window-buffer (get-buffer-window (current-buffer)) (current-buffer)))))
 
 ;;;;;; Navigation
 
 (defun bible--do-set-location (book chapter &optional verse)
-  (setq-local bible--current-book book)
-  (setq-local bible--current-book-name (car book))
+  (setq-local bible--current-book-name book)
   (setq-local bible--current-chapter chapter)
-  (bible--display verse))
+  (bible--display (or verse 1)))
 
 (defun bible--set-location (book chapter &optional verse)
-  "Set the BOOK, CHAPTER and optionally VERSE of the active `bible' buffer."
+  "Set the BOOK, CHAPTER and optionally VERSE of the active `bible' buffer.
+If there are synchronized buffers, set their locations as well."
   (let ((buffer (current-buffer)))
-    (bible--do-set-location book chapter verse)
+    (setq-local bible--current-book-entry book)
+    (bible--do-set-location (car book) chapter (or verse 1))
+    ;; Handle synchronized buffers.
     (when (cl-find buffer bible--synced-buffers)
-      (save-excursion
-        (dolist (buf bible--synced-buffers)
-          (unless (eq buf buffer)
-            (with-current-buffer buf
-              (bible--do-set-location book chapter verse))))))))
+      (dolist (buf bible--synced-buffers)
+        (unless (eq buf buffer)
+          (with-current-buffer buf
+            (bible--do-set-location (car book) chapter (or verse 1))))))))
 
 (defun bible-next-chapter ()
   "Page to the next chapter for the active `bible' buffer and 
 for any synchronized buffers."
   (interactive)
-  (let* ((book-chapters (cdr bible--current-book))
+  (let* ((book-chapters (cdr bible--current-book-entry))
          (chapter (min book-chapters (1+ bible--current-chapter))))
-    (bible--set-location bible--current-book chapter)))
+    (bible--set-location bible--current-book-entry chapter)))
 
 (defun bible-previous-chapter ()
   "Page to the previous chapter for the active `bible' buffer and
 for any synchronized buffers."
   (interactive)
-  (bible--set-location bible--current-book (max 1 (1- bible--current-chapter))))
-
-(defun bible-next-word ()
-  "Move forward a word, taking into account the relevant text properties."
-  (interactive)
-  (unless (eobp)
-    (let ((next-change (text-property-search-forward 'strong nil nil t)))
-      (when next-change
-        (goto-char (1- (prop-match-end next-change)))))))
-
-(defun bible-previous-word ()
-  "Move back a word, taking into account the relevant text properties."
-  (interactive)
-  (unless (bobp)
-    (let ((previous-change (text-property-search-backward 'strong)))
-      (when previous-change
-        (goto-char (prop-match-beginning previous-change))))))
+  (let ((chapter (max 1 (1- bible--current-chapter))))
+    (bible--set-location bible--current-book-entry chapter)))
+
+(defun bible-next-word (next-word)
+  "Move forward a word, taking into account the relevant text properties.
+Note that we stay on the word so that clicking or hitting return will
+bring up the term dispplay for that word."
+  (interactive (list (unless (eobp) (text-property-search-forward 'strong nil nil t))))
+  (when next-word (goto-char (1- (prop-match-end next-word)))))
+
+(defun bible-previous-word (previous-word)
+  "Move back a word, taking into account the relevant text properties.
+Note that we stay on the word so that clicking or hitting return will
+bring up the term dispplay for that word."
+  (interactive (list (unless (bobp) (text-property-search-backward 'strong))))
+  (when previous-word (goto-char (prop-match-beginning previous-word))))
 
 ;;;;;; Select Location
 
@@ -891,42 +899,43 @@ for any synchronized buffers."
       (?3 (setq book-data (cons (concat "III" (substring book-data-string 1)) (cdr book-data)))))
     (bible--set-location book-data chapter)))
 
+
 (defun bible-select-chapter ()
   "Ask user for a new chapter for the current `bible' buffer."
   (interactive)
-  (let* ((book-chapters (cdr bible--current-book))
+  (let* ((book-chapters (cdr bible--current-book-entry))
          (chapter (string-to-number 
                    (completing-read 
                     "Chapter [1]: " 
                     (bible--list-number-range 1 book-chapters) nil t nil nil "1"))))
     (when chapter
-      (bible--set-location bible--current-book chapter))))
+      (bible--set-location bible--current-book-entry chapter))))
 
 ;;;;;; Choose modules, either by keystroke or by choosing from a list.
 
-(defun bible-pick-text ()
+(defun bible-pick-text-module ()
   "Select a text from a list. Re-use the buffer listing the texts. Called
 by the menu item `Select Text'."
   (interactive)
   (let ((item (get-text-property (point) 'module)))
     (rename-buffer "*bible*" t)
-    (bible-open (current-buffer)
-                bible--current-book-name 
+    (bible-open bible--current-book-name 
                 bible--current-chapter 
-                1 
-                item)))
+                1
+                item
+                (current-buffer))))
 
-(defun bible-pick-commentary ()
+(defun bible-pick-commentary-module ()
   "Select a commentary from a list. Re-use the buffer listing the commentaries.
 Called by the menu item `Select Commentary'."
   (interactive)
   (let ((item (get-text-property (point) 'module)))
     (rename-buffer "*comm*" t)
-    (commentary-open (current-buffer)
-                     bible--current-book-name 
-                     bible--current-chapter 
+    (commentary-open bible--current-book-name
+                     bible--current-chapter
                      1
-                     item)))
+                     item
+                     (current-buffer))))
 
 (defun bible--new-window (name)
   "Open a new window and generate a new buffer with NAME.
@@ -936,7 +945,7 @@ Returns the new buffer."
   (other-window 1)
   (generate-new-buffer name))
 
-(defun bible-select-text (text)
+(defun bible-select-text-module (text)
   "Prompt for a new text module for the current `bible' buffer.
 Replace current text in buffer. With prefix argument or if called from a
 commentary window, use new buffer and new window."
@@ -946,13 +955,13 @@ commentary window, use new buffer and new window."
                              (bible--new-window "*bible*")
                            (current-buffer))
       (setq-local bible-text text)
-      (bible-open (current-buffer)
-                  bible--current-book-name 
-                  bible--current-chapter 
-                  1 
-                  text))))
+      (bible-open bible--current-book-name
+                  bible--current-chapter
+                  1
+                  text
+                  (current-buffer)))))
 
-(defun bible-select-commentary (commentary)
+(defun bible-select-commentary-module (commentary)
   "Promp for a new commentary module for the current `commentary' buffer.
 Replace current text in buffer. With prefix argument or if called from a
 text window, split window and put commentary in a new buffer in a new
@@ -963,11 +972,11 @@ window."
                              (bible--new-window "*comm*")
                            (current-buffer))
       (setq-local bible-commentary commentary)
-      (commentary-open (current-buffer)
-                       bible--current-book-name 
-                       bible--current-chapter 
-                       1 
-                       commentary))))
+      (commentary-open bible--current-book-name
+                       bible--current-chapter
+                       1
+                       commentary
+                       (current-buffer)))))
 
 ;;;;;; Toggles
 
@@ -996,18 +1005,26 @@ window."
       (setq-local bible--synced-p t))
     (force-mode-line-update)))
 
+;;(defun bible-split-display ()
+;;  "Copy the active `bible' buffer into a new buffer in another window."
+;;  (interactive)
+;;  (split-window-right)
+;;  (balance-windows)
+;;  (other-window 1)
+;;  (bible-open bible-text
+;;              bible--current-book-name
+;;              bible--current-chapter
+;;              1
+;;              (generate-new-buffer "*bible*")))
+
 (defun bible-split-display ()
   "Copy the active `bible' buffer into a new buffer in another window."
   (interactive)
-  (split-window-right)
-  (balance-windows)
-  (other-window 1)
-  (bible-open 
-   (generate-new-buffer "*bible*")
-   bible--current-book-name
-   bible--current-chapter
-   1
-   bible-text))
+  (bible-open bible--current-book-name
+              bible--current-chapter
+              1
+              bible-text
+              (bible--new-window "*bible*")))
 
 ;;;;;; Search helpers
 
@@ -1019,72 +1036,71 @@ window."
         (setq bible-search-range nil)
       (setq bible-search-range range))))
 
-(defun bible-search (query)
-  "Search for a QUERY: a word or phrase.
-Asks the user for type of search: either `lucene', `phrase', `regex'
-or `multiword'.  `lucene' is the default search.
-`lucene' mode requires an index to be built using the `mkfastmod' program."
-  (interactive "sBible Search: ")
+(defun bible-search (query searchmode)
+  "Search for a QUERY with search mode SEARCHMODE.
+Searches are done using the diatheke search modes. See diatheke for 
+more information.
+First ask for the query and then ask the user for search mode: either
+`lucene', `phrase', `regex' or `multiword'.  `lucene' is the default search.
+`lucene' mode requires an index to be built for the module being searched
+using the `mkfastmod' program."
+  (interactive (let ((query (read-string "Query: ")))
+                 (if (> (length query) 0)
+                     (list query (completing-read "Search Mode: " '("lucene" "phrase" "regex" "multiword") nil t "lucene"))
+                   (list nil nil))))
   (when (> (length query) 0)
-    (let ((searchmode (completing-read "Search Mode: " '("lucene" "phrase" "regex" "multiword") nil t "lucene")))
-      (bible--open-search query searchmode (buffer-local-value 'bible-text (current-buffer))))))
-
-(defvar-local bible-search-reference-buffer nil)
-
-(defun bible-follow-verse ()
-  "Follow the hovered verse in a bible search mode buffer.
+    (setq bible-reference-buffer (current-buffer))
+    (bible--open-search query searchmode (buffer-local-value 'bible-text (current-buffer)))))
+
+
+(defun bible--lookup-name (name)
+  "Find the canonical book entry for NAME in bible--books. First check in
+the bible--books list to see if NAME is the canonical name. If not,
+check if NAME is an abbreviation. If so, look up the abbreviation and
+get the canonical name from there. Once we have the canonical name, use
+that to look up the book entry."
+  (or (cl-find name 
+               bible--books :key #'car :test #'string-equal-ignore-case)
+      (cl-find (alist-get name bible--book-name-abbreviations nil nil #'string-equal-ignore-case)
+               bible--books :key #'car :test #'string-equal-ignore-case)))
+
+(defun bible-follow-verse (verse-ref)
+  "Follow VERSE-REF obtained from a bible search mode buffer.
 Create a new `bible' buffer positioned at the selected verse."
-  (interactive)
-  (let* ((text (thing-at-point 'line t))
-         book
-         chapter
-         verse)
-    (when (string-match bible--verse-regexp text)
-      (setq text (match-string 0 text))
-      (string-match "I?I?I? ?[A-Z]?[a-z]* " text)
-      (setq book (match-string 0 text))
-      (string-match "[0-9]?[0-9]?[0-9]?:" text)
-      (setq chapter (substring (match-string 0 text) 0 (1- (length (match-string 0 text)))))
-      (string-match ":[0-9]?[0-9]?[0-9]?" text)
-      (setq verse (substring (match-string 0 text) 1))
-      (unless bible-search-reference-buffer
-        (setq-local bible-search-reference-buffer (generate-new-buffer "*bible*")))
-      (bible-open bible-search-reference-buffer
-                  (string-trim book)
-                  (string-to-number chapter)
-                  (string-to-number verse)
-                  bible-text))))
-
-(defun bible-follow-xref ()
-  "Follow the hovered verse in a bible term or commentary buffer.
+  (interactive (list (thing-at-point 'line t)))
+  (when (string-match bible--verse-regexp verse-ref)
+    (let* ((ref-string (match-string 0 verse-ref))
+           (book (when (string-match "I?I?I? ?[A-Z]?[a-z]* " ref-string)
+                   (string-trim (match-string 0 ref-string))))
+           (chapter (when (string-match "[0-9]?[0-9]?[0-9]?:" ref-string)
+                      (string-to-number 
+                       (substring ref-string (match-beginning 0) (1- (match-end 0))))))
+           (verse (when (string-match ":[0-9]?[0-9]?[0-9]?" ref-string)
+                    (string-to-number (substring (match-string 0 ref-string) 1)))))
+      (pop-to-buffer bible-reference-buffer)
+      (bible--set-location (assoc book bible--books) chapter verse))))
+
+(defun bible-follow-xref (verse-ref)
+  "Follow VERSE-REF in a bible term or commentary buffer.
 Create a new `bible' buffer positioned at the specified verse.
 Handle abbreviations."
-  (interactive)
-  (let ((xref (get-text-property (point) 'xref)))
-    (when xref
-      (let ((verse-ref (split-string xref))
-            book-abbrev
-            chapter-verse)
-        (cond ((= (length verse-ref) 2) ; Mat 5 or the like
-               (setq book-abbrev (car verse-ref)
-                     chapter-verse (split-string (cadr verse-ref) ":")))
-              ((= (length verse-ref) 3) ; II Cor 3:17 or the like
-               (setq book-abbrev (concat (car verse-ref) " " (cadr verse-ref))
-                     chapter-verse (split-string (caddr verse-ref) ":"))))
-        ;; Use book abbreviation if present or try whatever is in verse-ref.
-        (let ((book (or (alist-get book-abbrev
-                                   bible--book-name-abbreviations
-                                   nil
-                                   nil
-                                   #'string-equal-ignore-case)
-                        (car verse-ref)))
-              (chapter (car chapter-verse))
-              (verse (cadr chapter-verse)))
-          (bible-open bible-associated-buffer 
-                      (string-trim book)
-                      (string-to-number chapter)
-                      (string-to-number verse)
-                      (default-value 'bible-text)))))))
+  (interactive (list (split-string (get-text-property (point) 'xref))))
+  (when verse-ref
+    (let* (book-abbrev
+           chapter-verse)
+      (cond ((= (length verse-ref) 2)   ; Mat 5 or the like
+             (setq book-abbrev (cl-first verse-ref)
+                   chapter-verse (split-string (cadr verse-ref) ":")))
+            ((= (length verse-ref) 3)   ; II Cor 3:17 or the like
+             (setq book-abbrev (concat (cl-first verse-ref) " " (cl-second verse-ref))
+                   chapter-verse (split-string (cl-third verse-ref) ":")))
+            (t (error "Invalid verse ref %s" verse-ref)))
+      ;; Use book abbreviation if present or try whatever is in verse-ref.
+      (let* ((book-entry (bible--lookup-name book-abbrev))
+             (chapter (string-to-number (cl-first chapter-verse)))
+             (verse (string-to-number (cl-second chapter-verse))))
+        (pop-to-buffer (or bible-associated-buffer (cl-first bible--text-buffers)))
+        (bible--set-location book-entry chapter verse)))))
 
 
 ;;;;;; User visible actions.
@@ -1092,17 +1108,20 @@ Handle abbreviations."
 ;; These can be called interactively if you know the Strong's number
 ;; you want to look up.
 
+;;;###autoload
 (defun bible-term-hebrew (term)
   "Query user for a Strong's Hebrew Lexicon TERM."
   (interactive "sTerm: ")
   (bible--open-term-hebrew term))
 
+;;;###autoload
 (defun bible-term-greek (term)
   "Query user for a Strong's Greek Lexicon TERM."
   (interactive "sTerm: ")
   (bible--open-term-greek term))
 
 ;; Interactively insert a verse into an arbitrary current buffer.
+;;;###autoload
 (defun bible-insert ()
   "Query user to select a verse for insertion into the current buffer."
   (interactive)
@@ -1296,12 +1315,15 @@ Massage output so various cross references are usable. Returns string."
 Returns a string that is intended to be displayed in a tooltip.
 Uses short lexicon (e.g. StrongsRealHebrew or StrongsRealGreek)."
   (when (string-match "[0-9]+" lemma)
-    (bible--remove-module-name 
-     lexicon 
-     ;; Get rid of unnecessary strongs codes at the beginning.
-     (replace-regexp-in-string
-      ".*[0-9]+ [0-9]+ " ""
-      (bible--lex-query (concat (match-string 0 lemma)) lexicon)))))
+    (let ((string
+           (bible--remove-module-name 
+            lexicon 
+            ;; Get rid of unnecessary strongs codes at the beginning. This
+            ;; differs between lexicon versions.
+            (replace-regexp-in-string
+             ".*[0-9]+: [0-9]+. " ""
+             (bible--lex-query (concat (match-string 0 lemma)) lexicon)))))
+      string)))
 
 (defun bible--lookup-lex (lex)
   "Look up lexical item LEX. This is used for tooltips.
@@ -1680,7 +1702,7 @@ If optional argument VERSE is supplied, set cursor at verse."
         (bible--insert-domnode-recursive (dom-by-tag html-dom-tree 'body))
         (goto-char (point-min))))
     (save-excursion
-      (let ((search-string (concat " *" (car bible--current-book) " " (number-to-string bible--current-chapter) ":")))
+      (let ((search-string (concat " *" (car bible--current-book-entry) " " (number-to-string bible--current-chapter) ":")))
         ;; Delete <Book Ch:> at beginning of verse, just leave verse number.
         (while (re-search-forward search-string nil t)
           (replace-match "")
@@ -1714,11 +1736,12 @@ If optional argument VERSE is supplied, set cursor at verse."
                                 (" ?" . "? ")
                                 (" !" . "! ")
                                 ("“ " . "“")
+                                (" ”" . "”")
                                 ("‘ " . "‘")
                                 (" ’" . "’")
-                                (". ”" . ".”")
-                                ("? ”" . "?”"))
-                              nil (point-min) (point-max)))
+;;                                (". ”" . ".”")
+                                ("? ”" . "?”")) 
+                             nil (point-min) (point-max)))
     ;; Get rid of multiple consecutive spaces.
     (save-excursion
       (while (re-search-forward "  *" nil t) ; More than one space in a row
@@ -1732,8 +1755,8 @@ If optional argument VERSE is supplied, set cursor at verse."
       (setq mode-name (replace-regexp-in-string " Morph" "" mode-name)))
     (force-mode-line-update))
     ;; If optional verse specification go to that verse.
-    (when verse
-      (re-search-forward (concat " ?" (number-to-string verse)) nil t)))
+  (when verse 
+    (re-search-forward (concat " ?" (number-to-string verse)) nil t 1)))
 
 
 ;;;; Modules (Bible texts, commentaries)
@@ -1796,47 +1819,47 @@ If optional argument VERSE is supplied, set cursor at verse."
       (erase-buffer)
       (setq-local tab-stop-list '(25))
       (dolist (text bible--texts)
-        (let ((name (string-trim (car text)))
-              (description (string-trim-left (cadr text))))
-          (insert
-           (propertize (string-trim name)
-                       'face 'bold
-                       'module name
-                       'help-echo (concat "Select " name)
-                       'keymap bible-text-map))
-          (move-to-tab-stop)
+        (let ((name (string-trim (cl-first text)))
+              (description (string-trim-left (cl-second text))))
+          (insert (propertize (string-trim name)
+                              'face 'bold
+                              'module name
+                              'help-echo (concat "Select " name)
+                              'keymap bible-text-map))
+          (insert (propertize " " 'display '(space :align-to 20)))
           (insert (format "%s\n" description)))))
     (goto-char (point-min))
     (pop-to-buffer (current-buffer) nil t)))
 
+
 (defun bible-display-available-commentaries ()
   "Display available modules, allow user to select."
   (interactive)
-  (bible--get-biblical-modules) ; Make sure lists are fresh.
+  (bible--get-biblical-modules)         ; Make sure lists are fresh.
   (with-current-buffer (get-buffer-create " Commentaries")
     (bible-text-select-mode)
     (let ((buffer-read-only nil))
       (erase-buffer)
-      (setq-local tab-stop-list '(25))
       (dolist (commentary bible--commentaries)
-        (let ((name (string-trim (car commentary)))
-              (description (string-trim-left (cadr commentary))))
-          (insert
-           (propertize (string-trim name)
-                       'face 'bold
-                       'module name
-                       'help-echo (concat "Select " name)
-                       'keymap bible-commentary-map))
-          (move-to-tab-stop)
+        (let ((name (string-trim (cl-first commentary)))
+              (description (string-trim-left (cl-second commentary))))
+          (insert (propertize (string-trim name)
+                              'face 'bold
+                              'module name
+                              'help-echo (concat "Select " name)
+                              'keymap bible-commentary-map))
+          (insert (propertize " " 'display '(space :align-to 22)))
           (insert (format "%s\n" description)))))
     (goto-char (point-min))
     (pop-to-buffer (current-buffer) nil t)))
 
+
+
 
 ;;;; Bible Searching
 
 (defun bible--open-search (query searchmode module)
-  "Open a search buffer of QUERY using SEARCHMODE in module MODULE."
+  "Open a search buffer of QUERY using SEARCHMODE, getting values from BUFFER."
   (let ((results (string-trim (replace-regexp-in-string
                                "Entries .+?--" ""
                                (bible--diatheke-search query searchmode "plain" module)))))
@@ -1891,6 +1914,9 @@ If optional argument VERSE is supplied, set cursor at verse."
       (bible--insert-domnode-recursive (dom-by-tag html-dom-tree 'body)))
     (goto-char (point-min))
     (save-excursion
+      ;; Highlight verse numbers.
+      (while (re-search-forward bible--verse-regexp nil t)
+        (add-face-text-property (match-beginning 0) (match-end 0) '(:foreground "purple")))
       ;; Remove module name from buffer.
       (while (re-search-forward (concat "^.*" module ".*$") nil t)
         (replace-match ""))
@@ -1901,39 +1927,39 @@ If optional argument VERSE is supplied, set cursor at verse."
 
 ;;;; Terms (lemmas, morphemes)
 (defun bible--get-lemma (language strongs)
-  "Get the lemma from lexicon for LANGUAGE for strong's term STRONGS.
-Used to display lemmas in mode lines. Assumes that StrongsHebrew
-and StrongsGreek lexicons have been installed."
+  "Get the lemma from shorter lexicon for LANGUAGE for term STRONGS.
+Used to display lemmas in mode lines. Assumes that StrongsHebrew and
+StrongsGreek lexicons, or lexicons with compatible output, have been
+installed."
   (let ((lemma-entry
          (pcase language
            ('hebrew
-            ;; Use Strong's Hebrew lexicon to look up Hebrew lemma.
-            (bible--lex-query strongs "StrongsHebrew" ))
+            ;; Use shorter Hebrew lexicon to look up Hebrew lemma.
+            (bible--lex-query strongs bible-hebrew-lexicon-short))
            ('greek
-            ;; Use Strong's Greek lexicon to look up Greek lemma.
-            (bible--lex-query strongs "StrongsGreek")))))
+            ;; Use shorter Greek lexicon to look up Greek lemma.
+            (bible--lex-query strongs bible-greek-lexicon-short)))))
     (unless (equal lemma-entry "")
-      ;; Entry will look like <num>: <num>. <lemma> <definition>. Get
-      ;; rid of everything before and after <lemma>.
-      (let* ((lemma-line (split-string lemma-entry))
-             (lemma (caddr lemma-line)))
-        lemma))))
-
-(defun bible--display-greek ()
-  "Display Greek term.
+      ;; Entry will look something like 
+      ;; <num>: <num>. <lemma> <definition>.
+      ;; Get rid of everything before and after <lemma>.
+      (let* ((lemma-line (split-string lemma-entry)))
+        (cl-third lemma-line)))))
+
+
+(defun bible--display-greek (term)
+  "Display Greek TERM..
 This command is run by clicking on text, not directly by the user."
-  (interactive)
-  (let ((item (car (split-string (get-text-property (point) 'strong)))))
-    ;; Remove "strong:G" prefix
-    (bible--open-term-greek (replace-regexp-in-string "strong:G" "" item))))
+  (interactive (list (car (split-string (get-text-property (point) 'strong)))))
+  ;; Remove "strong:G" prefix
+  (bible--open-term-greek (replace-regexp-in-string "strong:G" "" term)))
 
-(defun bible--display-hebrew ()
-  "Display Hebrew term.
+(defun bible--display-hebrew (term)
+  "Display Hebrew TERM.
 This command is run by clicking on text, not directly by the user."
-  (interactive)
-  (let ((item (car (split-string (get-text-property (point) 'strong)))))
-    ;; Remove "strong:H" prefix and any alphabetic suffixes.
-    (bible--open-term-hebrew (replace-regexp-in-string "strong:H" "" item))))
+  (interactive (list (car (split-string (get-text-property (point) 'strong)))))
+  ;; Remove "strong:H" prefix and any alphabetic suffixes.
+  (bible--open-term-hebrew (replace-regexp-in-string "strong:H" "" term)))
 
 ;;(defun bible-display-morphology (morph)
 ;; ;; REVIEW: Do something here? (FMG 5-Mar-2026)