|
|
@@ -88,19 +88,15 @@
|
|
|
;; new function, retain backward compatibility.
|
|
|
(defalias 'bible-dom-text
|
|
|
(if (fboundp 'dom-inner-text)
|
|
|
- (lambda (node)
|
|
|
- (dom-inner-text node))
|
|
|
+ 'dom-inner-text
|
|
|
(with-no-warnings
|
|
|
- (lambda (node)
|
|
|
- (dom-text node)))))
|
|
|
+ 'dom-text)))
|
|
|
|
|
|
(defalias 'bible-dom-texts
|
|
|
(if (fboundp 'dom-inner-text)
|
|
|
- (lambda (node)
|
|
|
- (dom-inner-text node))
|
|
|
+ 'dom-inner-text
|
|
|
(with-no-warnings
|
|
|
- (lambda (node)
|
|
|
- (dom-texts node)))))
|
|
|
+ 'dom-texts)))
|
|
|
|
|
|
|
|
|
;;;; Configuration Variables
|
|
|
@@ -116,7 +112,7 @@
|
|
|
\(For full list of installed modules, run `diatheke -b system -l bibliography'\)"
|
|
|
:type '(choice (const :tag "None" nil)
|
|
|
(string :tag "Module abbreviation (e.g. \"KJV\")"))
|
|
|
-;; :local t
|
|
|
+ :local t
|
|
|
:group 'bible)
|
|
|
|
|
|
;;
|
|
|
@@ -190,6 +186,7 @@ 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
|
|
|
@@ -313,6 +310,7 @@ See `bible--display-lemma-hebrew'."
|
|
|
(defvar-local bible--current-chapter 1
|
|
|
"Current book chapter number.")
|
|
|
|
|
|
+;;;;; Search / query
|
|
|
(defvar-local bible-query nil
|
|
|
"Search query associated with the buffer.")
|
|
|
|
|
|
@@ -321,6 +319,9 @@ See `bible--display-lemma-hebrew'."
|
|
|
|
|
|
(defvar bible-search-range nil)
|
|
|
|
|
|
+
|
|
|
+;;;;; Lexemes / morphemes
|
|
|
+
|
|
|
(defvar-local bible-has-lexemes nil
|
|
|
"Set if the module being displayed has lexical entries availabile.")
|
|
|
|
|
|
@@ -341,7 +342,6 @@ See `bible--display-lemma-hebrew'."
|
|
|
[menu-bar bible toggle-debug]
|
|
|
'("Toggle debug-on-error" . toggle-debug-on-error))
|
|
|
|
|
|
-
|
|
|
(define-key bible-map
|
|
|
[menu-bar bible display-diatheke]
|
|
|
'("Toggle diatheke display" . bible-toggle-display-diatheke))
|
|
|
@@ -374,8 +374,8 @@ See `bible--display-lemma-hebrew'."
|
|
|
[menu-bar bible split-display]
|
|
|
'("Split Display" . bible-split-display))
|
|
|
|
|
|
-
|
|
|
;;;;; Search
|
|
|
+
|
|
|
(define-key bible-map "/" 'bible-search)
|
|
|
(define-key bible-map "s" 'bible-search)
|
|
|
(define-key bible-map
|
|
|
@@ -394,6 +394,8 @@ See `bible--display-lemma-hebrew'."
|
|
|
(define-key bible-search-mode-map "p" 'bible-previous-search-item)
|
|
|
(define-key bible-search-mode-map (kbd "RET") 'bible-search-mode-follow-verse)
|
|
|
|
|
|
+;;;;; Term display
|
|
|
+
|
|
|
(defconst bible-term-hebrew-mode-map (make-sparse-keymap))
|
|
|
(define-key bible-term-hebrew-mode-map "z" 'text-scale-adjust)
|
|
|
|
|
|
@@ -402,6 +404,7 @@ See `bible--display-lemma-hebrew'."
|
|
|
(define-key bible-term-greek-mode-map [mouse-1] 'bible-search-mode-follow-xref)
|
|
|
|
|
|
;;;;; Navigation
|
|
|
+
|
|
|
(define-key bible-map "p" 'bible-previous-chapter)
|
|
|
(define-key bible-map
|
|
|
[menu-bar bible previous-chapter]
|
|
|
@@ -416,6 +419,7 @@ See `bible--display-lemma-hebrew'."
|
|
|
(define-key bible-map (kbd "M-<tab>") 'bible-previous-word)
|
|
|
|
|
|
;;;;; Direct jump
|
|
|
+
|
|
|
(define-key bible-map "c" 'bible-select-chapter)
|
|
|
(define-key bible-map
|
|
|
[menu-bar bible select-chapter]
|
|
|
@@ -426,18 +430,14 @@ See `bible--display-lemma-hebrew'."
|
|
|
[menu-bar bible select-book]
|
|
|
'("Select Book" . bible-select-book))
|
|
|
|
|
|
-
|
|
|
(define-key bible-map
|
|
|
[menu-bar bible sep]
|
|
|
'(menu-item '"--"))
|
|
|
|
|
|
-
|
|
|
-;;;;; Deal with visual-line-mode
|
|
|
+;; Deal with visual-line-mode navigation.
|
|
|
(define-key bible-map "\C-n" 'next-logical-line)
|
|
|
(define-key bible-map "\C-p" 'previous-logical-line)
|
|
|
|
|
|
-;;;;; Keymap functions
|
|
|
-
|
|
|
(defun bible-toggle-display-diatheke ()
|
|
|
"Toggle diatheke args display."
|
|
|
(interactive)
|
|
|
@@ -460,8 +460,6 @@ See `bible--display-lemma-hebrew'."
|
|
|
(setq-local bible-debugme (not bible-debugme))
|
|
|
(bible--display))
|
|
|
|
|
|
-;;;; Menu bar items
|
|
|
-
|
|
|
(defvar-local bible-text-direction 'left-to-right)
|
|
|
|
|
|
(defun bible-toggle-text-direction ()
|
|
|
@@ -472,7 +470,6 @@ See `bible--display-lemma-hebrew'."
|
|
|
(setq-local bible-text-direction 'left-to-right))
|
|
|
(setq-local bidi-paragraph-direction bible-text-direction))
|
|
|
|
|
|
-
|
|
|
(defvar-local bible-search-query nil
|
|
|
"Query used in toggles (word study and red letter).")
|
|
|
|
|
|
@@ -484,7 +481,6 @@ See `bible--display-lemma-hebrew'."
|
|
|
;;(setq tooltip-mode -1)
|
|
|
;;(setq tooltip-resize-echo-area t)
|
|
|
|
|
|
-
|
|
|
(defun bible-toggle-tooltips ()
|
|
|
"Toggle use of tooltips to display lexical/morphological items."
|
|
|
(interactive)
|
|
|
@@ -494,7 +490,6 @@ See `bible--display-lemma-hebrew'."
|
|
|
(setq bible-show-diatheke-exec (and bible-show-diatheke-exec bible-use-tooltips)) ; Don't conflict with echo area
|
|
|
(message ""))
|
|
|
|
|
|
-
|
|
|
(define-key bible-map
|
|
|
[menu-bar bible sepp]
|
|
|
'(menu-item '"--"))
|
|
|
@@ -515,9 +510,10 @@ See `bible--display-lemma-hebrew'."
|
|
|
[menu-bar bible select-biblical-text]
|
|
|
'("Select Module" . bible-display-available-modules))
|
|
|
|
|
|
+;;;; Terms
|
|
|
|
|
|
(defun bible--display-greek ()
|
|
|
- "Display Greek text.
|
|
|
+ "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)))))
|
|
|
@@ -529,7 +525,7 @@ This command is run by clicking on text, not directly by the user."
|
|
|
(define-key bible-greek-keymap [mouse-1] 'bible--display-greek)
|
|
|
|
|
|
(defun bible--display-hebrew ()
|
|
|
- "Display Hebrew text.
|
|
|
+ "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)))))
|
|
|
@@ -566,7 +562,6 @@ This command is run by clicking on text, not directly by the user."
|
|
|
(setq buffer-read-only t)
|
|
|
(visual-line-mode t))
|
|
|
|
|
|
-
|
|
|
(define-derived-mode bible-search-mode special-mode "Bible Search"
|
|
|
"Mode for performing Bible searches.
|
|
|
\\{bible-search-mode-map}"
|
|
|
@@ -599,21 +594,24 @@ This command is run by clicking on text, not directly by the user."
|
|
|
(font-lock-mode t)
|
|
|
(setq buffer-read-only t))
|
|
|
|
|
|
-
|
|
|
;;;; Functions
|
|
|
|
|
|
-;;;;; Commands
|
|
|
+;;;;; Commands (interactive)
|
|
|
|
|
|
-(defun bible-open (&optional book-name chapter verse)
|
|
|
- "Create and open a `bible' buffer with BOOK-NAME, CHAPTER and VERSE.
|
|
|
-Arguments BOOK-NAME, CHAPTER and VERSE, when supplied, give the starting
|
|
|
-verse reference for the buffer. If no optional arguments are supplied,
|
|
|
-Genesis 1:1 is used."
|
|
|
+(defun bible-open (&optional book-name chapter verse module)
|
|
|
+ "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."
|
|
|
(interactive)
|
|
|
(with-current-buffer (get-buffer-create (generate-new-buffer-name (concat "*bible*")))
|
|
|
(bible)
|
|
|
+ (when module
|
|
|
+ (setq-default bible-module module))
|
|
|
+ (setq-local bible-module (or module (default-value 'bible-module)))
|
|
|
(bible--set-location
|
|
|
- (or (assoc (or book-name "Genesis") bible--books) (list book-name))
|
|
|
+ (assoc (or book-name "Genesis") bible--books)
|
|
|
(or chapter 1)
|
|
|
verse)
|
|
|
(set-window-buffer (get-buffer-window (current-buffer)) (current-buffer))))
|
|
|
@@ -681,12 +679,13 @@ Genesis 1:1 is used."
|
|
|
(setq bible-search-range nil)
|
|
|
(setq bible-search-range range))))
|
|
|
|
|
|
-
|
|
|
(defun bible-select-module ()
|
|
|
"Ask user for a new text module for the current `bible' buffer."
|
|
|
(interactive)
|
|
|
- (setq-default bible-module (completing-read "Module: " bible--modules))
|
|
|
- (bible--display))
|
|
|
+ (let ((module (completing-read "Module: " bible--modules)))
|
|
|
+ (when (not (string= module ""))
|
|
|
+ (setq-default bible-module module)
|
|
|
+ (bible--display module))))
|
|
|
|
|
|
(defun bible-toggle-word-study ()
|
|
|
"Toggle the inclusion of word study for the active `bible' buffer."
|
|
|
@@ -706,7 +705,7 @@ Genesis 1:1 is used."
|
|
|
(split-window-right)
|
|
|
(balance-windows)
|
|
|
(other-window 1)
|
|
|
- (bible-open bible--current-book-name bible--current-chapter))
|
|
|
+ (bible-open bible--current-book-name bible--current-chapter 1 bible-module))
|
|
|
|
|
|
(defun bible-search (query)
|
|
|
"Search for a QUERY: a word or phrase.
|
|
|
@@ -716,9 +715,8 @@ or `multiword'. `lucene' is the default search.
|
|
|
`lucene' mode requires an index to be built using the `mkfastmod' program."
|
|
|
(interactive "sBible Search: ")
|
|
|
(when (> (length query) 0)
|
|
|
- (let* ((bible-module (buffer-local-value 'bible-module (current-buffer)))
|
|
|
- (searchmode (completing-read "Search Mode: " '("lucene" "phrase" "regex" "multiword") nil t "lucene")))
|
|
|
- (bible--open-search query searchmode))))
|
|
|
+ (let ((searchmode (completing-read "Search Mode: " '("lucene" "phrase" "regex" "multiword") nil t "lucene")))
|
|
|
+ (bible--open-search query searchmode (buffer-local-value 'bible-module (current-buffer))))))
|
|
|
|
|
|
(defun bible-search-mode-follow-verse ()
|
|
|
"Follow the hovered verse in a `bible-search-mode' buffer.
|
|
|
@@ -737,7 +735,7 @@ Create a new `bible' buffer positioned at the selected verse."
|
|
|
(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))
|
|
|
- (bible-open (string-trim book) (string-to-number chapter) (string-to-number verse))))
|
|
|
+ (bible-open (string-trim book) (string-to-number chapter) (string-to-number verse)) bible-module))
|
|
|
|
|
|
(defun bible-search-mode-follow-xref ()
|
|
|
"Follow the hovered verse in a bible term buffer.
|
|
|
@@ -763,7 +761,7 @@ Handle abbreviations from lexicon module (AbbottSmith)."
|
|
|
(setq 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))))
|
|
|
+ (bible-open (string-trim book) (string-to-number chapter) (string-to-number verse) bible-module)))
|
|
|
|
|
|
|
|
|
;; These can be called interactively if you know the Strong's number
|
|
|
@@ -791,8 +789,14 @@ Handle abbreviations from lexicon module (AbbottSmith)."
|
|
|
(args (list bible-sword-query nil (current-buffer) t "-b" bible-module "-f" "plain" "-k" query)))
|
|
|
(apply #'call-process args)))
|
|
|
|
|
|
+;; Choose a Bible text.
|
|
|
+(defun bible-pick-module ()
|
|
|
+ "Keymap action function---select module user chooses."
|
|
|
+ (interactive)
|
|
|
+ (let ((item (get-text-property (point) 'module)))
|
|
|
+ (bible-open bible--current-book-name bible--current-chapter 1 item)))
|
|
|
|
|
|
-;;;; Support
|
|
|
+;;;; Support (internal)
|
|
|
|
|
|
(defconst bible-diatheke-filter-options " avlnmw")
|
|
|
|
|
|
@@ -804,17 +808,16 @@ Handle abbreviations from lexicon module (AbbottSmith)."
|
|
|
FILTER is the Diatheke filter argument. FORMAT is either plain
|
|
|
or the default of internal. MODULE is the text module to use."
|
|
|
(let ((module (or module bible-module)))
|
|
|
- (with-temp-buffer
|
|
|
- (let ((args (list bible-sword-query nil (current-buffer) t "-b" module)))
|
|
|
- (if filter
|
|
|
- (setq filter (concat filter bible-diatheke-filter-options))
|
|
|
- (setq filter bible-diatheke-filter-options))
|
|
|
- (setq args (append args (list "-o" filter)))
|
|
|
- (setq args (append args (list "-f" (pcase format ("plain" "plain") (_ "internal")) "-k" query)))
|
|
|
- (when bible-show-diatheke-exec
|
|
|
- (message "%s" args))
|
|
|
- (apply 'call-process args))
|
|
|
- (buffer-string))))
|
|
|
+ (let ((args (list bible-sword-query nil (current-buffer) t "-b" module)))
|
|
|
+ (if filter
|
|
|
+ (setq filter (concat filter bible-diatheke-filter-options))
|
|
|
+ (setq filter bible-diatheke-filter-options))
|
|
|
+ (setq args (append args (list "-o" filter)))
|
|
|
+ (setq args (append args (list "-f" (pcase format ("plain" "plain") (_ "internal")) "-k" query)))
|
|
|
+ (when bible-show-diatheke-exec
|
|
|
+ (message "%s" args))
|
|
|
+ (apply #'call-process args))))
|
|
|
+
|
|
|
|
|
|
|
|
|
(defun bible--diatheke-search (query searchtype &optional format module)
|
|
|
@@ -832,10 +835,9 @@ MODULE is the text module to use and defaults to the current module."
|
|
|
(setq args (append args (list "-f" (pcase format ("plain" "plain") (_ "internal")) "-k" query)))
|
|
|
(when bible-show-diatheke-exec
|
|
|
(message "%s" args))
|
|
|
- (apply 'call-process args))
|
|
|
+ (apply #'call-process args))
|
|
|
(buffer-string)))
|
|
|
|
|
|
-
|
|
|
;; XXX Bible chapter titles mostly appear in Psalms. This code works
|
|
|
;; OK except for Psalm 119 which changes the chapter title to indicate
|
|
|
;; the Hebrew letter that each verse of a stanza begins with.
|
|
|
@@ -850,7 +852,6 @@ MODULE is the text module to use and defaults to the current module."
|
|
|
"Text preceding start of chapter.
|
|
|
Mostly in Psalms, like `Of David' or the like.")
|
|
|
|
|
|
-
|
|
|
;;;; Greek and Hebrew lexeme and morpheme tooltip rendering.
|
|
|
|
|
|
;;;;; Hash tables for Lexical definitions.
|
|
|
@@ -869,7 +870,7 @@ Render HTML, return string. Do some tweaking specific to morphology."
|
|
|
(let ((args (list bible-sword-query nil (current-buffer) t "-b" module "-o" "m" "-f" "HTMLHREF" "-k" query)))
|
|
|
(when bible-show-diatheke-exec
|
|
|
(message "%s" args))
|
|
|
- (apply 'call-process args)
|
|
|
+ (apply #'call-process args)
|
|
|
(shr-render-region (point-min) (point-max))
|
|
|
(format-replace-strings
|
|
|
'(("\n:" . "") ; This makes the Packard morphology display look better.
|
|
|
@@ -882,8 +883,9 @@ Render HTML, return string. Do some tweaking specific to morphology."
|
|
|
(defun bible--lex-query (query module)
|
|
|
"Execute `diatheke' for QUERY, using MODULE.
|
|
|
Plain format, returns string."
|
|
|
- (bible--exec-diatheke query nil "plain" module))
|
|
|
-
|
|
|
+ (with-temp-buffer
|
|
|
+ (bible--exec-diatheke query nil "plain" module)
|
|
|
+ (buffer-string)))
|
|
|
|
|
|
(defun bible--lookup-lemma-index (key)
|
|
|
"Return the Greek lemma from lemma index with a strong's number as KEY."
|
|
|
@@ -893,7 +895,6 @@ Plain format, returns string."
|
|
|
""
|
|
|
(bible--lex-query key bible-lexicon-index))))
|
|
|
|
|
|
-;;
|
|
|
;; The Greek lexical definitions are done using the HTMLHREF output
|
|
|
;; format so they come out looking nice and having clickable
|
|
|
;; cross-references and/or Strong's references.
|
|
|
@@ -943,7 +944,7 @@ Massage output so verse cross references are usable. Returns string."
|
|
|
(let ((args (list bible-sword-query nil (current-buffer) t "-b" bible-greek-lexicon "-o" "m" "-f" "plain" "-k" key)))
|
|
|
(when bible-show-diatheke-exec
|
|
|
(message "%s" args))
|
|
|
- (apply 'call-process args)
|
|
|
+ (apply #'call-process args)
|
|
|
(bible--cleanup-lex-text (string-replace (concat "(" bible-greek-lexicon ) "" (buffer-string))))))
|
|
|
|
|
|
(defun bible--lookup-lemma-greek-indexed (key)
|
|
|
@@ -976,7 +977,7 @@ Massage output so various cross references are usable. Returns string."
|
|
|
(let ((args (list bible-sword-query nil (current-buffer) t "-b" bible-hebrew-lexicon "-f" "plain" "-k" key)))
|
|
|
(when bible-show-diatheke-exec
|
|
|
(message "%s" args))
|
|
|
- (apply 'call-process args)
|
|
|
+ (apply #'call-process args)
|
|
|
(bible--process-href)
|
|
|
(bidi-string-mark-left-to-right
|
|
|
(string-replace (concat "(" bible-hebrew-lexicon ) "" (substring (buffer-string) 7))))))
|
|
|
@@ -1004,8 +1005,10 @@ Massage output so various cross references are usable. Returns string."
|
|
|
"Look up Hebrew lexical entry for LEMMA.
|
|
|
Uses short Hebrew lexicon (e.g. StrongsRealHebrew)."
|
|
|
(when (string-match "[0-9]+" lemma)
|
|
|
- ;; Remove redundant stuff at the beginnning.
|
|
|
- (substring (bible--lex-query (concat (match-string 0 lemma)) bible-hebrew-lexicon-short) 7)))
|
|
|
+ (let ((result (bible--lex-query (concat (match-string 0 lemma)) bible-hebrew-lexicon-short)))
|
|
|
+ ;; Get rid of unnecessary strongs codes at the beginning.
|
|
|
+ (replace-regexp-in-string ".*[0-9]* [0-9]* " "" result))))
|
|
|
+
|
|
|
|
|
|
(defun bible--lookup-lex (lex)
|
|
|
"Look up lexical item LEX. This is used for tooltips.
|
|
|
@@ -1292,28 +1295,26 @@ XXX In processing subnodes, each case will prepend a space if it needs it."
|
|
|
(add-face-text-property (- (point) (length word)) (point) '(:foreground "gray50")))))))))))
|
|
|
|
|
|
|
|
|
-(defun bible--display (&optional verse)
|
|
|
+(defun bible--display (&optional module verse)
|
|
|
"Render a page of text for `bible'.
|
|
|
+If optional argument MODULE is supplied, use that module for display.
|
|
|
If optional argument VERSE is supplied, set cursor at verse."
|
|
|
-
|
|
|
- (setq-local bible-module (default-value 'bible-module))
|
|
|
-
|
|
|
+ (setq-local bible-module (or module (default-value 'bible-module)))
|
|
|
(let ((buffer-read-only nil)
|
|
|
(bible-chapter-title nil)
|
|
|
(bible-has-lexemes nil)
|
|
|
(bible-has-morphemes nil))
|
|
|
+ (message "display %s" module)
|
|
|
(erase-buffer)
|
|
|
- (insert (bible--exec-diatheke (concat bible--current-book-name ":" (number-to-string bible--current-chapter))))
|
|
|
-
|
|
|
+ (bible--exec-diatheke (concat bible--current-book-name ":" (number-to-string bible--current-chapter)))
|
|
|
;; Parse the xml in the buffer into a DOM tree.
|
|
|
- (let ((html-dom-tree (libxml-parse-html-region (point-min) (point-max))))
|
|
|
+ (let ((html-dom-tree (libxml-parse-html-region (point-min) (point-max))))
|
|
|
;; Render the DOM tree into the buffer.
|
|
|
- (unless bible-debugme ; If this is true, display the XML.
|
|
|
+ (unless bible-debugme ; If this is true, display the XML.
|
|
|
(erase-buffer)
|
|
|
;; Looking for the "body" tag in the DOM node.
|
|
|
(bible--insert-domnode-recursive (dom-by-tag html-dom-tree 'body) nil nil)
|
|
|
(goto-char (point-min))))
|
|
|
-
|
|
|
(save-excursion
|
|
|
(let ((search-string (concat " *" (car bible--current-book) " " (number-to-string bible--current-chapter) ":")))
|
|
|
;; Delete <Book Ch:> at beginning of verse, just leave verse number.
|
|
|
@@ -1322,12 +1323,10 @@ If optional argument VERSE is supplied, set cursor at verse."
|
|
|
;; Highlight verse number
|
|
|
(when (re-search-forward "^ *[0-9]+" nil t 1)
|
|
|
(add-face-text-property (match-beginning 0) (match-end 0) '(:foreground "purple"))))))
|
|
|
-
|
|
|
(save-excursion
|
|
|
;; Remove the module name from the buffer.
|
|
|
(while (re-search-forward (concat "^.*" bible-module ".*$") nil t)
|
|
|
(replace-match "" nil t)))
|
|
|
-
|
|
|
(save-excursion
|
|
|
;; Deal with chapter titles (i.e. in Psalms)
|
|
|
;; XXX N.B. This won't change a title inside a chapter, and so it
|
|
|
@@ -1343,7 +1342,6 @@ If optional argument VERSE is supplied, set cursor at verse."
|
|
|
(insert title-text "\n")
|
|
|
(setq refend (point))
|
|
|
(put-text-property refstart refend 'face 'bold))))
|
|
|
-
|
|
|
;; Get rid of spurious spaces.
|
|
|
(format-replace-strings '(("." . ". ")
|
|
|
("," . ", ")
|
|
|
@@ -1363,30 +1361,30 @@ If optional argument VERSE is supplied, set cursor at verse."
|
|
|
(". ”" . ".”")
|
|
|
("? ”" . "?”"))
|
|
|
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
|
|
|
(replace-match " ")))
|
|
|
-
|
|
|
;; Set the mode line of the biffer.
|
|
|
(setq mode-name (concat "Bible (" bible--current-book-name " " (number-to-string bible--current-chapter) ") "
|
|
|
- bible-module
|
|
|
+ module
|
|
|
(when bible-has-lexemes " Lex")
|
|
|
(when bible-has-morphemes " Morph")
|
|
|
- ")")))
|
|
|
-
|
|
|
+ ")"))
|
|
|
+ (force-mode-line-update))
|
|
|
;; If optional verse specification go to that verse.
|
|
|
(when verse
|
|
|
(re-search-forward (concat " ?" (number-to-string verse)) nil t)))
|
|
|
|
|
|
-
|
|
|
;;;; Modules (Bible texts)
|
|
|
|
|
|
(defun bible--list-biblical-modules ()
|
|
|
"Return a list of accessible Biblical Text modules."
|
|
|
- (let ((text (bible--exec-diatheke "modulelist" nil nil "system"))
|
|
|
- modules)
|
|
|
+ (let ((text
|
|
|
+ (with-temp-buffer
|
|
|
+ (bible--exec-diatheke "modulelist" nil nil "system")
|
|
|
+ (buffer-string)))
|
|
|
+ modules)
|
|
|
(catch 'done
|
|
|
(dolist (line (split-string text "[\n\r]+"))
|
|
|
(when (equal line "Commentaries:")
|
|
|
@@ -1395,14 +1393,6 @@ If optional argument VERSE is supplied, set cursor at verse."
|
|
|
(push (split-string line " : ") modules))))
|
|
|
(reverse modules)))
|
|
|
|
|
|
-(defun bible-pick-module ()
|
|
|
- "Keymap action function---select module user chooses."
|
|
|
- (interactive)
|
|
|
- (let ((item (get-text-property (point) 'module)))
|
|
|
- (setq-default bible-module item)
|
|
|
- (bible-open)))
|
|
|
-
|
|
|
-
|
|
|
(defconst bible-module-map (make-keymap))
|
|
|
(define-key bible-module-map [mouse-1] 'bible-pick-module)
|
|
|
(define-key bible-module-map (kbd "RET") 'bible-pick-module)
|
|
|
@@ -1433,34 +1423,34 @@ If optional argument VERSE is supplied, set cursor at verse."
|
|
|
|
|
|
;;;; Bible Searching
|
|
|
|
|
|
-(defun bible--open-search (query searchmode)
|
|
|
- "Open a search buffer of QUERY using SEARCHMODE in module MOD."
|
|
|
+(defun bible--open-search (query searchmode module)
|
|
|
+ "Open a search buffer of QUERY using SEARCHMODE in module MODULE."
|
|
|
(let ((results (string-trim (replace-regexp-in-string
|
|
|
"Entries .+?--" ""
|
|
|
- (bible--diatheke-search query searchmode "plain" bible-module)))))
|
|
|
- (if (equal results (concat "none (" bible-module ")"))
|
|
|
+ (bible--diatheke-search query searchmode "plain" module)))))
|
|
|
+ (if (equal results (concat "none (" module ")"))
|
|
|
(message (concat
|
|
|
"No results found."
|
|
|
(when (equal searchmode "lucene")
|
|
|
" Verify index has been build with mkfastmod.")))
|
|
|
-
|
|
|
- (with-current-buffer (get-buffer-create (concat "*bible-search-" (downcase bible-module) "-" query "*"))
|
|
|
+ (with-current-buffer (get-buffer-create (concat "*bible-search-" (downcase module) "-" query "*"))
|
|
|
(bible-search-mode)
|
|
|
- (bible--display-search results)
|
|
|
+ (bible--display-search results module)
|
|
|
(pop-to-buffer (current-buffer) nil t)))))
|
|
|
|
|
|
-(defun bible--display-search (results)
|
|
|
- "Render RESULTS of search query."
|
|
|
+(defun bible--display-search (results module)
|
|
|
+ "Render RESULTS of search query with MODULE."
|
|
|
(let ((match 0)
|
|
|
(matchstr "")
|
|
|
(verses nil)
|
|
|
(query-verses "")
|
|
|
(buffer-read-only nil))
|
|
|
+ (message "display-search %s" module)
|
|
|
+ (setq-default bible-module module)
|
|
|
(erase-buffer)
|
|
|
(while match
|
|
|
(setq match (string-match ".+?:[0-9]?[0-9]?" results (+ match (length matchstr)))
|
|
|
matchstr (match-string 0 results))
|
|
|
-
|
|
|
(when match
|
|
|
(push
|
|
|
;; Massage match to make it more sortable, get rid of some characters.
|
|
|
@@ -1474,22 +1464,21 @@ If optional argument VERSE is supplied, set cursor at verse."
|
|
|
"III " "3"
|
|
|
matchstr))))
|
|
|
verses)))
|
|
|
-
|
|
|
(sort verses #'string-version-lessp)
|
|
|
(dolist (verse verses)
|
|
|
(if query-verses
|
|
|
(setq query-verses (concat query-verses ";" verse))
|
|
|
(setq query-verses verse)))
|
|
|
(let ((bible-show-diatheke-exec nil))
|
|
|
- (insert (bible--exec-diatheke query-verses nil nil bible-module)))
|
|
|
+ (bible--exec-diatheke query-verses nil nil module))
|
|
|
(let* ((html-dom-tree (libxml-parse-html-region (point-min) (point-max))))
|
|
|
(erase-buffer)
|
|
|
(bible--insert-domnode-recursive (dom-by-tag html-dom-tree 'body) nil nil))
|
|
|
(goto-char (point-min))
|
|
|
(save-excursion
|
|
|
- (while (re-search-forward (concat "^.*" bible-module) nil t)
|
|
|
+ (while (re-search-forward (concat "^.*" module) nil t)
|
|
|
(replace-match ""))))
|
|
|
- (setq mode-name (concat "Bible Search (" bible-module))
|
|
|
+ (setq mode-name (concat "Bible Search (" module))
|
|
|
(when bible-search-range
|
|
|
(setq mode-name (concat mode-name " [" bible-search-range "]")))
|
|
|
(setq mode-name (concat mode-name ")")))
|
|
|
@@ -1575,11 +1564,12 @@ This code is customized for the BDBGlosses_Strongs lexicon."
|
|
|
|
|
|
(defun bible--set-location (book chapter &optional verse)
|
|
|
"Set the BOOK, CHAPTER and optionally VERSE of the active `bible' buffer."
|
|
|
- (setq-local bible-module (default-value 'bible-module))
|
|
|
+ ;; (setq-local bible-module (default-value 'bible-module))
|
|
|
+ (message "set-location %s" book)
|
|
|
(setq-local bible--current-book book)
|
|
|
(setq-local bible--current-book-name (car book))
|
|
|
(setq-local bible--current-chapter chapter)
|
|
|
- (bible--display verse))
|
|
|
+ (bible--display bible-module verse))
|
|
|
|
|
|
;;;; Utilities
|
|
|
|