branch: elpa/gptel
commit 6320c2bf4f688a01385e8fce2ee8382a57299262
Author: Karthik Chikmagalur <karthikchikmaga...@gmail.com>
Commit: Karthik Chikmagalur <karthikchikmaga...@gmail.com>

    gptel: Use font-lock-flush instead of font-lock-fontify-region
    
    * gptel.el (gptel--font-lock-update): Remove this function and use
    the built-in `font-lock-flush' instead to update fontification
    after a streaming response in Org mode.  This was recommended by
    Stefan Monnier:
    https://lists.gnu.org/archive/html/emacs-devel/2025-03/msg00699.html
---
 gptel.el | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/gptel.el b/gptel.el
index 8afd57929a..98c72bcbb9 100644
--- a/gptel.el
+++ b/gptel.el
@@ -919,12 +919,6 @@ Later plists in the sequence take precedence over earlier 
ones."
         (setq rtn (plist-put rtn p v))))
     rtn))
 
-(defun gptel--font-lock-update (beg end)
-  "Force font-lock update between BEG and END."
-  (when font-lock-mode
-    (save-excursion
-      (font-lock-fontify-region beg end))))
-
 (defun gptel-auto-scroll ()
   "Scroll window if LLM response continues below viewport.
 
@@ -1337,7 +1331,7 @@ file."
         (add-hook 'before-save-hook #'gptel--save-state nil t)
         (when (derived-mode-p 'org-mode)
           ;; Work around bug in `org-fontify-extend-region'.
-          (add-hook 'gptel-post-response-functions #'gptel--font-lock-update 
nil t))
+          (add-hook 'gptel-post-response-functions #'font-lock-flush nil t))
         (gptel--restore-state)
         (if gptel-use-header-line
           (setq gptel--old-header-line header-line-format

Reply via email to