emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/eldoc-eval 5ecafc2b3d 26/28: Better fix to prevent erro


From: Stefan Monnier
Subject: [elpa] externals/eldoc-eval 5ecafc2b3d 26/28: Better fix to prevent error with composition-function-table
Date: Thu, 6 Jan 2022 08:34:57 -0500 (EST)

branch: externals/eldoc-eval
commit 5ecafc2b3d3e712c96dcdbcff0cbe43f1b6fed3d
Author: Thierry Volpiatto <thievol@posteo.net>
Commit: Thierry Volpiatto <thievol@posteo.net>

    Better fix to prevent error with composition-function-table
    
    when ligature-mode is enabled.
    
    This modify only mode-line string without modifying text in current-buffer
    while in the minibuffer.
---
 eldoc-eval.el | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/eldoc-eval.el b/eldoc-eval.el
index ef9a32e297..0528f6c256 100644
--- a/eldoc-eval.el
+++ b/eldoc-eval.el
@@ -183,6 +183,18 @@ See `with-eldoc-in-minibuffer'."
              'above (minibuffer-window)))
            (t (minibuffer-selected-window))))))
 
+(defun eldoc-eval--get-string (str)
+  ;; Avoid error when ligature-mode is enabled. The error comes from
+  ;; composite.c.
+  ;; (error "Attempt to shape unibyte text"). This happen when string
+  ;; comes with [...] at end.
+  (with-temp-buffer
+    (let ((composition-function-table
+           (default-value 'composition-function-table)))
+      (when (stringp str)
+        (insert str)
+        (buffer-string)))))
+
 (defun eldoc-show-in-mode-line (input)
   "Display string STR in the mode-line next to minibuffer."
   (with-current-buffer (eldoc-current-buffer)
@@ -190,15 +202,17 @@ See `with-eldoc-in-minibuffer'."
            (str              (and (stringp input) (concat " " input)))
            (len              (length str))
            (tmp-str          str)
-           (composition-function-table (default-value 
'composition-function-table))
-           (mode-line-format (or str mode-line-format))
+           (mode-line-format
+            (or (eldoc-eval--get-string str)
+                mode-line-format))
            roll mode-line-in-non-selected-windows)
       (catch 'break
         (if (and (> len max) eldoc-mode-line-rolling-flag)
             (progn
               (while (setq roll (sit-for 0.3))
                 (setq tmp-str (substring tmp-str 2)
-                      mode-line-format (concat tmp-str " [<]" str))
+                      mode-line-format (eldoc-eval--get-string
+                                        (concat tmp-str " [<]" str)))
                 (force-mode-line-update)
                 (when (< (length tmp-str) 2) (setq tmp-str str)))
               (unless roll



reply via email to

[Prev in Thread] Current Thread [Next in Thread]