unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Augusto Stoffel <arstoffel@gmail.com>
To: 54473@debbugs.gnu.org
Cc: "João Távora" <joaotavora@gmail.com>, andreyk.mad@gmail.com
Subject: bug#54473: 28.0.91; [PATCH] Eldoc: Handle invisible text when truncating strings
Date: Sun, 20 Mar 2022 13:06:56 +0100	[thread overview]
Message-ID: <87o8203k0v.fsf@gmail.com> (raw)

[-- 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


             reply	other threads:[~2022-03-20 12:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-20 12:06 Augusto Stoffel [this message]
2022-03-20 13:10 ` bug#54473: 28.0.91; [PATCH] Eldoc: Handle invisible text when truncating strings 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87o8203k0v.fsf@gmail.com \
    --to=arstoffel@gmail.com \
    --cc=54473@debbugs.gnu.org \
    --cc=andreyk.mad@gmail.com \
    --cc=joaotavora@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).