From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Augusto Stoffel Newsgroups: gmane.emacs.bugs Subject: bug#54473: 28.0.91; [PATCH] Eldoc: Handle invisible text when truncating strings Date: Sun, 20 Mar 2022 13:06:56 +0100 Message-ID: <87o8203k0v.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35253"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.91 (gnu/linux) Cc: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= , andreyk.mad@gmail.com To: 54473@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Mar 20 13:08:38 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nVuMQ-0008za-0L for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 20 Mar 2022 13:08:38 +0100 Original-Received: from localhost ([::1]:52338 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVuMO-0001AG-Hp for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 20 Mar 2022 08:08:36 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:48262) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVuLs-00019V-Ux for bug-gnu-emacs@gnu.org; Sun, 20 Mar 2022 08:08:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:39141) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVuLq-0003Bd-OX for bug-gnu-emacs@gnu.org; Sun, 20 Mar 2022 08:08:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nVuLq-0005fI-I0 for bug-gnu-emacs@gnu.org; Sun, 20 Mar 2022 08:08:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Augusto Stoffel Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 20 Mar 2022 12:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 54473 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.164777803221716 (code B ref -1); Sun, 20 Mar 2022 12:08:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 20 Mar 2022 12:07:12 +0000 Original-Received: from localhost ([127.0.0.1]:33038 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nVuL1-0005eB-PI for submit@debbugs.gnu.org; Sun, 20 Mar 2022 08:07:12 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:57428) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nVuKz-0005e2-Ny for submit@debbugs.gnu.org; Sun, 20 Mar 2022 08:07:10 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:48002) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVuKw-0000gj-BY for bug-gnu-emacs@gnu.org; Sun, 20 Mar 2022 08:07:08 -0400 Original-Received: from [2a00:1450:4864:20::634] (port=37641 helo=mail-ej1-x634.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVuKq-0002xt-UN for bug-gnu-emacs@gnu.org; Sun, 20 Mar 2022 08:07:02 -0400 Original-Received: by mail-ej1-x634.google.com with SMTP id bg10so25008813ejb.4 for ; Sun, 20 Mar 2022 05:06:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:user-agent:mime-version; bh=pnwz0tNPXmH4jtQdC1lTLmPj7YI/i3ShpdU7pZkU22Y=; b=Y2Uphet9RDnTMKLMNsJEVatpOn1Or+5yQWrumljpW2GTczdBm4B4+ztEdFiIfGWP7+ knja+NSQ2OJvwkXWMYD7xj1SvVSMchumFWiqBvfpq6fi+FunTakq2+VD4yhqryItRsO2 Sc5a/lYgH7T4hWvv8TrU5X0M5rkPo52/moVbXHhrYJ0bReP8bHyoKBcjz6L5xqsxgweU iWWAUlHLwNU/85miuEzzI2is4calGWIUyDDJnYqrfyHSBLFe6zO6rJEL0kiai/AXOoQL Nrhmpehw/n7aIgjzJsQRxFWvAd52vfYSJwpFKB4/LGmcj5DWUbLJ2WojPsieikA0+z2J iWsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:user-agent :mime-version; bh=pnwz0tNPXmH4jtQdC1lTLmPj7YI/i3ShpdU7pZkU22Y=; b=6Vtu/mZ872XW3dnAAR4MH6BYzRwrGRg4cy3CESrGLML75TMmkfo5UaZ6iR/2+lxShs yyL6ojNcX62jNGGtSwGiLcI/6EgD5cssRdMIq1m+3hdXQrED3rluoCD1g7FDjsBh1fsC Zq7vui69HvDBs3hUSFzxSTxBT+ZemLaUgIus+2EAhWFsbMWilIjL800jJy4htzFbqDqx x1lM4yoR0tjSWG8C/huZUUxtczA5SPV9P4/UmZ6d6Wa+jnSpB2bJxPD1XBjLBIZPwJmL J/PtDmw/ZkzU6LUNidItg73q9e4/Y2fRkiDxcxheyyfiB8Nl2PNOoSNrQx67Y++ZRsai soJg== X-Gm-Message-State: AOAM531fNwqeZ2XgnmWvJIBq9TFhhiiMAMVmNKZauguxn5X56u301g8P /oYaTu9I6yZgrTw/rmbVgnU= X-Google-Smtp-Source: ABdhPJxIk2ldIF3mfjk4dN/Ddmhef/aTL5+dUPXHlxsk3mPNMQ36ziiz6FXQz3lFUhRHLBK+HrLcRg== X-Received: by 2002:a17:906:168f:b0:6df:b4ed:7c49 with SMTP id s15-20020a170906168f00b006dfb4ed7c49mr10688872ejd.36.1647778018119; Sun, 20 Mar 2022 05:06:58 -0700 (PDT) Original-Received: from ars3 ([2a02:8109:8ac0:56d0::758e]) by smtp.gmail.com with ESMTPSA id o14-20020a170906774e00b006d5b915f27dsm5746413ejn.169.2022.03.20.05.06.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 05:06:57 -0700 (PDT) X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::634 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::634; envelope-from=arstoffel@gmail.com; helo=mail-ej1-x634.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:228618 Archived-At: --=-=-= Content-Type: text/plain This should solve the Eglot-related problem described in this Github comment: https://github.com/joaotavora/eglot/issues/865#issuecomment-1065565845 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Eldoc-Handle-invisible-text-when-truncating-strings.patch >From c52b891b4197ee5cf9cec39993117487b0b4015f Mon Sep 17 00:00:00 2001 From: Augusto Stoffel 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 --=-=-=--