emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master c77731e 2/2: Fix ElDoc bugs around eldoc-echo-area-use-multiline-


From: João Távora
Subject: master c77731e 2/2: Fix ElDoc bugs around eldoc-echo-area-use-multiline-p.
Date: Sat, 18 Jul 2020 19:59:38 -0400 (EDT)

branch: master
commit c77731e824bbc219561cb9af0d3724e7b6cef789
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>

    Fix ElDoc bugs around eldoc-echo-area-use-multiline-p.
    
    If the value is 'truncate-sym-name-if-fit andthe single docstring
    doesn't fit in the echo area even when the symbol name is elided, that
    step shouldn't be attempted.  Also if the value is nil, really ensure
    that only the first line is shown.
    
    * lisp/emacs-lisp/eldoc.el (eldoc--handle-docs): Rework
    'truncate-sym-name-if-fit case of eldoc-echo-area-use-multiline-p.
---
 lisp/emacs-lisp/eldoc.el | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el
index 5741c52..6ed5bff 100644
--- a/lisp/emacs-lisp/eldoc.el
+++ b/lisp/emacs-lisp/eldoc.el
@@ -429,7 +429,7 @@ Honor most of `eldoc-echo-area-use-multiline-p'."
                       (integer val)
                       (t 1)))
          (things-reported-on)
-         single-sym-name)
+         single-doc single-doc-sym)
       ;; Then, compose the contents of the `*eldoc*' buffer.
       (with-current-buffer (eldoc-doc-buffer)
         (let ((inhibit-read-only t))
@@ -454,20 +454,24 @@ Honor most of `eldoc-echo-area-use-multiline-p'."
                                  (mapconcat (lambda (s) (format "%s" s))
                                             things-reported-on
                                             ", ")))))
-      ;; Finally, output to the echo area.  We handle the
-      ;; `truncate-sym-name-if-fit' special case first, by selecting a
-      ;; top-section of the `*eldoc' buffer.  I'm pretty sure nicer
+      ;; Finally, output to the echo area.  I'm pretty sure nicer
       ;; strategies can be used here, probably by splitting this
       ;; function into some `eldoc-display-functions' special hook.
       (let ((echo-area-message
              (cond
-              ((and
+              (;; We handle the `truncate-sym-name-if-fit' special
+               ;; case first, by checking if for a lot of special
+               ;; conditions.
+               (and
                 (eq 'truncate-sym-name-if-fit eldoc-echo-area-use-multiline-p)
                 (null (cdr docs))
-                (setq single-sym-name
+                (setq single-doc (caar docs))
+                (setq single-doc-sym
                       (format "%s" (plist-get (cdar docs) :thing)))
-                (> (+ (length (caar docs)) (length single-sym-name) 2) width))
-               (caar docs))
+                (< (length single-doc) width)
+                (not (string-match "\n" single-doc))
+                (> (+ (length single-doc) (length single-doc-sym) 2) width))
+               single-doc)
               ((> available 1)
                (with-current-buffer (eldoc-doc-buffer)
                  (cl-loop
@@ -497,7 +501,7 @@ Honor most of `eldoc-echo-area-use-multiline-p'."
                ;; Truncate "brutally." ; FIXME: use `eldoc-prefer-doc-buffer' 
too?
                (with-current-buffer (eldoc-doc-buffer)
                  (truncate-string-to-width
-                  (buffer-substring (point-min) (line-end-position 1)) 
width))))))
+                  (buffer-substring (goto-char (point-min)) (line-end-position 
1)) width))))))
         (when echo-area-message
           (eldoc--message echo-area-message))))))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]