unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Mathieu Marques <mathieumarques78@gmail.com>
To: 47109@debbugs.gnu.org
Subject: bug#47109: eldoc.el: Allow custom separator between documentations in the echo area
Date: Fri, 12 Mar 2021 20:10:17 +0100	[thread overview]
Message-ID: <CANgONYJ4cooM7Z-iPR9qKDnso8Dv9FYAq=Bt6_-uk2Dm72m+kA@mail.gmail.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 916 bytes --]

Hello,

While trying out eglot.el, I played around with eldoc.el and needed to
display all pieces of documentations in the echo area at once. The joined
patch allows for a custom separator between said documentations.

First patch is a fix to indenting levels as well as untabifying the whole
file. That was done automatically by my configuration and given the
existing code I thought it would be beneficial to most to provide a patch
for that as well. Feel free to dismiss it if needed.

The second patch is the subject of this very email. With the updated code,
in the user configuration, one can customize the separator to `"\n"` and
its face to `((t :inherit shadow :strike-through t))` in order to have a
horizontal line between documentations in the echo area for instance.

I've tried following conventions described over at gnu.org, do let me know
if I've missed anything.

Best regards

-- 
Mathieu Marques

[-- Attachment #1.2: Type: text/html, Size: 1209 bytes --]

[-- Attachment #2: 0001-lisp-emacs-lisp-eldoc.el-Untabify-and-fix-indent-lev.patch --]
[-- Type: text/x-patch, Size: 5337 bytes --]

From 63d8a5f88d5a23cb2df215125e81ac78dd0d7e6a Mon Sep 17 00:00:00 2001
From: Mathieu Marques <mathieumarques78@gmail.com>
Date: Fri, 12 Mar 2021 19:43:10 +0100
Subject: [PATCH 1/2] * lisp/emacs-lisp/eldoc.el: Untabify and fix indent
 levels

---
 lisp/emacs-lisp/eldoc.el | 58 ++++++++++++++++++++--------------------
 1 file changed, 29 insertions(+), 29 deletions(-)

diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el
index a02406a7b7..485ea26379 100644
--- a/lisp/emacs-lisp/eldoc.el
+++ b/lisp/emacs-lisp/eldoc.el
@@ -87,7 +87,7 @@ returns another string is acceptable.
 Note that this variable has no effect, unless
 `eldoc-documentation-strategy' handles it explicitly."
   :type '(radio (function-item upcase)
-		(function-item downcase)
+                (function-item downcase)
                 function))
 (make-obsolete-variable 'eldoc-argument-case nil "25.1")
 
@@ -183,12 +183,12 @@ It should receive the same arguments as `message'.")
 When `eldoc-print-after-edit' is non-nil, ElDoc messages are only
 printed after commands contained in this obarray."
   (let ((cmds (make-vector 31 0))
-	(re (regexp-opt '("delete" "insert" "edit" "electric" "newline"))))
+        (re (regexp-opt '("delete" "insert" "edit" "electric" "newline"))))
     (mapatoms (lambda (s)
-		(and (commandp s)
-		     (string-match-p re (symbol-name s))
-		     (intern (symbol-name s) cmds)))
-	      obarray)
+                (and (commandp s)
+                     (string-match-p re (symbol-name s))
+                     (intern (symbol-name s) cmds)))
+              obarray)
     cmds))
 
 \f
@@ -269,8 +269,8 @@ reflect the change."
            (memq eldoc-timer timer-idle-list)) ;FIXME: Why?
       (setq eldoc-timer
             (run-with-idle-timer
-	     eldoc-idle-delay nil
-	     (lambda ()
+             eldoc-idle-delay nil
+             (lambda ()
                (when (or eldoc-mode
                          (and global-eldoc-mode
                               (eldoc--supported-p)))
@@ -291,23 +291,23 @@ reflect the change."
 Otherwise work like `message'."
   (if (minibufferp)
       (progn
-	(add-hook 'minibuffer-exit-hook
-		  (lambda () (setq eldoc-mode-line-string nil
-			      ;; https://debbugs.gnu.org/16920
-			      eldoc-last-message nil))
-		  nil t)
-	(with-current-buffer
-	    (window-buffer
-	     (or (window-in-direction 'above (minibuffer-window))
-		 (minibuffer-selected-window)
-		 (get-largest-window)))
+        (add-hook 'minibuffer-exit-hook
+                  (lambda () (setq eldoc-mode-line-string nil
+                                   ;; https://debbugs.gnu.org/16920
+                                   eldoc-last-message nil))
+                  nil t)
+        (with-current-buffer
+            (window-buffer
+             (or (window-in-direction 'above (minibuffer-window))
+                 (minibuffer-selected-window)
+                 (get-largest-window)))
           (when (and mode-line-format
                      (not (and (listp mode-line-format)
                                (assq 'eldoc-mode-line-string mode-line-format))))
-	    (setq mode-line-format
-		  (list "" '(eldoc-mode-line-string
-			     (" " eldoc-mode-line-string " "))
-			mode-line-format)))
+            (setq mode-line-format
+                  (list "" '(eldoc-mode-line-string
+                             (" " eldoc-mode-line-string " "))
+                        mode-line-format)))
           (setq eldoc-mode-line-string
                 (when (stringp format-string)
                   (apply #'format-message format-string args)))
@@ -327,8 +327,8 @@ Also store it in `eldoc-last-message' and return that value."
     ;; Emacs way of preventing log messages.
     (let ((message-log-max nil))
       (cond (eldoc-last-message
-	     (funcall eldoc-message-function "%s" eldoc-last-message))
-	    (omessage (funcall eldoc-message-function nil)))))
+             (funcall eldoc-message-function "%s" eldoc-last-message))
+            (omessage (funcall eldoc-message-function nil)))))
   eldoc-last-message)
 
 (defun eldoc--message-command-p (command)
@@ -350,8 +350,8 @@ Also store it in `eldoc-last-message' and return that value."
   (and eldoc-last-message
        (not (minibufferp))      ;We don't use the echo area when in minibuffer.
        (if (and (eldoc-display-message-no-interference-p)
-		(eldoc--message-command-p this-command))
-	   (eldoc--message eldoc-last-message)
+                (eldoc--message-command-p this-command))
+           (eldoc--message eldoc-last-message)
          ;; No need to call eldoc--message since the echo area will be cleared
          ;; for us, but do note that the last-message will be gone.
          (setq eldoc-last-message nil))))
@@ -667,9 +667,9 @@ Meant as a value for `eldoc-documentation-strategy'."
        (progn
          (defcustom ,secondary ,value ,docstring ,@more)
          (define-obsolete-variable-alias ',main ',secondary "eldoc-1.1.0"))
-       (progn
-         (defcustom ,main ,value ,docstring  ,@more)
-         (defvaralias ',secondary ',main ,docstring))))
+     (progn
+       (defcustom ,main ,value ,docstring  ,@more)
+       (defvaralias ',secondary ',main ,docstring))))
 
 (eldoc--documentation-strategy-defcustom eldoc-documentation-strategy
     eldoc-documentation-function
-- 
2.30.1


[-- Attachment #3: 0002-lisp-emacs-lisp-eldoc.el-Allow-custom-separator.patch --]
[-- Type: text/x-patch, Size: 1746 bytes --]

From 184d5aa6e4d594b044a62e15b6eab084da0abb29 Mon Sep 17 00:00:00 2001
From: Mathieu Marques <mathieumarques78@gmail.com>
Date: Fri, 12 Mar 2021 19:45:18 +0100
Subject: [PATCH 2/2] * lisp/emacs-lisp/eldoc.el (eldoc--format-doc-buffer):
 Allow custom separator

---
 lisp/emacs-lisp/eldoc.el | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el
index 485ea26379..93cb6e7df5 100644
--- a/lisp/emacs-lisp/eldoc.el
+++ b/lisp/emacs-lisp/eldoc.el
@@ -129,6 +129,13 @@ window.  If the value is the symbol `maybe', then the echo area
 is only skipped if the documentation doesn't fit there."
   :type 'boolean)
 
+(defcustom eldoc-documentation-separator ""
+  "Separator to use between each documentation thing, when multiple."
+  :type 'string)
+
+(defface eldoc-documentation-separator '((t (:extend t :inherit shadow)))
+  "Face to use for the separator between documentation things.")
+
 (defface eldoc-highlight-function-argument
   '((t (:inherit bold)))
   "Face used for the argument at point in a function's argument list.
@@ -490,7 +497,11 @@ This holds the results of the last documentation request."
                         ": "
                         this-doc))
                  do (insert this-doc)
-                 when rest do (insert "\n")
+                 when rest
+                 do (insert (concat
+                             "\n"
+                             (propertize eldoc-documentation-separator
+                                         'face 'eldoc-documentation-separator)))
                  finally (goto-char (point-min)))
         ;; Rename the buffer, taking into account whether it was
         ;; hidden or not
-- 
2.30.1


             reply	other threads:[~2021-03-12 19:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-12 19:10 Mathieu Marques [this message]
2021-03-12 21:13 ` bug#47109: eldoc.el: Allow custom separator between documentations in the echo area Basil L. Contovounesios
2021-03-13 12:26   ` Mathieu Marques
2021-03-13 14:02     ` Basil L. Contovounesios
2021-03-13 14:35       ` João Távora
2021-03-18 18:30         ` Mathieu Marques
2021-05-17 15:37           ` Lars Ingebrigtsen
2021-05-17 15:44             ` João Távora
2021-05-18 13:39               ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CANgONYJ4cooM7Z-iPR9qKDnso8Dv9FYAq=Bt6_-uk2Dm72m+kA@mail.gmail.com' \
    --to=mathieumarques78@gmail.com \
    --cc=47109@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).