branch: externals/greader
commit 2e3374e1974c9c8b44d4c4d16a12681079780f28
Author: Michelangelo Rodriguez <[email protected]>
Commit: Michelangelo Rodriguez <[email protected]>

    Fix(greader-dict): Correctly identify the reading buffer
    
    The change in greader-dict--update ensures that the correct reading
    buffer is used when updating the dictionary.
    
    Previously, (current-buffer) was used, which could lead to errors if
    the update function was called from a different context than the
    buffer being read.
    
    The new implementation now prioritizes the value of
    greader--current-buffer, falling back to (current-buffer) only if it
    is not set. This improves the reliability of the dictionary update
    mechanism.
---
 greader-dict.el | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/greader-dict.el b/greader-dict.el
index 0a9944bbca..d8719cd5a9 100644
--- a/greader-dict.el
+++ b/greader-dict.el
@@ -177,6 +177,7 @@
 
 (defvar-local greader-dict-filename "greader-dict.global"
   "File name where dictionary definitions are stored.")
+
 (defvar greader-dict--current-reading-buffer (current-buffer))
 ;; We use this variable to know if greader-dictionary is saved after
 ;; the last modification.
@@ -822,14 +823,18 @@ asked."
 (defvar greader-reading-mode)
 (defun greader-dict--update ()
   (when greader-dict-toggle-filters
-    (setq greader-dict--current-reading-buffer (current-buffer))
+    (setq greader-dict--current-reading-buffer (or
+                                               greader--current-buffer
+                                               (current-buffer)))
     (let ((dict-mode-state greader-dict-mode))
       (greader-dict-mode 1)
       (greader-dict-read-from-dict-file t)
       (unless dict-mode-state
        (greader-dict-mode -1))))
   (when greader-dict-mode
-    (setq greader-dict--current-reading-buffer (current-buffer))
+    (setq greader-dict--current-reading-buffer (or
+                                               greader--current-buffer
+                                               (current-buffer)))
     (unless greader-dict--saved-flag
       (greader-dict-write-file))
     ;; I decided to keep the following code for historical reasons and
@@ -841,6 +846,7 @@ asked."
        (buffer-local-value 'greader-dictionary
                           greader-dict--current-reading-buffer))
       (greader-dict-read-from-dict-file t))))
+
 ;; Questa funzione è solo di utilità e potrebbe essere rimossa o
 ;; modificata in qualsiasi momento.
 (defun greader-dict-beep ()

Reply via email to