[Top][All Lists]

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

bug#19338: [PATCH 1/3] eldoc: use default eldoc function if local one gi

From: Michal Nazarewicz
Subject: bug#19338: [PATCH 1/3] eldoc: use default eldoc function if local one gives no results
Date: Wed, 10 Dec 2014 18:49:43 +0100

From: Michal Nazarewicz <address@hidden>

* lisp/emacs-lisp/eldoc.el (eldoc-print-current-symbol-info): If
local `eldoc-documentation-function' returns no docstring and the
variable has a non-nil default value, try it as well.  This allows
setting up a global documentation function which will still be
used if given major mode has its own.
 etc/NEWS                 | 6 ++++--
 lisp/emacs-lisp/eldoc.el | 8 +++++++-
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 407df82..50338cf 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -199,8 +199,10 @@ typing RET.
 result of the calculation into the current buffer.
 ** ElDoc
-*** New minor mode global-eldoc-mode
-*** eldoc-documentation-function now defaults to nil
+*** New minor mode `global-eldoc-mode'
+*** `eldoc-documentation-function' now defaults to nil
+*** Default value of `eldoc-documentation-function now' is consulted if
+local function does not return any documentation.
 ** eww
diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el
index 6dddf5b..06ee164 100644
--- a/lisp/emacs-lisp/eldoc.el
+++ b/lisp/emacs-lisp/eldoc.el
@@ -345,7 +345,13 @@ This variable is expected to be set buffer-locally by 
modes that support ElDoc."
              (when eldoc-last-message
                (eldoc-message nil)
-        (eldoc-message (funcall eldoc-documentation-function)))))
+         (eldoc-message
+          (or (funcall eldoc-documentation-function)
+              ;; If local documentation function did not return anything, try
+              ;; global one.
+              (when (local-variable-p 'eldoc-documentation-function)
+                (let ((func (default-value 'eldoc-documentation-function)))
+                  (when func (funcall func)))))))))
 ;; When point is in a sexp, the function args are not reprinted in the echo

reply via email to

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