branch: elpa/gptel
commit b972f59d1c0414d79b99ec6f4447ef6482f88f33
Author: Karthik Chikmagalur <[email protected]>
Commit: Karthik Chikmagalur <[email protected]>
gptel-request: Simplify truncation in gptel--describe-directive
* gptel-request.el (gptel--describe-directive):
`truncate-string-to-width' is slow when the string is large (> 2000
words, say). Since `gptel--describe-directive' is used in the
header line and refreshes on redisplay, switch to using substring
instead. We lose the ellipsis at the end of truncated strings,
but them's the breaks.
---
gptel-request.el | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/gptel-request.el b/gptel-request.el
index f4043c3da40..12380d3e013 100644
--- a/gptel-request.el
+++ b/gptel-request.el
@@ -1065,10 +1065,9 @@ The result is a string intended for display. Newlines
are
replaced with REPLACEMENT."
(cl-typecase directive
(string
- (concat
- (string-replace "\n" (or replacement " ")
- (truncate-string-to-width
- directive width nil nil t))))
+ (string-replace
+ "\n" (or replacement " ")
+ (substring directive 0 (min width (length directive)))))
(function
(concat
"λ: "