emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Need help with eldoc:


From: T.V Raman
Subject: Re: Need help with eldoc:
Date: Fri, 25 Mar 2022 07:03:22 -0700

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  🦮



reply via email to

[Prev in Thread] Current Thread [Next in Thread]