emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 2349f1d: Turn global-eldoc-mode into a globalized m


From: Dmitry Gutov
Subject: [Emacs-diffs] master 2349f1d: Turn global-eldoc-mode into a globalized minor mode
Date: Mon, 29 May 2017 19:55:39 -0400 (EDT)

branch: master
commit 2349f1df1b11381c421287670ffd0f84725d7818
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>

    Turn global-eldoc-mode into a globalized minor mode
    
    * lisp/emacs-lisp/eldoc.el (global-eldoc-mode):
    Turn into globalized mode (bug#19853).
    (turn-on-eldoc-mode): Make it into a wrapper instead of alias.
    (eldoc-mode): Only show the message when called interactively.
---
 lisp/emacs-lisp/eldoc.el | 29 +++++++++--------------------
 1 file changed, 9 insertions(+), 20 deletions(-)

diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el
index 6cb8e6c..b0f6ea4 100644
--- a/lisp/emacs-lisp/eldoc.el
+++ b/lisp/emacs-lisp/eldoc.el
@@ -187,7 +187,8 @@ expression point is on."
   (setq eldoc-last-message nil)
   (cond
    ((memq eldoc-documentation-function '(nil ignore))
-    (message "There is no ElDoc support in this buffer")
+    (when (called-interactively-p 'any)
+      (message "There is no ElDoc support in this buffer"))
     (setq eldoc-mode nil))
    (eldoc-mode
     (when eldoc-print-after-edit
@@ -203,29 +204,17 @@ expression point is on."
       (setq eldoc-timer nil)))))
 
 ;;;###autoload
-(define-minor-mode global-eldoc-mode
-  "Toggle Global Eldoc mode on or off.
-With a prefix argument ARG, enable Global Eldoc mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil, and toggle it if ARG is ‘toggle’.
-
-If Global Eldoc mode is on, `eldoc-mode' will be enabled in all
-buffers where it's applicable.  These are buffers that have modes
-that have enabled eldoc support.  See `eldoc-documentation-function'."
+(define-globalized-minor-mode global-eldoc-mode eldoc-mode turn-on-eldoc-mode
   :group 'eldoc
-  :global t
   :initialize 'custom-initialize-delay
-  :init-value t
-  (setq eldoc-last-message nil)
-  (if global-eldoc-mode
-      (progn
-       (add-hook 'post-command-hook #'eldoc-schedule-timer)
-       (add-hook 'pre-command-hook #'eldoc-pre-command-refresh-echo-area))
-    (remove-hook 'post-command-hook #'eldoc-schedule-timer)
-    (remove-hook 'pre-command-hook #'eldoc-pre-command-refresh-echo-area)))
+  :init-value t)
 
 ;;;###autoload
-(define-obsolete-function-alias 'turn-on-eldoc-mode 'eldoc-mode "24.4")
+(defun turn-on-eldoc-mode ()
+  "Turn on `eldoc-mode' if the buffer has eldoc support enabled.
+See `eldoc-documentation-function' for more detail."
+  (unless (memq eldoc-documentation-function '(nil ignore))
+    (eldoc-mode 1)))
 
 
 (defun eldoc-schedule-timer ()



reply via email to

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