Browse Source

Handle 'q tag better.

Fred Gilham 5 days ago
parent
commit
05ab278cd2
1 changed files with 96 additions and 44 deletions
  1. 96 44
      bible.el

+ 96 - 44
bible.el

@@ -220,9 +220,7 @@ See `bible--display-lemma-hebrew'."
 
 (defvar bible-mode-line-format
   '("%e" mode-line-front-space
-    mode-line-frame-identification mode-line-buffer-identification "   "
-;;    bible-text
-    "  "
+    mode-line-frame-identification mode-line-buffer-identification " "
     bible--current-book-name
     " "  (:eval (number-to-string bible--current-chapter))
     "  " (:eval (if bible--synced-p "Sync" ""))
@@ -233,22 +231,20 @@ See `bible--display-lemma-hebrew'."
 
 (defvar bible-search-mode-line-format
   '("%e" mode-line-front-space
-    mode-line-frame-identification mode-line-buffer-identification "   "
+    mode-line-frame-identification mode-line-buffer-identification " "
     bible-search-text-this-query " " bible-search-word-this-query " "
     (:eval (when bible-search-range-this-query (concat "<" bible-search-range-this-query "> ")))
     (:eval (number-to-string bible-search-matches)) " matches"
-    "  " mode-line-modes mode-line-misc-info
+    " " mode-line-modes mode-line-misc-info
     mode-line-end-spaces)
   "Mode line format for bible search buffers.")
 
 (defvar bible-term-mode-line-format
   '("%e" mode-line-front-space
-    mode-line-frame-identification mode-line-buffer-identification "   "
-;;    bible-term-language 
-;;    " " (:eval bible-term-lemma)
-    "  " mode-line-modes mode-line-misc-info
+    mode-line-frame-identification mode-line-buffer-identification " "
+    mode-line-modes mode-line-misc-info
     mode-line-end-spaces)
-  "Mode line format for bible search buffers.")
+  "Mode line format for bible term buffers.")
 
 
 ;;;; Modes
@@ -481,6 +477,11 @@ See `bible--display-lemma-hebrew'."
 (defvar bible--commentary-buffers nil
   "List of commentary buffers.")
 
+(defvar bible-buffer-type nil
+  "One of `bible', `commentary', `term', `select' or `search'. Identifies
+the type of buffer.")
+  
+
 (defvar-local bible-associated-buffer nil
   "Buffer associated with a given commentary buffer---used for 
 chasing cross-references.")
@@ -540,20 +541,28 @@ to all of them.")
     ("Josh" . "Joshua") ("Js" . "Joshua") ("Jos" . "Joshua")
     ("Judg" . "Judges") ("Jg" . "Judges") ("Jdg" . "Judges")
     ("Ru" . "Ruth") ("Rut" . "Ruth")
-    ("1 Sam" . "I Samuel") ("1 Samuel" . "I Samuel")  ("I Sa" . "I Samuel")   ("1 Sa" . "I Samuel")  ("1Sam" . "I Samuel")
-    ("2 Sam" . "II Samuel") ("2 Samuel" . "II Samuel") ("II Sa" . "II Samuel") ("2 Sa" . "II Samuel") ("2Sam" . "II Samuel")
-    ("1 Kgs" . "I Kings") ("1 Kings"  . "I Kings") ("I Ki"  . "I Kings") ("1 Ki" . "I Kings") ("1Ki" . "I Kings")
-    ("2 Kgs" . "II Kings") ("2 Kings"  . "II Kings") ("II Ki" . "II Kings") ("2 Ki" . "II Kings") ("2Ki" . "II Kings")
-    ("1 Chr" . "I Chronicles") ("1 Chronicles" . "I Chronicles") ("I Ch"  . "I Chronicles") ("1 Ch" . "I Chronicles")
-    ("2 Chr" . "II Chronicles") ("2 Chronicles" . "II Chronicles") ("II Ch" . "II Chronicles") ("2 Ch" . "II Chronicles")
+    ("1 Sam" . "I Samuel") ("1 Samuel" . "I Samuel")  ("I Sa" . "I Samuel")
+    ("1 Sa" . "I Samuel")  ("1Sam" . "I Samuel")
+    ("2 Sam" . "II Samuel") ("2 Samuel" . "II Samuel") ("II Sa" . "II Samuel")
+    ("2 Sa" . "II Samuel") ("2Sam" . "II Samuel")
+    ("1 Kgs" . "I Kings") ("1 Kings"  . "I Kings") ("I Ki"  . "I Kings")
+    ("1 Ki" . "I Kings") ("1Ki" . "I Kings")
+    ("2 Kgs" . "II Kings") ("2 Kings"  . "II Kings") ("II Ki" . "II Kings")
+    ("2 Ki" . "II Kings") ("2Ki" . "II Kings")
+    ("1 Chr" . "I Chronicles") ("1 Chronicles" . "I Chronicles")
+    ("I Ch"  . "I Chronicles") ("1 Ch" . "I Chronicles")
+    ("2 Chr" . "II Chronicles") ("2 Chronicles" . "II Chronicles")
+    ("II Ch" . "II Chronicles") ("2 Ch" . "II Chronicles")
     ("Ezr" . "Ezra")
     ("Neh"  . "Nehemiah") ("Ne"  . "Nehemiah")
     ("Esth"  . "Esther") ("Es"  . "Esther") ("Est"  . "Esther")
     ("Jb"  . "Job")
     ("Ps"  . "Psalms") ("Psa" . "Psalms")
     ("Prov" . "Proverbs") ("Pr"  . "Proverbs") ("Pro" . "Proverbs")
-    ("Eccl"  . "Ecclesiastes") ("Ec"  . "Ecclesiastes") ("Ecc"  . "Ecclesiastes")
-    ("Song"  . "Song of Solomon") ("So"  . "Song of Solomon") ("Sol"  . "Song of Solomon")
+    ("Eccl"  . "Ecclesiastes") ("Ec"  . "Ecclesiastes")
+    ("Ecc"  . "Ecclesiastes")
+    ("Song"  . "Song of Solomon") ("So"  . "Song of Solomon")
+    ("Sol"  . "Song of Solomon")
     ("Isa" . "Isaiah") ("Is"  . "Isaiah")
     ("Jer" . "Jeremiah") ("Je"  . "Jeremiah")
     ("Lam"  . "Lamentations") ("La"  . "Lamentations")
@@ -569,41 +578,55 @@ to all of them.")
     ("Hab"  . "Habakkuk") ("Ha"  . "Habakkuk")
     ("Zeph" . "Zephaniah") ("Zep" . "Zephaniah")
     ("Hag" . "Haggai")
-    ("Zech"  . "Zechariah") ("Ze"  . "Zechariah") ("Zac"  . "Zechariah") ;; Is the last one correct??
+    ("Zech"  . "Zechariah") ("Ze"  . "Zechariah")
+    ("Zac"  . "Zechariah") ; Is this one correct??
     ("Mal" . "Malachi")
 
     ;; New Testament
     ("Mt" . "Matthew") ("Mat" . "Matthew") ("Matt" . "Matthew")
     ("Mk" . "Mark") ("Mar" . "Mark")
     ("Lk" . "Luke") ("Luk" . "Luke")
-    ("Jn" . "John") ("Jo" . "John") ("Joh" . "John") 
+    ("Jn" . "John") ("Jo" . "John") ("Joh" . "John")
     ("Ac" . "Acts") ("Act" . "Acts")
     ("Rom" . "Romans") ("Ro" . "Romans")
-    ("1 Cor" . "I Corinthians") ("1 Corintihans" . "I Corinthians") ("I Co" . "I Corinthians") ("1 Co" . "I Corinthians")
+    ("1 Cor" . "I Corinthians") ("1 Corintihans" . "I Corinthians")
+    ("I Co" . "I Corinthians") ("1 Co" . "I Corinthians")
     ("ICor" . "I Corinthians") ("1Cor" . "I Corinthians")
-    ("2 Cor" . "II Corinthians") ("2 Corinthians" . "II Corinthians") ("II Co" . "II Corinthians") ("2 Co" . "II Corinthians")
+    ("2 Cor" . "II Corinthians") ("2 Corinthians" . "II Corinthians")
+    ("II Co" . "II Corinthians") ("2 Co" . "II Corinthians")
     ("IICor" . "II Corinthians") ("2Cor" . "II Corinthians")
     ("Gal" . "Galatians") ("Ga" . "Galatians")
     ("Eph" . "Ephesians")
     ("Phil" . "Philippians") ("Phl" . "Philippians")
     ("Col" . "Colossians")
-    ("1 Thess" . "I Thessalonians") ("1 Thessalonians" . "I Thessalonians") ("I Th" . "I Thessalonians") ("1 Th" . "I Thessalonians")
-    ("IThess" . "I Thessalonians") ("1Thes" . "I Thessalonians") ("1Thess" . "I Thessalonians")
-    ("2 Thess" . "II Thessalonians") ("2 Thessalonians" . "II Thessalonians") ("II Th" . "II Thessalonians") ("2 Th" . "II Thessalonians")
-    ("IIThess" . "II Thessalonians") ("2Thes" . "II Thessalonians") ("2Thess" . "II Thessalonians")
-    ("1 Tim" . "I Timothy") ("1 Timothy" . "I Timothy")   ("I Ti"  . "I Timothy")  ("1 Ti" . "I Timothy")  ("ITim" . "I Timothy")
+    ("1 Thess" . "I Thessalonians") ("1 Thessalonians" . "I Thessalonians")
+    ("I Th" . "I Thessalonians") ("1 Th" . "I Thessalonians")
+    ("IThess" . "I Thessalonians") ("1Thes" . "I Thessalonians")
+    ("1Thess" . "I Thessalonians")
+    ("2 Thess" . "II Thessalonians") ("2 Thessalonians" . "II Thessalonians")
+    ("II Th" . "II Thessalonians") ("2 Th" . "II Thessalonians")
+    ("IIThess" . "II Thessalonians") ("2Thes" . "II Thessalonians")
+    ("2Thess" . "II Thessalonians")
+    ("1 Tim" . "I Timothy") ("1 Timothy" . "I Timothy")
+    ("I Ti" . "I Timothy") ("1 Ti" . "I Timothy") ("ITim" . "I Timothy")
     ("1Tim" . "I Timothy")
-    ("2 Tim" . "II Timothy") ("2 Timothy" . "II Timothy") ("II Ti" . "II Timothy") ("2 Ti" . "II Timothy") ("IITim" . "II Timothy")
+    ("2 Tim" . "II Timothy") ("2 Timothy" . "II Timothy")
+    ("II Ti" . "II Timothy") ("2 Ti" . "II Timothy") ("IITim" . "II Timothy")
     ("2Tim" . "II Timothy")
     ("Tit" . "Titus")
     ("Phlm" . "Philemon") ("Phm" . "Philemon") ("Plm" . "Philemon")
     ("Heb" . "Hebrews") ("He" . "Hebrews")
     ("Jas" . "James") ("Ja" . "James") ("Jam" . "James")
-    ("1 Pet" . "I Peter") ("1 Peter" . "I Peter") ("I Pe" . "I Peter") ("1 Pe" . "I Peter") ("IPet" . "I Peter") ("1Pet" . "I Peter")
-    ("2 Pet" . "II Peter") ("2 Peter" . "II Peter") ("II Pe" . "II Peter") ("2 Pe" . "II Peter") ("IIPet" . "II Peter") ("2Pet" . "II Peter")
-    ("1 Jn" . "I John") ("1 John" . "I John") ("I Jo" . "I John") ("1 Jo" . "I John") ("IJohn" . "I John") ("1Jn" . "I John")
-    ("2 Jn" . "I John") ("2 John" . "II John") ("II Jo"  . "II John") ("2 Jo" . "II John") ("IIJohn" . "II John") ("2Jn" . "I John")
-    ("3 Jn" . "I John") ("3 John" . "III John") ("III Jo" . "III John") ("3 Jo" . "III John") ("IIIJohn" . "III John") ("3Jn" . "I John")
+    ("1 Pet" . "I Peter") ("1 Peter" . "I Peter") ("I Pe" . "I Peter")
+    ("1 Pe" . "I Peter") ("IPet" . "I Peter") ("1Pet" . "I Peter")
+    ("2 Pet" . "II Peter") ("2 Peter" . "II Peter") ("II Pe" . "II Peter")
+    ("2 Pe" . "II Peter") ("IIPet" . "II Peter") ("2Pet" . "II Peter")
+    ("1 Jn" . "I John") ("1 John" . "I John") ("I Jo" . "I John")
+    ("1 Jo" . "I John") ("IJohn" . "I John") ("1Jn" . "I John")
+    ("2 Jn" . "II John") ("2 John" . "II John") ("II Jo"  . "II John")
+    ("2 Jo" . "II John") ("IIJohn" . "II John") ("2Jn" . "II John")
+    ("3 Jn" . "III John") ("3 John" . "III John") ("III Jo" . "III John")
+    ("3 Jo" . "III John") ("IIIJohn" . "III John") ("3Jn" . "III John")
     ("Ju" . "Jude") ("Jde" . "Jude")
     ("Rev" . "Revelation of John") ("Re" . "Revelation of John"))
   "A-list of abbreviations for Bible books.")
@@ -766,6 +789,7 @@ specifies the module to use."
   (interactive)
   (with-current-buffer (or buffer (get-buffer-create "*bible*"))
     (bible)
+    (setq-local bible-buffer-type 'bible)
     (when module (setq-default bible-text module))
     (setq-local bible-text (default-value 'bible-text))
     (setq-local mode-name (concat "Text " bible-text))
@@ -785,8 +809,9 @@ arguments are supplied, Genesis 1:1 is used."
   (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 "*commentary*"))
+    (with-current-buffer (or buffer (get-buffer-create "*comm*"))
       (bible)
+      (setq-local bible-buffer-type 'commentary)
       (when module (setq-default bible-commentary module))
       (setq-local bible-associated-buffer old-buffer)
       (setq-local bible-text (default-value 'bible-commentary))
@@ -878,23 +903,47 @@ for any synchronized buffers."
 
 ;;;;;; Select modules
 
+;; REVIEW: Need to re-visit which of the following is called in which
+;;         mode. `bible-select-<xxxx>' should be called in <xxxx> mode
+;;         (i.e. text or commentary). It should be used for replacing
+;;         the current text/commentary and should not create a new
+;;         buffer. `bible-select-<xxxx>' uses the interface for
+;;         choosing texts or commentaries and should be available in
+;;         either mode. It will create a new buffer with the chosen
+;;         module in it. Commentaries have an `associated buffer'
+;;         against which its cross-references work and so I guess
+;;         there will have to be an identified current bible text
+;;         buffer to set this association. (FMG 31-Mar-2026)
+
 ;; Choose a module.
-(defun bible-pick-text (&optional module)
+(defun bible-pick-text (&optional module buffer)
   "Keymap action function---select text that the user chooses."
   (interactive)
   (let ((item (or module (get-text-property (point) 'module))))
-    (bible-open (current-buffer) bible--current-book-name bible--current-chapter 1 item)))
-
-(defun bible-pick-commentary (&optional module)
+    (bible-open
+     (or buffer (generate-new-buffer "*bible*"))
+     bible--current-book-name 
+     bible--current-chapter 
+     1 
+     item)))
+
+(defun bible-pick-commentary (&optional module buffer)
   "Keymap action function---select commentary that the user chooses.
 Use optional argument MODULE as commentary if given."
   (interactive)
-  (let ((item (or module (get-text-property (point) 'module))))
+  (let ((item (or module (get-text-property (point) 'module)))
+        (buffer (or buffer (generate-new-buffer "*comm*"))))
     (setq-local bible-commentary item)
+    (setq-local bible-buffer-type 'commentary)
     (split-window-right)
     (balance-windows)
     (other-window 1)
-    (commentary-open (generate-new-buffer "*commentary*") bible--current-book-name bible--current-chapter 1 item)))
+    (commentary-open 
+     buffer
+     bible--current-book-name 
+     bible--current-chapter 
+     1
+     item)))
 
 (defun bible-select-text ()
   "Ask user for a new text module for the current `bible' buffer."
@@ -903,7 +952,7 @@ Use optional argument MODULE as commentary if given."
     (unless (string= text "")
       (setq-default bible-text text)
       (setq-local bible-text text)
-      (bible-pick-text bible-text))))
+      (bible-pick-text bible-text (when (eq bible-buffer-type 'bible) (current-buffer))))))
 
 (defun bible-select-commentary ()
   "Ask user for a new commentary module for the current `bible' buffer."
@@ -911,7 +960,7 @@ Use optional argument MODULE as commentary if given."
   (let ((commentary (completing-read "Commentary: " bible--commentaries)))
     (unless (string= commentary "")
       (setq-local bible-commentary commentary)
-      (bible-pick-commentary bible-commentary))))
+      (bible-pick-commentary bible-commentary (when (eq bible-buffer-type 'commentary) (current-buffer))))))
 
 ;;;;;; Toggles
 
@@ -1546,9 +1595,12 @@ In processing subnodes, each case will prepend a space if it needs it."
                   (insert word)
                   (put-text-property start (point) 'face 'bold)
                   (add-face-text-property start (point) '(:foreground "orange"))))
-               ;; 'q is used for red letter.
+               ;; 'q is used for quotations (red letter and non-specific).
                ;; NASB Module uses 'seg to indicate OT quotations (and others?).
-               ((or 'body 'seg 'p 'q) (bible--insert-domnode-recursive subnode iproperties))
+               ((or 'body 'seg 'p 'q)
+                ;; Some modules use `marker' to indicate quotation marks. 
+                (when (dom-attr subnode 'marker) (insert (dom-attr subnode 'marker)))
+                (bible--insert-domnode-recursive subnode iproperties))
                ('l (bible--level-tag subnode))
                ;; REVIEW: divine name handling doesn't seem to work the same
                ;;         with all modules. (FMG 26-Mar-2026)