aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Gutov2017-05-30 02:55:28 +0300
committerDmitry Gutov2017-05-30 02:55:28 +0300
commit2349f1df1b11381c421287670ffd0f84725d7818 (patch)
tree9dc9f92b5b35ca2da50ca7c03f2e1c63b135422e
parent4886b2ed52249597d1ea638f20c0ceb689075e72 (diff)
downloademacs-2349f1df1b11381c421287670ffd0f84725d7818.tar.gz
emacs-2349f1df1b11381c421287670ffd0f84725d7818.zip
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.
-rw-r--r--lisp/emacs-lisp/eldoc.el29
1 files changed, 9 insertions, 20 deletions
diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el
index 6cb8e6ce480..b0f6ea4412d 100644
--- a/lisp/emacs-lisp/eldoc.el
+++ b/lisp/emacs-lisp/eldoc.el
@@ -187,7 +187,8 @@ expression point is on."
187 (setq eldoc-last-message nil) 187 (setq eldoc-last-message nil)
188 (cond 188 (cond
189 ((memq eldoc-documentation-function '(nil ignore)) 189 ((memq eldoc-documentation-function '(nil ignore))
190 (message "There is no ElDoc support in this buffer") 190 (when (called-interactively-p 'any)
191 (message "There is no ElDoc support in this buffer"))
191 (setq eldoc-mode nil)) 192 (setq eldoc-mode nil))
192 (eldoc-mode 193 (eldoc-mode
193 (when eldoc-print-after-edit 194 (when eldoc-print-after-edit
@@ -203,29 +204,17 @@ expression point is on."
203 (setq eldoc-timer nil))))) 204 (setq eldoc-timer nil)))))
204 205
205;;;###autoload 206;;;###autoload
206(define-minor-mode global-eldoc-mode 207(define-globalized-minor-mode global-eldoc-mode eldoc-mode turn-on-eldoc-mode
207 "Toggle Global Eldoc mode on or off.
208With a prefix argument ARG, enable Global Eldoc mode if ARG is
209positive, and disable it otherwise. If called from Lisp, enable
210the mode if ARG is omitted or nil, and toggle it if ARG is ‘toggle’.
211
212If Global Eldoc mode is on, `eldoc-mode' will be enabled in all
213buffers where it's applicable. These are buffers that have modes
214that have enabled eldoc support. See `eldoc-documentation-function'."
215 :group 'eldoc 208 :group 'eldoc
216 :global t
217 :initialize 'custom-initialize-delay 209 :initialize 'custom-initialize-delay
218 :init-value t 210 :init-value t)
219 (setq eldoc-last-message nil)
220 (if global-eldoc-mode
221 (progn
222 (add-hook 'post-command-hook #'eldoc-schedule-timer)
223 (add-hook 'pre-command-hook #'eldoc-pre-command-refresh-echo-area))
224 (remove-hook 'post-command-hook #'eldoc-schedule-timer)
225 (remove-hook 'pre-command-hook #'eldoc-pre-command-refresh-echo-area)))
226 211
227;;;###autoload 212;;;###autoload
228(define-obsolete-function-alias 'turn-on-eldoc-mode 'eldoc-mode "24.4") 213(defun turn-on-eldoc-mode ()
214 "Turn on `eldoc-mode' if the buffer has eldoc support enabled.
215See `eldoc-documentation-function' for more detail."
216 (unless (memq eldoc-documentation-function '(nil ignore))
217 (eldoc-mode 1)))
229 218
230 219
231(defun eldoc-schedule-timer () 220(defun eldoc-schedule-timer ()