From: "T.V Raman" <raman@google.com>
To: joaotavora@gmail.com
Cc: raman@google.com, emacs-devel@gnu.org
Subject: Re: Need help with eldoc:
Date: Fri, 25 Mar 2022 07:03:22 -0700 [thread overview]
Message-ID: <25149.52138.240688.137767@retriever.mtv.corp.google.com> (raw)
In-Reply-To: <87a6dee4dd.fsf@gmail.com>
This is awesome!
Q: what is "patch in PS"?
Once you push the patch to emacs git I'll implement what you suggest
as the final solution.
One more question -- Once I have this working well for myself, I then
need to build a solution that works when Emacs 28 releases --- since I
cant depend on all emacspeak users running emacs from @HEAD, but I'd
like to first get the *final* solution right, then worry about
backwards compat.
João Távora writes:
> "T.V Raman" <raman@google.com> writes:
>
> > If I could be ensured of the eldoc always being in a buffer I could
> > eliminate most of the above, but I am also afraid that that will
> > recreate the earlier async problem which is why I didn't go there.
>
> Raman,
>
> You are completely on the right track, and I'm very glad it was
> reasonably straightforward. And yes, "ensuring eldoc always being in a
> buffer" is useful and possible -- if very slightly hacky, but read on.
>
> Anyway, if you read the eldoc code and search for
> eldoc--format-doc-buffer, you'll notice that the two members of
> eldoc-display-functions by default already share "the eldoc doc buffer".
> This avoids them repeating common needed work between themselves. In
> Emacsspeak, you have the same problem.
>
> So you have two options:
>
> 1. Make use of the internal function eldoc--format-doc-buffer. This has
> "ensure" semantics and returns the desired buffer. Then your
> function will become:
>
> (defun emacspeak-speak-eldoc (docs interactive)
> "Speak eldoc."
> (emacspeak-auditory-icon 'help)
> (when interactive
> (with-current-buffer (eldoc--format-doc-buffer docs)
> (dtk-speak (buffer-string)))))
>
> 2. Make sure that the function eldoc-display-in-buffer is always present
> in eldoc-display-functions. It will undertake to call
> eldoc--format-doc-buffer and place that work in the buffer that you
> can access with eldoc--doc-buffer. Your function becomes:
>
> (defun emacspeak-speak-eldoc (docs interactive)
> "Speak eldoc."
> (emacspeak-auditory-icon 'help)
> (when interactive
> (with-current-buffer eldoc--doc-buffer
> (dtk-speak (buffer-string)))))
>
> The reason I said before these solutions are slightly hacky is because
> of the usage of "internal --" symbols. But I guess it's reasonable to
> make one of these symbols "external". Or better yet, reuse the existing
> external function eldoc-doc-buffer and re-purpose it for non-interactive
> use. This is done in a patch to eldoc.el added in PS, which I think is
> reasonable.
>
> Then your function would become more idiomatic:
>
> (defun emacspeak-speak-eldoc (docs interactive)
> "Speak eldoc."
> (emacspeak-auditory-icon 'help)
> (when interactive
> (with-current-buffer (eldoc-doc-buffer)
> (dtk-speak (buffer-string)))))
>
> Let me know what you think,
> João
>
>
> diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el
> index 74ffeb166d..2d0656fb41 100644
> --- a/lisp/emacs-lisp/eldoc.el
> +++ b/lisp/emacs-lisp/eldoc.el
> @@ -464,19 +464,21 @@ eldoc--doc-buffer
>
> (defvar eldoc--doc-buffer-docs nil "Documentation items in `eldoc--doc-buffer'.")
>
> -(defun eldoc-doc-buffer ()
> +(defun eldoc-doc-buffer (&optional interactive)
> "Display ElDoc documentation buffer.
>
> This holds the results of the last documentation request."
> - (interactive)
> + (interactive (list t))
> (unless (buffer-live-p eldoc--doc-buffer)
> (user-error (format
> "ElDoc buffer doesn't exist, maybe `%s' to produce one."
> (substitute-command-keys "\\[eldoc]"))))
> (with-current-buffer eldoc--doc-buffer
> - (rename-buffer (replace-regexp-in-string "^ *" ""
> - (buffer-name)))
> - (display-buffer (current-buffer))))
> + (cond (interactive
> + (rename-buffer (replace-regexp-in-string "^ *" ""
> + (buffer-name)))
> + (display-buffer (current-buffer)))
> + (t (current-buffer)))))
>
> (defun eldoc--format-doc-buffer (docs)
> "Ensure DOCS are displayed in an *eldoc* buffer."
>
>
>
>
>
>
--
Thanks,
--Raman(I Search, I Find, I Misplace, I Research)
♉ Id: kg:/m/0285kf1 🦮
--
Thanks,
--Raman(I Search, I Find, I Misplace, I Research)
♉ Id: kg:/m/0285kf1 🦮
next prev parent reply other threads:[~2022-03-25 14:03 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-24 14:21 Need help with eldoc: T.V Raman
2022-03-24 23:28 ` João Távora
2022-03-24 23:39 ` T.V Raman
2022-03-25 0:16 ` João Távora
2022-03-25 2:21 ` T.V Raman
2022-03-25 10:03 ` João Távora
2022-03-25 14:03 ` T.V Raman [this message]
2022-03-25 22:52 ` João Távora
2022-03-25 14:27 ` T.V Raman
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=25149.52138.240688.137767@retriever.mtv.corp.google.com \
--to=raman@google.com \
--cc=emacs-devel@gnu.org \
--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).