unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#44885: 28.0.50; [PATCH] ElDoc buffer mode and separator
@ 2020-11-26 12:42 Andrii Kolomoiets
  2020-11-28 23:54 ` João Távora
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Andrii Kolomoiets @ 2020-11-26 12:42 UTC (permalink / raw)
  To: 44885; +Cc: joaotavora

[-- Attachment #1: Type: text/plain, Size: 378 bytes --]

Hi,

Patch attached.

The configurable separator will make it possible to show multiple docs
in user pleasant way.

The mode will allow tweak ElDoc doc buffer appearance by adding hooks.

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.  See attached screenshot.

Thanks!


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ElDoc-buffer-mode-and-separator.patch --]
[-- Type: text/x-patch, Size: 3127 bytes --]

From d13320ce2126b944cb03272b5546e08251b266db Mon Sep 17 00:00:00 2001
From: Andrii Kolomoiets <andreyk.mad@gmail.com>
Date: Thu, 26 Nov 2020 14:21:54 +0200
Subject: [PATCH] ElDoc buffer mode and separator

* lisp/emacs-lisp/eldoc.el (eldoc-doc-buffer-separator): New option.
(eldoc-doc-mode-map): New keymap.
(eldoc-doc-mode): New mode.
(eldoc--format-doc-buffer): Use them.
---
 lisp/emacs-lisp/eldoc.el | 30 +++++++++++++++++++++++++++---
 1 file changed, 27 insertions(+), 3 deletions(-)

diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el
index 78cb8f08c3..e2c8d001d6 100644
--- a/lisp/emacs-lisp/eldoc.el
+++ b/lisp/emacs-lisp/eldoc.el
@@ -129,6 +129,11 @@ eldoc-echo-area-prefer-doc-buffer
 is only skipped if the documentation doesn't fit there."
   :type 'boolean)

+(defcustom eldoc-doc-buffer-separator "\n"
+  "String used by Eldoc to separate docs in the ElDoc documentation buffer."
+  :type 'string
+  :version "28.1")
+
 (defface eldoc-highlight-function-argument
   '((t (:inherit bold)))
   "Face used for the argument at point in a function's argument list.
@@ -465,6 +470,24 @@ eldoc-doc-buffer
                                              (buffer-name)))
     (display-buffer (current-buffer))))

+(defvar eldoc-doc-mode-map
+  (let ((map (make-sparse-keymap)))
+    (suppress-keymap map)
+    (define-key map "q" 'quit-window)
+    (define-key map " " 'scroll-up-command)
+    (define-key map [?\S-\ ] 'scroll-down-command)
+    (define-key map "\C-?" 'scroll-down-command)
+    (define-key map "?" 'describe-mode)
+    (define-key map "h" 'describe-mode)
+    (define-key map ">" 'end-of-buffer)
+    (define-key map "<" 'beginning-of-buffer)
+    map)
+  "Keymap used in ElDoc documentation buffer.")
+
+(define-derived-mode eldoc-doc-mode fundamental-mode "ElDoc doc"
+  "Major mode for ElDoc documentation buffer."
+  (setq buffer-read-only t))
+
 (defun eldoc--format-doc-buffer (docs)
   "Ensure DOCS are displayed in an *eldoc* buffer."
   (interactive (list t))
@@ -472,12 +495,13 @@ eldoc--format-doc-buffer
                            eldoc--doc-buffer
                          (setq eldoc--doc-buffer
                                (get-buffer-create " *eldoc*")))
+    (unless (eq major-mode 'eldoc-doc-mode)
+      (eldoc-doc-mode))
     (unless (eq docs eldoc--doc-buffer-docs)
       (setq-local eldoc--doc-buffer-docs docs)
       (let ((inhibit-read-only t)
             (things-reported-on))
-        (erase-buffer) (setq buffer-read-only t)
-        (local-set-key "q" 'quit-window)
+        (erase-buffer)
         (cl-loop for (docs . rest) on docs
                  for (this-doc . plist) = docs
                  for thing = (plist-get plist :thing)
@@ -490,7 +514,7 @@ eldoc--format-doc-buffer
                         ": "
                         this-doc))
                  do (insert this-doc)
-                 when rest do (insert "\n")
+                 when rest do (insert eldoc-doc-buffer-separator)
                  finally (goto-char (point-min)))
         ;; Rename the buffer, taking into account whether it was
         ;; hidden or not
--
2.15.1

[-- Attachment #3: eldoc.png --]
[-- Type: image/png, Size: 64179 bytes --]

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-09-11 11:33 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-26 12:42 bug#44885: 28.0.50; [PATCH] ElDoc buffer mode and separator Andrii Kolomoiets
2020-11-28 23:54 ` João Távora
2020-12-03  9:25   ` Andrii Kolomoiets
2020-11-29 13:02 ` Basil L. Contovounesios
2020-12-03 10:29   ` Andrii Kolomoiets
2021-01-25 14:19     ` Felician Nemeth
2021-09-08  9:44     ` Lars Ingebrigtsen
2021-09-08  9:46       ` João Távora
2021-09-08 18:56         ` Andrii Kolomoiets
2022-09-11 11:33 ` Lars Ingebrigtsen

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).