Jelajahi Sumber

More misc. cleanup

Fred Gilham 1 Minggu lalu
induk
melakukan
c85e380b2e
1 mengubah file dengan 38 tambahan dan 35 penghapusan
  1. 38 35
      bible.el

+ 38 - 35
bible.el

@@ -936,23 +936,24 @@ Create a new `bible' buffer positioned at the selected verse."
 Create a new `bible' buffer positioned at the specified verse.
 Handle abbreviations."
   (interactive)
-  (let* ((xref (get-text-property (point) 'xref))
-         (verse-ref (split-string xref))
-         book-abbrev
-         chapter-verse)
-    (message "xref: %s" xref)
-    (message "Verse-ref: %s" verse-ref)
-    (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 (string-trim book) (string-to-number chapter) (string-to-number verse) (default-value 'bible-text)))))
+  (let ((xref (get-text-property (point) 'xref)))
+    (when xref
+      (let ((verse-ref (split-string xref))
+            book-abbrev
+            chapter-verse)
+	(message "xref: %s" xref)
+	(message "Verse-ref: %s" verse-ref)
+	(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 (string-trim book) (string-to-number chapter) (string-to-number verse) (default-value 'bible-text)))))))
 
 
 ;;;;;; User visible actions.
@@ -1022,7 +1023,6 @@ MODULE is the text module to use and defaults to the current module."
       (apply #'call-process args))
     (buffer-string)))
 
-
 ;; Use HTMLHREF format with diatheke, post-process to render html.
 (defun bible--morph-query (query module)
   "Execute `diatheke' to do morph QUERY, using MODULE.
@@ -1095,7 +1095,8 @@ them to the <bookname> <chapter>:<verse> format."
   "Reformat tooltip text LEX-TEXT so tooltips look nice."
   (dolist (outline-string bible-outline-strings)
     (setq lex-text (string-replace (car outline-string) (cdr outline-string) lex-text)))
-    lex-text)
+  lex-text)
+
 
 (defun bible--lookup-def-greek (key)
   "Execute `diatheke' to do query on KEY.
@@ -1166,14 +1167,12 @@ 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)
-    (let ((result
-	   ;; 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))))
-      ;; Remove parenthesized module name.
-      (bible--remove-module-name lexicon result))))
-      
+    (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)))))
 
 (defun bible--lookup-lex (lex)
   "Look up lexical item LEX. This is used for tooltips.
@@ -1200,6 +1199,7 @@ database and stash in cache."
     (or (gethash morph morph-hash)
         (puthash morph
                  (let (morph-module morph-key)
+		   ;; We know about these modules. (Assume they're installed.)
                    (cond ((string-prefix-p "robinson:" morph)
                           (setq morph-module "Robinson")
                           (setq morph-key (substring morph (length "robinson:"))))
@@ -1489,7 +1489,6 @@ If optional argument VERSE is supplied, set cursor at verse."
           (replace-match "")
 	  (bible-new-line)
           ;; Highlight verse number
-	  ;;          (when (re-search-forward "^ *[0-9]+" nil t 1)
 	  (when (re-search-forward " *[0-9]+:" nil t 1)
             (add-face-text-property (match-beginning 0) (match-end 0) '(:foreground "purple"))))))
     (save-excursion
@@ -1502,7 +1501,8 @@ If optional argument VERSE is supplied, set cursor at verse."
 	(add-face-text-property (1- (point)) (- (point) 5) 'bold))
       ;; Remove the module name from the buffer.
       (while (re-search-forward (concat "^.*" bible-text ".*$") nil t)
-        (replace-match "" nil t)))
+	(replace-match ""))
+      (delete-blank-lines))
     (save-excursion
       (format-replace-strings '(("." . ". ")
                                 ("," . ", ")
@@ -1693,10 +1693,11 @@ If optional argument VERSE is supplied, set cursor at verse."
       (erase-buffer)
       (bible--insert-domnode-recursive (dom-by-tag html-dom-tree 'body)))
     (goto-char (point-min))
-    ;; Remove module name from buffer.
     (save-excursion
+      ;; Remove module name from buffer.
       (while (re-search-forward (concat "^.*" module ".*$") nil t)
-        (replace-match "")))
+	(replace-match ""))
+      (delete-blank-lines))
     (setq mode-name "Bible Search ")
     (setq-local bible-search-matches (length verses))))
 
@@ -1705,7 +1706,8 @@ If optional argument VERSE is supplied, set cursor at verse."
 
 (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."
+Used to display lemmas in mode lines. Assumes that StrongsHebrew
+and StrongsGreek lexicons have been installed."
   (let ((lemma-entry
 	 (pcase language
 	   ('hebrew
@@ -1727,7 +1729,7 @@ 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-term-greek (replace-regexp-in-string "strong:G" "" item))))
+    (bible--open-term-greek (replace-regexp-in-string "strong:G" "" item))))
 
 (defun bible--display-hebrew ()
   "Display Hebrew term.
@@ -1735,7 +1737,7 @@ 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-term-hebrew (replace-regexp-in-string "strong:H" "" item))))
+    (bible--open-term-hebrew (replace-regexp-in-string "strong:H" "" item))))
 
 ;;(defun bible-display-morphology (morph)
 ;; ;; REVIEW: Do something here? (FMG 5-Mar-2026)
@@ -1757,7 +1759,8 @@ This command is run by clicking on text, not directly by the user."
           (add-face-text-property start end '(:foreground "blue")))))
     (save-excursion
       (while (search-forward "()" nil t)
-        (replace-match "")))))
+        (replace-match ""))
+      (delete-blank-lines))))
 
 (defun bible--open-term-hebrew (term)
   "Open a buffer of the Strong's Hebrew TERM's definition."