From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Newsgroups: gmane.emacs.devel Subject: Re: Need help with eldoc: Date: Fri, 25 Mar 2022 10:03:10 +0000 Message-ID: <87a6dee4dd.fsf@gmail.com> References: <25149.276.56904.499053@retriever.mtv.corp.google.com> <87ee2qevjs.fsf@gmail.com> <25149.10028.97873.940861@google.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="12418"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: "T.V Raman" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Mar 25 11:03:28 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 1nXgn0-00030o-2V for ged-emacs-devel@m.gmane-mx.org; Fri, 25 Mar 2022 11:03:26 +0100 Original-Received: from localhost ([::1]:36470 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nXgmy-0006vh-Db for ged-emacs-devel@m.gmane-mx.org; Fri, 25 Mar 2022 06:03:24 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:52428) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nXglt-0006Ew-3q for emacs-devel@gnu.org; Fri, 25 Mar 2022 06:02:17 -0400 Original-Received: from [2a00:1450:4864:20::330] (port=40560 helo=mail-wm1-x330.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nXglo-0001Sy-AS for emacs-devel@gnu.org; Fri, 25 Mar 2022 06:02:13 -0400 Original-Received: by mail-wm1-x330.google.com with SMTP id v130-20020a1cac88000000b00389d0a5c511so8649798wme.5 for ; Fri, 25 Mar 2022 03:02:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=1Ms7dXMZrvT9cd7rg23DpqrYIt+/XkuvXGS6xdacr54=; b=AVImqLKdhBLCFJqWhYkAWl3LKsUk7OP1efIyRxW6bQrYEHoe6ZtmNevObc4fkA4ri9 Jq2nydUN23xyA7L24U76/Al9Z+6VQ1fTVeT2DzXkJHaEh8+zAaBMkdPTDk+qfptdu56W BBju6IPfNStEMTOSGmQuqmDGx6xJSdjnILOndf07111AchPXNnT48ZfNSp0izQ3dmthM RtL8gymF/mh1ztO7xLPLKRvrYFVOIsBIUVVyB8U18Sjjsdn7xB7tdJrCx+red7vdvYZm 2E/WFD3RrpSE0V43BQ3NaLx5fzItDym68/y+XuWtHcQsOGm7/kqTpzGRg90uYQoDaEDk axPA== 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:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=1Ms7dXMZrvT9cd7rg23DpqrYIt+/XkuvXGS6xdacr54=; b=ShTQyAvEEwd29sNVXuip2gcMFe2Ndqtg3L33rSCxE8Ho75rTKjRnkGQuY3EEG4jJ3f 8Egf7cZ2iIE4D73/gbnYJFfcDLCLWaHyxE389ohs44S9CU3y7RqK6IE4AS71d6rmPyno X/uJcg0M9oai3p2SzYOJs9yOJlbYPQ0ZwFPvENyu0/xtu4Vyaawlv63VLhh1eq8aVMhb Ajjv0DMI2Gss0U6xGaA0M1HJ+K9sucDjMqkAAdOOk88BaL0XN/b1KrQtck9KYmFCeu7f tz+sDJvTrLnZbiZ8RChnajTSgvt3vqw12AnXkEdamWlcmXXkAAcL669NkpJTxgSJWRHf cYcg== X-Gm-Message-State: AOAM532IVNfSQ0dlCX80wxSyPaTd6BWmyilfr4Q5wWknEAABpX2jXyTp O4oWY4SKK8tCo23kNybGxmsIza9WqHKU3Q== X-Google-Smtp-Source: ABdhPJw7+YQxph5JOEMwKZO9OrcI0pZtaDojZnnR4JGEQILVJvFmAAVJ8XvdDwcaFsfObolQxKNxuA== X-Received: by 2002:a05:600c:1d04:b0:38c:ba2f:88ba with SMTP id l4-20020a05600c1d0400b0038cba2f88bamr8976309wms.137.1648202529855; Fri, 25 Mar 2022 03:02:09 -0700 (PDT) Original-Received: from krug (87-196-72-45.net.novis.pt. [87.196.72.45]) by smtp.gmail.com with ESMTPSA id e8-20020a056000178800b00203da3bb4d2sm5419276wrg.41.2022.03.25.03.02.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 03:02:09 -0700 (PDT) In-Reply-To: <25149.10028.97873.940861@google.com> (T. V. Raman's message of "Thu, 24 Mar 2022 19:21:32 -0700") X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::330 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=joaotavora@gmail.com; helo=mail-wm1-x330.google.com X-Spam_score_int: 27 X-Spam_score: 2.7 X-Spam_bar: ++ X-Spam_report: (2.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, RCVD_IN_SBL_CSS=3.335, 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: 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:287442 Archived-At: "T.V Raman" 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: =20=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))))) 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=C3=A3o 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-buf= fer'.") =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."