unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#54473: 28.0.91; [PATCH] Eldoc: Handle invisible text when truncating strings
@ 2022-03-20 12:06 Augusto Stoffel
  2022-03-20 13:10 ` João Távora
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Augusto Stoffel @ 2022-03-20 12:06 UTC (permalink / raw)
  To: 54473; +Cc: João Távora, andreyk.mad

[-- Attachment #1: Type: text/plain, Size: 151 bytes --]

This should solve the Eglot-related problem described in this Github comment:

https://github.com/joaotavora/eglot/issues/865#issuecomment-1065565845


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Eldoc-Handle-invisible-text-when-truncating-strings.patch --]
[-- Type: text/x-patch, Size: 2678 bytes --]

From c52b891b4197ee5cf9cec39993117487b0b4015f Mon Sep 17 00:00:00 2001
From: Augusto Stoffel <arstoffel@gmail.com>
Date: Sun, 20 Mar 2022 12:59:14 +0100
Subject: [PATCH] Eldoc: Handle invisible text when truncating strings

* lisp/emacs-lisp/eldoc.el (eldoc--echo-area-substring,
eldoc-display-in-echo-area):  Take invisible text into consideration
when counting lines to crop an echo-area message.
---
 lisp/emacs-lisp/eldoc.el | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el
index 73713a3dec..16c08e1e10 100644
--- a/lisp/emacs-lisp/eldoc.el
+++ b/lisp/emacs-lisp/eldoc.el
@@ -102,7 +102,7 @@ eldoc-echo-area-use-multiline-p
 directly, while a float specifies the number of lines as a
 proportion of the echo area frame's height.
 
-If value is the symbol `truncate-sym-name-if-fit' t, the part of
+If value is the symbol `truncate-sym-name-if-fit', the part of
 the doc string that represents a symbol's name may be truncated
 if it will enable the rest of the doc string to fit on a single
 line, without resizing the echo area.
@@ -525,7 +525,8 @@ eldoc--echo-area-substring
                         (goto-char (point-min))
                         (skip-chars-forward " \t\n")
                         (point))
-                 (goto-char (line-end-position available))
+                 (forward-visible-line (1- available))
+                 (end-of-visible-line)
                  (skip-chars-backward " \t\n")))
         (truncated (save-excursion
                      (skip-chars-forward " \t\n")
@@ -535,7 +536,8 @@ eldoc--echo-area-substring
           ((and truncated
                 (> available 1)
                 eldoc-echo-area-display-truncation-message)
-           (goto-char (line-end-position 0))
+           (forward-visible-line -1)
+           (end-of-visible-line)
            (concat (buffer-substring start (point))
                    (format
                     "\n(Documentation truncated. Use `%s' to see rest)"
@@ -610,7 +612,8 @@ eldoc-display-in-echo-area
                (let ((string
                       (with-current-buffer (eldoc--format-doc-buffer docs)
                         (buffer-substring (goto-char (point-min))
-                                          (line-end-position 1)))))
+                                          (progn (end-of-visible-line)
+                                                 (point))))))
                  (if (> (length string) width)  ; truncation to happen
                      (unless (eldoc--echo-area-prefer-doc-buffer-p t)
                        (truncate-string-to-width string width))
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-06-23 17:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-20 12:06 bug#54473: 28.0.91; [PATCH] Eldoc: Handle invisible text when truncating strings Augusto Stoffel
2022-03-20 13:10 ` João Távora
2022-03-20 13:52 ` Eli Zaretskii
2022-03-20 14:03   ` João Távora
2022-03-20 14:34     ` Augusto Stoffel
2022-03-20 15:57       ` Eli Zaretskii
2022-03-20 21:24 ` Andrii Kolomoiets
2022-03-24 15:25   ` João Távora
2022-06-23 17:24     ` Stefan Kangas

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).