branch: externals/greader
commit e4b7844cb43b0496a676212eeda92643085e7cbe
Author: Michelangelo Rodriguez <[email protected]>
Commit: Michelangelo Rodriguez <[email protected]>
Refactor: Update dictionary on stop and simplify filter logic
The dictionary update process is now called from "greader-stop". This
ensures that "greader-dict--update" is executed once when reading stops,
making the update process more reliable.
In "greader-dict.el", the logic for applying filters has been simplified.
The function "greader-dict-check-and-replace" no longer fetches filter
variables from the reading buffer. This reduces coupling between the
dictionary and the reading buffer's local variables.
The docstring for "greader-stop" has been updated to document the new
behavior.
---
greader-dict.el | 6 +-----
greader.el | 7 +++++--
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/greader-dict.el b/greader-dict.el
index 6538e7e5c9..0a9944bbca 100644
--- a/greader-dict.el
+++ b/greader-dict.el
@@ -484,11 +484,7 @@ by adding every match found in the text as a word."
(with-greader-dict-temp-buffer
(insert text)
(goto-char (point-min))
- (when
- (buffer-local-value 'greader-dict-toggle-filters
- greader-dict--current-reading-buffer)
- (setq greader-filters (buffer-local-value 'greader-filters
-
greader-dict--current-reading-buffer))
+ (when greader-dict-toggle-filters
(greader-dict-filters-apply))
(if
(buffer-local-value 'greader-dict-mode
diff --git a/greader.el b/greader.el
index d6cbc8f3e9..60d0fbd899 100644
--- a/greader.el
+++ b/greader.el
@@ -638,7 +638,8 @@ function, point jumps at the last position you called
command `greader-read'."
(greader-read-asynchronous ". end"))))))
(defun greader-stop ()
- "Stops reading of document."
+ "Stop reading of document.
+If `greader-dict-mode' and/or `greader-dict-toggle-filters' are active, the
dictionary of pronunciation rules will be updated after calling all the hooks."
(interactive)
(cond
((and (> greader-elapsed-time 0) greader-timer-flag)
@@ -651,7 +652,9 @@ function, point jumps at the last position you called
command `greader-read'."
(setq-local greader-stop-timer 0)))
(greader-set-greader-keymap)
(greader-tts-stop)
- (run-hooks 'greader-after-stop-hook))
+ (run-hooks 'greader-after-stop-hook)
+ (when (or greader-dict-mode greader-dict-toggle-filters)
+ (greader-dict--update)))
(defun greader-debug (arg)
"Used to get some fast debugging.