all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] 28.0.50 Keep point position in *eldoc* buffer
@ 2020-11-25 20:20 Andrii Kolomoiets
  2020-11-26 10:25 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: Andrii Kolomoiets @ 2020-11-25 20:20 UTC (permalink / raw)
  To: emacs-devel

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

Hi,

1. emacs -Q
2. (setq
Wait for eldoc shows the message.
3. M-x eldoc-doc-buffer

The point is at the end of the text shown in the minibuffer.

Patch attached.

Thanks!

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Keep-point-position-in-eldoc-buffer.patch --]
[-- Type: text/x-patch, Size: 2900 bytes --]

From 7e995dbcbe22b95e793e64961a62346adf370af0 Mon Sep 17 00:00:00 2001
From: Andrii Kolomoiets <andreyk.mad@gmail.com>
Date: Wed, 25 Nov 2020 21:55:25 +0200
Subject: [PATCH] Keep point position in *eldoc* buffer

* list/emacs-lisp/eldoc.el (eldoc--echo-area-substring): Use 'save-excursion'
to keep point position in *eldoc* buffer
---
 lisp/emacs-lisp/eldoc.el | 43 ++++++++++++++++++++++---------------------
 1 file changed, 22 insertions(+), 21 deletions(-)

diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el
index 78cb8f08c3..9f6cc65842 100644
--- a/lisp/emacs-lisp/eldoc.el
+++ b/lisp/emacs-lisp/eldoc.el
@@ -508,27 +508,28 @@ eldoc--format-doc-buffer
 (defun eldoc--echo-area-substring (available)
   "Given AVAILABLE lines, get buffer substring to display in echo area.
 Helper for `eldoc-display-in-echo-area'."
-  (let ((start (prog1 (progn
-                        (goto-char (point-min))
-                        (skip-chars-forward " \t\n")
-                        (point))
-                 (goto-char (line-end-position available))
-                 (skip-chars-backward " \t\n")))
-        (truncated (save-excursion
-                     (skip-chars-forward " \t\n")
-                     (not (eobp)))))
-    (cond ((eldoc--echo-area-prefer-doc-buffer-p truncated)
-           nil)
-          ((and truncated
-                (> available 1)
-                eldoc-echo-area-display-truncation-message)
-           (goto-char (line-end-position 0))
-           (concat (buffer-substring start (point))
-                   (format
-                    "\n(Documentation truncated. Use `%s' to see rest)"
-                    (substitute-command-keys "\\[eldoc-doc-buffer]"))))
-          (t
-           (buffer-substring start (point))))))
+  (save-excursion
+    (let ((start (prog1 (progn
+                          (goto-char (point-min))
+                          (skip-chars-forward " \t\n")
+                          (point))
+                   (goto-char (line-end-position available))
+                   (skip-chars-backward " \t\n")))
+          (truncated (save-excursion
+                       (skip-chars-forward " \t\n")
+                       (not (eobp)))))
+      (cond ((eldoc--echo-area-prefer-doc-buffer-p truncated)
+             nil)
+            ((and truncated
+                  (> available 1)
+                  eldoc-echo-area-display-truncation-message)
+             (goto-char (line-end-position 0))
+             (concat (buffer-substring start (point))
+                     (format
+                      "\n(Documentation truncated. Use `%s' to see rest)"
+                      (substitute-command-keys "\\[eldoc-doc-buffer]"))))
+            (t
+             (buffer-substring start (point)))))))
 
 (defun eldoc--echo-area-prefer-doc-buffer-p (truncatedp)
   "Tell if display in the echo area should be skipped.
-- 
2.15.1


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

end of thread, other threads:[~2020-11-26 10:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-25 20:20 [PATCH] 28.0.50 Keep point position in *eldoc* buffer Andrii Kolomoiets
2020-11-26 10:25 ` Lars Ingebrigtsen

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.