From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Andrii Kolomoiets Newsgroups: gmane.emacs.bugs Subject: bug#44885: 28.0.50; [PATCH] ElDoc buffer mode and separator Date: Thu, 03 Dec 2020 11:25:33 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18908"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (darwin) Cc: 44885@debbugs.gnu.org To: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Dec 03 10:26:18 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1kkksS-0004mo-SG for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 03 Dec 2020 10:26:16 +0100 Original-Received: from localhost ([::1]:60602 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kkksR-0005sM-Un for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 03 Dec 2020 04:26:15 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54266) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kkksE-0005rv-2R for bug-gnu-emacs@gnu.org; Thu, 03 Dec 2020 04:26:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:55047) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kkksD-0004D6-Oj for bug-gnu-emacs@gnu.org; Thu, 03 Dec 2020 04:26:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kkksD-00012H-LD for bug-gnu-emacs@gnu.org; Thu, 03 Dec 2020 04:26:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Andrii Kolomoiets Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 03 Dec 2020 09:26:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44885 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 44885-submit@debbugs.gnu.org id=B44885.16069875453952 (code B ref 44885); Thu, 03 Dec 2020 09:26:01 +0000 Original-Received: (at 44885) by debbugs.gnu.org; 3 Dec 2020 09:25:45 +0000 Original-Received: from localhost ([127.0.0.1]:38360 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kkkrw-00011g-S2 for submit@debbugs.gnu.org; Thu, 03 Dec 2020 04:25:45 -0500 Original-Received: from mail-lj1-f169.google.com ([209.85.208.169]:36780) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kkkrv-00011R-4D for 44885@debbugs.gnu.org; Thu, 03 Dec 2020 04:25:43 -0500 Original-Received: by mail-lj1-f169.google.com with SMTP id a1so423362ljq.3 for <44885@debbugs.gnu.org>; Thu, 03 Dec 2020 01:25:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=1HPBXJwRtG4UUq0BX7c3+OmSae52sA+Z6B/w0BnXmmE=; b=eoORU+1rL9GpwW9nxGQeIle60XZjzn4lUxgGW6VAGJcj57o28PE0Y212NdxtcL2h0J v+oFOfY11sNMciNbG6JkG/86wTPXAeuh0ftNUssksME0MyUG3+zsz6bj/LJJ3URzxXX2 /yAPILQpb3cB+tZMKPMnVjwzZTq3K+6OCvfIerWw49T8G10JoHWd7EmnaJOUr0bixXkK RntILBPSNHURUzmf9V8rlKa0FN01Lkecc9kD4Ad2EdpCiZNATAqGcJBlWSkrtjuDOTYU Ro633ej4S1PTWnc2++kdAvs0LKNO+MvKfhEdGnvKtSoV50EFjw9rDJBS/fOVs7dV0b/1 eBCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=1HPBXJwRtG4UUq0BX7c3+OmSae52sA+Z6B/w0BnXmmE=; b=FkOMltYiaStlpClp/MMSjlhtTgc42AHHQSY7tz2yfcrVDOSnSgpKKSKwt7IiG+rU+l C06fkpndgFaXYC0MGNj3L3klygh/W7en6hxNslyDU2XNIv9WWkR9pq5zQVoIdFI4Pk4w 1YBhRLwQXMS8ewPYkgMsq0SuH9tZd19r/AhmxjWIM6ZSiadFLUoPOwG5Awop2UZIWSQ3 5VbNvAVM232xNQci8rGzoqMS8rlgonXcNX+13nq7/x9YrxcS1buwg8glkXOYl61V4W6y xmk1okYqmBJVnHx4vundYVJYTU2YX5wukiPr8TaN0hIHA50Qc8uPKzRYW0VZuK5F7ye6 RQlg== X-Gm-Message-State: AOAM530gXp16skL/+XZ6OwnFS+mzQoycsXRYwYCh2+ECqgbC+B+Afglu PJdvFD1p7zi2ndpDZh8+bt+TCaw5sOE= X-Google-Smtp-Source: ABdhPJwpTK4uuT9D2SvysHf+NaKKjEKDCCqYwXlwoht5kVN+oxSqlPeGXz3sHhECvp960hT/8/Cqbg== X-Received: by 2002:a2e:9086:: with SMTP id l6mr833371ljg.91.1606987536470; Thu, 03 Dec 2020 01:25:36 -0800 (PST) Original-Received: from muffinmac ([91.206.110.206]) by smtp.gmail.com with ESMTPSA id u4sm226408lju.47.2020.12.03.01.25.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2020 01:25:35 -0800 (PST) In-Reply-To: ("=?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?="'s message of "Sat, 28 Nov 2020 23:54:36 +0000") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:194858 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Jo=C3=A3o T=C3=A1vora writes: > The only incompatibility I see between my idea and your current proposal > is the major mode that you picked for the Eldoc doc buffer. I wonder if > you could make it inherit from Help mode? Then it would glue better > with my idea. Sure. >> +(define-derived-mode eldoc-doc-mode fundamental-mode "ElDoc doc" >> + "Major mode for ElDoc documentation buffer." >> + (setq buffer-read-only t)) > > As I said above, I wonder if inheriting from help-mode wouldn't give us > most of this for free. Maybe it would bring us _too much_ though... The only reason I didn't inherit from `special-mode` is to avoid binding the `g` key to the `revert-buffer` function. > So some inheritance snipping would be needed. OK, will do. >> With little customization and custom display function in >> display-buffer-alist 'M-x eldoc-doc-buffer' can show the ElDoc buffer >> like some kind of tooltip. > > Very interesting. Can you share the display-buffer-alist hack that > allowed you to do this? I didn't think about the possibility of > tweaking it like this, but it's certainly "legal". See attached eldoc-frame.el. In emacs -Q: 1. M-x load-file eldoc-frame.el 2. Type "(setq" and wait a bit for eldoc message to appear in the echo area 3. C-c h > I wonder if you cann't do the same by adding a different function to > eldoc-display-functions, which was how I intented it to work. This will work even better. This way the "tooltip" can fit to content as soon as new docs will be shown. >> do (insert this-doc) >> - when rest do (insert "\n") >> + when rest do (insert eldoc-doc-buffer-separator) > > I like this and I like the separator, however, notice that the current > implementation of the eldoc-display-in-echo-area also uses this buffer > as an implementation detail. So this would break eldoc-display-in-echo > area. I was hoping it would look like an enhancement -- eldoc-separator everywhere! :) > The solution would be for eldoc-display-in-echo-area to use its own > "hidden" buffer and then eldoc-display-in-buffer would be free to format > the buffer as it sees fit. > > So you could extract the buffer-formatting code to a common helper, use > it in eldoc-display-in-echo-area with a "\n" separator and in > eldoc-display-in-buffer with an arbitrary user-chosen separator. The > performance hit of formatting two buffers would likely be negligible. OK, will do. --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=eldoc-frame.el Content-Transfer-Encoding: quoted-printable ;; -*- lexical-binding: t; -*- (setq eldoc-documentation-strategy 'eldoc-documentation-compose) (global-set-key (kbd "C-c h") 'eldoc-doc-buffer) (defvar eldoc-frame-frame nil) (defvar eldoc-frame-max-height 5) (defun eldoc-frame-hide (&optional frame) "Hide FRAME and select it's parent frame." (make-frame-invisible frame) (select-frame-set-input-focus (frame-parameter frame 'parent-frame))) (defun eldoc-frame-display (buffer alist) "Display eldoc BUFFER in child frame. ALIST is passed to `window--display-buffer'." (setq mode-line-format nil) (let ((frame (selected-frame))) (if (frame-live-p eldoc-frame-frame) (modify-frame-parameters eldoc-frame-frame `((parent-frame . ,frame))) (setq eldoc-frame-frame (let ((after-make-frame-functions nil)) (make-frame `((tool-bar-lines . 0) (visibility) (auto-hide-function . eldoc-frame-hide) (minibuffer) (undecorated . t) (background-color . "#e5e5e5") (vertical-scroll-bars) (horizontal-scroll-bars) (internal-border-width . 2) (parent-frame . ,frame))))) (set-face-background 'fringe nil eldoc-frame-frame) (set-face-background 'internal-border "#c0c0c0" eldoc-frame-frame)) (let ((eldoc-window (frame-selected-window eldoc-frame-frame)) (pos (pos-visible-in-window-p (window-point) nil t))) (modify-frame-parameters eldoc-frame-frame `((left . ,(+ (car pos) (car (window-edges nil t nil t)) (- (car (window-edges eldoc-window t nil t))))) (top . ,(+ (cadr pos) (cadr (window-edges nil nil nil t)) (frame-char-height frame))))) ;; (make-frame-visible eldoc-frame-frame) (prog1 (window--display-buffer buffer eldoc-window 'frame alist) (set-window-dedicated-p eldoc-window 'soft) (fit-frame-to-buffer eldoc-frame-frame eldoc-frame-max-height) (make-frame-visible eldoc-frame-frame))))) (add-to-list 'display-buffer-alist '("\\*eldoc.*" eldoc-frame-display)) --=-=-=--