From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "T.V Raman" Newsgroups: gmane.emacs.devel Subject: Re: Need help with eldoc: Date: Fri, 25 Mar 2022 07:03:22 -0700 Message-ID: <25149.52138.240688.137767@retriever.mtv.corp.google.com> References: <25149.276.56904.499053@retriever.mtv.corp.google.com> <87ee2qevjs.fsf@gmail.com> <25149.10028.97873.940861@google.com> <87a6dee4dd.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10379"; mail-complaints-to="usenet@ciao.gmane.io" Cc: raman@google.com, emacs-devel@gnu.org To: joaotavora@gmail.com Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Mar 25 15:07:11 2022 Return-path: Envelope-to: ged-emacs-devel@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 1nXkas-0002SK-Un for ged-emacs-devel@m.gmane-mx.org; Fri, 25 Mar 2022 15:07:11 +0100 Original-Received: from localhost ([::1]:39022 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nXkar-0003f0-S6 for ged-emacs-devel@m.gmane-mx.org; Fri, 25 Mar 2022 10:07:09 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:53254) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nXkXN-00011T-Ea for emacs-devel@gnu.org; Fri, 25 Mar 2022 10:03:33 -0400 Original-Received: from [2607:f8b0:4864:20::529] (port=33728 helo=mail-pg1-x529.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nXkXL-0003Bj-ML for emacs-devel@gnu.org; Fri, 25 Mar 2022 10:03:33 -0400 Original-Received: by mail-pg1-x529.google.com with SMTP id k14so6548908pga.0 for ; Fri, 25 Mar 2022 07:03:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=from:mime-version:content-transfer-encoding:message-id:date:to:cc :subject:in-reply-to:references; bh=Z6JjhujnSRu6agd2oKsd4yEW7lxE8I1M3y2nO1+3b24=; b=W6s5fcWF7fsiGPpfhBGVA9rPSMZbgoDpE5YQwP7mfjq3GslY9xRJZzWsqFasE6Rdtj 70ZGHGRdh7HcyJ7JNSPYHzHT2YCeJq367Boa5bajfu96Ykc2UbkicyO2WdRTAmQ5ALE+ zPeFWu9kgkCDxgPRPMgwjjFGmqqLr+/hj2Yw9hB+cq4n6ZRcNrZEjavCzf64LSTfDZza Kfan8qvTi8cQZO0qzsbnPylHn9PzERzpGKVgKUPV7Y0mryZIYdJhROtQ4gP1GkaXFF6W d00KRrOnYa7ozYg40wGsBVG+cagFmes/ZdRpkyRgmmmGU5jt1ynzsz5rG4fUlfAQLjMk joUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:mime-version:content-transfer-encoding :message-id:date:to:cc:subject:in-reply-to:references; bh=Z6JjhujnSRu6agd2oKsd4yEW7lxE8I1M3y2nO1+3b24=; b=VNieVGjSLhwM4Nrz+8vmyY3lpBFmOj9NEyeW+G+Gz9VBvPl8zy3yoeQHkkZQY8i8si okwmyo2dMUoabD1Mh5XqqZRHrnIUhxxHr0b3nzMGFcXv8ptqRKG+UG8WacZ+ivo1h+iY xhWbkC21MpbkkmktVT+7P90LL6LOj2xR9PhsmhG2dI2UabO6KLc0OZFdZ74p59oZ5bjy uUkxqxngkgPVCqezrfiTaxbrfcDIQ7F4JcNzOwJ+y34nhmTLhJYK9tcyhrLUXZ6JnJgD yZ7eXnwJdCObkkivHJPP6gqVs0+SVd5TfpTX8RKGON1ORDwigM/XOVKW45ZL1MH9ukeF BgVw== X-Gm-Message-State: AOAM5317DOn0ogSAm4tWyr0WLVasONjaznzsVmC9th3AFbEH/AUCnt4M QJ7AM+2hjWJ4E+N5UIwX/cCCsTvexYCb/w== X-Google-Smtp-Source: ABdhPJzV9OknQo0SLSYdlLbp30eP/FoS1haqh4iOZi/6rvaqbMFnMJNW2+XgnIX/jaNbgJ1og7M4XQ== X-Received: by 2002:a05:6a00:2408:b0:4f7:a8cb:9b63 with SMTP id z8-20020a056a00240800b004f7a8cb9b63mr10145828pfh.33.1648217008951; Fri, 25 Mar 2022 07:03:28 -0700 (PDT) Original-Received: from retriever.mtv.corp.google.com ([2620:0:1000:1510:feb0:2be9:334c:b4e9]) by smtp.gmail.com with ESMTPSA id fy9-20020a17090b020900b001c690bc05c4sm6226925pjb.0.2022.03.25.07.03.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 07:03:27 -0700 (PDT) In-Reply-To: <87a6dee4dd.fsf@gmail.com> X-Mailer: VM 8.1.1 under 29.0.50 (x86_64-pc-linux-gnu) X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::529 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::529; envelope-from=raman@google.com; helo=mail-pg1-x529.google.com X-Spam_score_int: -161 X-Spam_score: -16.2 X-Spam_bar: ---------------- X-Spam_report: (-16.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, ENV_AND_HDR_SPF_MATCH=-0.5, NICE_REPLY_A=-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, USER_IN_DEF_DKIM_WL=-7.5, USER_IN_DEF_SPF_WL=-7.5 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:287451 Archived-At: This is awesome! Q: what is "patch in PS"=3F 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=C3=A3o T=C3=A1vora writes: > "T.V Raman" writes: >=20 > > If I could be ensured of the eldoc always being in a buffer I coul= d > > 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.= >=20 > Raman, >=20 > You are completely on the right track, and I'm very glad it was > reasonably straightforward. And yes, "ensuring eldoc always being i= n a > buffer" is useful and possible -- if very slightly hacky, but read o= n. >=20 > 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 buff= er". > This avoids them repeating common needed work between themselves. I= n > Emacsspeak, you have the same problem. >=20 > So you have two options: >=20 > 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: > =20 > (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))))) >=20 > 2. Make sure that the function eldoc-display-in-buffer is always pre= sent > in eldoc-display-functions. It will undertake to call > eldoc--format-doc-buffer and place that work in the buffer that y= ou > can access with eldoc--doc-buffer. Your function becomes: >=20 > (defun emacspeak-speak-eldoc (docs interactive) > "Speak eldoc." > (emacspeak-auditory-icon 'help) > (when interactive > (with-current-buffer eldoc--doc-buffer > (dtk-speak (buffer-string))))) >=20 > The reason I said before these solutions are slightly hacky is becau= se > of the usage of "internal --" symbols. But I guess it's reasonable = to > make one of these symbols "external". Or better yet, reuse the exis= ting > external function eldoc-doc-buffer and re-purpose it for non-interac= tive > use. This is done in a patch to eldoc.el added in PS, which I think= is > reasonable. >=20 > Then your function would become more idiomatic: >=20 > (defun emacspeak-speak-eldoc (docs interactive) > "Speak eldoc." > (emacspeak-auditory-icon 'help) > (when interactive > (with-current-buffer (eldoc-doc-buffer) > (dtk-speak (buffer-string))))) >=20 > Let me know what you think, > Jo=C3=A3o >=20 >=20 > 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 > =20 > (defvar eldoc--doc-buffer-docs nil "Documentation items in `eldoc--= doc-buffer'.") > =20 > -(defun eldoc-doc-buffer () > +(defun eldoc-doc-buffer (&optional interactive) > "Display ElDoc documentation buffer. > =20 > 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))))) > =20 > (defun eldoc--format-doc-buffer (docs) > "Ensure DOCS are displayed in an *eldoc* buffer." >=20 >=20 >=20 >=20 >=20 >=20 --=20 Thanks, --Raman(I Search, I Find, I Misplace, I Research) =E2=99=89 Id: kg:/m/0285kf1 =F0=9F=A6=AE -- Thanks, --Raman(I Search, I Find, I Misplace, I Research) ♉ Id: kg:/m/0285kf1 🦮