unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "João Távora" <joaotavora@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel <emacs-devel@gnu.org>,
	fh@fhaun.de, Tassilo Horn <tsdh@gnu.org>
Subject: Re: eldoc-docstring-format-sym-doc
Date: Sun, 26 Jul 2020 11:16:31 +0100	[thread overview]
Message-ID: <87imeatwcg.fsf@gmail.com> (raw)
In-Reply-To: <CALDnm52PDHAt5CyS73k+_5Uy05SM-9tutJhX5qbb1M03KYpJbw@mail.gmail.com> ("João Távora"'s message of "Sat, 25 Jul 2020 10:26:31 +0100")

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

João Távora <joaotavora@gmail.com> writes:

> On Sat, Jul 25, 2020 at 7:16 AM Eli Zaretskii <eliz@gnu.org> wrote:
>
>  > From: Tassilo Horn <tsdh@gnu.org>
>  > Date: Fri, 24 Jul 2020 21:49:12 +0200
>  > Cc: emacs-devel@gnu.org
>  > 
>  > > when was the function "eldoc-docstring-format-sym-doc" removed? I cant
>  > > find nothing in the logs.
>  > 
>  > In this commit:
>  > 
>  >   commit 1203626f472b0d99d2746f5999711137c0c1fd0c
>  >   Author: João Távora <joaotavora@gmail.com>
>  >   Date:   Sat Jun 6 14:04:48 2020 +0100
>  > 
>  > > Elpy is using it.
>  > 
>  > It seems like it was removed including allmost all calls except for in
>  > semantic/grammar.el:
>  > 
>  >     * lisp/cedet/semantic/grammar.el (semantic--docstring-format-sym-doc):
>  >     New function.
>  >     (semantic-grammar-eldoc-get-macro-docstring): Adjust.
>  > 
>  > Basically semantic--docstring-format-sym-doc is the old
>  > eldoc-docstring-format-sym-doc.  But I guess the plan is to remove that
>  > eventually, too.  Eldoc got a overhaul recently...
>
>  João, based on this report, do we need some backward-compatibility
>  shim to help 3rd party packages which use this removed function?
>
> From memory, maybe  just bringing back the function as-is should
> do the trick, since eldoc-docstring-format-sym-doc is just a 
> string formatting function, I seem to recall.
>
> I hope this can wait for monday, as I don't have much time
> for emacs devel this weekend.
>
> Ideally though, elpy would rely on the new API, if possible.
> Is Elpy using the new eldoc.el because it's being started
> with Emacs 28 or because it's fetching the package from 
> GNU ELPA?

Here's a patch that should fix this, by bringing back the function to
eldoc and marking it obsolete.  I'd of course much prefer if Elpy starts
using the new features of eldoc-documentation-functions instead, if
indeed it must be made to work with Emacs 28.  The bits of that
variable's docstring concerning the `:THING` and `:FACE` keyword
arguments should, in principle, be enough to do the same as the defunct
eldoc-docstring-format-sym-doc.  If they're not, then it's something to
be iterated in eldoc.el.

João


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Bring-back-eldoc-docstring-format-sym-doc-but-obsole.patch --]
[-- Type: text/x-diff, Size: 5035 bytes --]

From a8ac95944ca84ae094b5ae33d00b9966da969cdf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jo=C3=A3o=20T=C3=A1vora?= <joaotavora@gmail.com>
Date: Sun, 26 Jul 2020 11:10:11 +0100
Subject: [PATCH] Bring back eldoc-docstring-format-sym-doc but obsolete it

* lisp/cedet/semantic/grammar.el
(semantic--docstring-format-sym-doc): Call
eldoc-docstring-format-sym-doc.

* lisp/emacs-lisp/eldoc.el (eldoc-docstring-format-sym-doc): Bring
back from dead.
---
 lisp/cedet/semantic/grammar.el | 36 ++-----------------------------
 lisp/emacs-lisp/eldoc.el       | 39 ++++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+), 34 deletions(-)

diff --git a/lisp/cedet/semantic/grammar.el b/lisp/cedet/semantic/grammar.el
index 1ed18339a7..4acaa2fb22 100644
--- a/lisp/cedet/semantic/grammar.el
+++ b/lisp/cedet/semantic/grammar.el
@@ -1664,40 +1664,8 @@ semantic-grammar-syntax-help
 (defvar semantic-grammar-eldoc-last-data (cons nil nil))
 
 (defun semantic--docstring-format-sym-doc (prefix doc &optional face)
-  "Combine PREFIX and DOC, and shorten the result to fit in the echo area.
-
-When PREFIX is a symbol, propertize its symbol name with FACE
-before combining it with DOC.  If FACE is not provided, just
-apply the nil face.
-
-See also: `eldoc-echo-area-use-multiline-p'."
-  ;; Hoisted from old `eldoc-docstring-format-sym-doc'.
-  ;; If the entire line cannot fit in the echo area, the symbol name may be
-  ;; truncated or eliminated entirely from the output to make room for the
-  ;; description.
-  (when (symbolp prefix)
-    (setq prefix (concat (propertize (symbol-name prefix) 'face face) ": ")))
-  (let* ((ea-multi eldoc-echo-area-use-multiline-p)
-         ;; Subtract 1 from window width since emacs will not write
-         ;; any chars to the last column, or in later versions, will
-         ;; cause a wraparound and resize of the echo area.
-         (ea-width (1- (window-width (minibuffer-window))))
-         (strip (- (+ (length prefix)
-                      (length doc))
-                   ea-width)))
-    (cond ((or (<= strip 0)
-               (eq ea-multi t)
-               (and ea-multi (> (length doc) ea-width)))
-           (concat prefix doc))
-          ((> (length doc) ea-width)
-           (substring (format "%s" doc) 0 ea-width))
-          ((>= strip (string-match-p ":? *\\'" prefix))
-           doc)
-          (t
-           ;; Show the end of the partial symbol name, rather
-           ;; than the beginning, since the former is more likely
-           ;; to be unique given package namespace conventions.
-           (concat (substring prefix strip) doc)))))
+  "Call obsolete `eldoc-docstring-format-sym-doc', which see."
+  (eldoc-docstring-format-sym-doc prefix doc face))
 
 (defun semantic-grammar-eldoc-get-macro-docstring (macro expander)
   "Return a one-line docstring for the given grammar MACRO.
diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el
index fcb104e547..d2d68b30fe 100644
--- a/lisp/emacs-lisp/eldoc.el
+++ b/lisp/emacs-lisp/eldoc.el
@@ -809,6 +809,45 @@ eldoc-remove-command-completions
     (apply #'eldoc-remove-command
            (all-completions name eldoc-message-commands))))
 
+(make-obsolete 'eldoc-docstring-format-sym-doc
+               "Use features of `eldoc-documentation-functions' instead"
+               "eldoc-1.1.0")
+
+(defun eldoc-docstring-format-sym-doc (prefix doc &optional face)
+  "Combine PREFIX and DOC, and shorten the result to fit in the echo area.
+
+When PREFIX is a symbol, propertize its symbol name with FACE
+before combining it with DOC.  If FACE is not provided, just
+apply the nil face.
+
+See also: `eldoc-echo-area-use-multiline-p'."
+  ;; If the entire line cannot fit in the echo area, the symbol name may be
+  ;; truncated or eliminated entirely from the output to make room for the
+  ;; description.
+  (when (symbolp prefix)
+    (setq prefix (concat (propertize (symbol-name prefix) 'face face) ": ")))
+  (let* ((ea-multi eldoc-echo-area-use-multiline-p)
+         ;; Subtract 1 from window width since emacs will not write
+         ;; any chars to the last column, or in later versions, will
+         ;; cause a wraparound and resize of the echo area.
+         (ea-width (1- (window-width (minibuffer-window))))
+         (strip (- (+ (length prefix)
+                      (length doc))
+                   ea-width)))
+    (cond ((or (<= strip 0)
+               (eq ea-multi t)
+               (and ea-multi (> (length doc) ea-width)))
+           (concat prefix doc))
+          ((> (length doc) ea-width)
+           (substring (format "%s" doc) 0 ea-width))
+          ((>= strip (string-match-p ":? *\\'" prefix))
+           doc)
+          (t
+           ;; Show the end of the partial symbol name, rather
+           ;; than the beginning, since the former is more likely
+           ;; to be unique given package namespace conventions.
+           (concat (substring prefix strip) doc)))))
+
 \f
 ;; Prime the command list.
 (eldoc-add-command-completions
-- 
2.25.1


  reply	other threads:[~2020-07-26 10:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-24 15:21 eldoc-docstring-format-sym-doc Frank Haun
2020-07-24 19:49 ` eldoc-docstring-format-sym-doc Tassilo Horn
2020-07-24 20:29   ` eldoc-docstring-format-sym-doc Frank Haun
2020-07-25  6:16   ` eldoc-docstring-format-sym-doc Eli Zaretskii
2020-07-25  9:26     ` eldoc-docstring-format-sym-doc João Távora
2020-07-26 10:16       ` João Távora [this message]
2020-07-26 10:57         ` eldoc-docstring-format-sym-doc Frank Haun
2020-07-27 14:52           ` eldoc-docstring-format-sym-doc João Távora

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=87imeatwcg.fsf@gmail.com \
    --to=joaotavora@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=fh@fhaun.de \
    --cc=tsdh@gnu.org \
    /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).